~ubuntu-branches/ubuntu/saucy/quantum/saucy

« back to all changes in this revision

Viewing changes to quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-05-31 09:37:25 UTC
  • mfrom: (2.1.22)
  • Revision ID: package-import@ubuntu.com-20130531093725-bf9jom93l7jm57iv
Tags: 1:2013.2~b1-0ubuntu1
* New upstream release.
* debian/patches/fix-quantum-configuration.patch: Refreshed
* debian/control: Add testrepository.
* debian/control: Add subunit.
* debian/control: Add python-d21o1 and python-pbr as build-depends.
* debian/control: Add python-stevedore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
to the Network Operating System by PLUMgrid called NOS
22
22
"""
23
23
 
24
 
import sys
25
 
 
26
24
from oslo.config import cfg
27
25
 
28
26
from quantum.db import api as db
67
65
        self.topology_name = cfg.CONF.PLUMgridNOS.topologyname
68
66
        self.snippets = plumgrid_nos_snippets.DataNOSPLUMgrid()
69
67
 
70
 
        # TODO: (Edgar) These are placeholders for next PLUMgrid release
71
 
        nos_username = cfg.CONF.PLUMgridNOS.username
72
 
        nos_password = cfg.CONF.PLUMgridNOS.password
 
68
        # TODO(Edgar) These are placeholders for next PLUMgrid release
 
69
        cfg.CONF.PLUMgridNOS.username
 
70
        cfg.CONF.PLUMgridNOS.password
73
71
        self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
74
72
                                                        nos_port, timeout)
75
73
        if self.rest_conn is None:
90
88
                        'PLUMgrid Plugin has started'))
91
89
 
92
90
    def create_network(self, context, network):
93
 
        """
94
 
        Create network core Quantum API
95
 
        """
 
91
        """Create network core Quantum API."""
96
92
 
97
93
        LOG.debug(_('QuantumPluginPLUMgrid Status: create_network() called'))
98
94
 
106
102
                                                                      network)
107
103
 
108
104
            try:
109
 
                LOG.debug(_('QuantumPluginPLUMgrid Status: %s, %s, %s'),
110
 
                          tenant_id, network["network"], net["id"])
 
105
                LOG.debug(_('QuantumPluginPLUMgrid Status: %(tenant_id)s, '
 
106
                            '%(network)s, %(network_id)s'),
 
107
                          dict(
 
108
                              tenant_id=tenant_id,
 
109
                              network=network["network"],
 
110
                              network_id=net["id"],
 
111
                          ))
111
112
                nos_url = self.snippets.BASE_NOS_URL + net["id"]
112
113
                headers = {}
113
114
                body_data = self.snippets.create_domain_body_data(tenant_id)
114
115
                self.rest_conn.nos_rest_conn(nos_url,
115
116
                                             'PUT', body_data, headers)
116
117
 
117
 
            except:
 
118
            except Exception:
118
119
                err_message = _("PLUMgrid NOS communication failed")
119
120
                LOG.Exception(err_message)
120
121
                raise plum_excep.PLUMgridException(err_message)
123
124
        return net
124
125
 
125
126
    def update_network(self, context, net_id, network):
126
 
        """
127
 
        Update network core Quantum API
128
 
        """
 
127
        """Update network core Quantum API."""
129
128
 
130
129
        LOG.debug(_("QuantumPluginPLUMgridV2.update_network() called"))
131
130
        self._network_admin_state(network)
132
131
        tenant_id = self._get_tenant_id_for_create(context, network["network"])
133
132
 
134
 
        # Get initial network details
135
 
        original_net = super(QuantumPluginPLUMgridV2, self).get_network(
136
 
            context, net_id)
137
 
 
138
133
        with context.session.begin(subtransactions=True):
139
134
            # Plugin DB - Network Update
140
135
            new_network = super(
152
147
                body_data = self.snippets.create_domain_body_data(tenant_id)
153
148
                self.rest_conn.nos_rest_conn(nos_url,
154
149
                                             'PUT', body_data, headers)
155
 
            except:
 
150
            except Exception:
156
151
                err_message = _("PLUMgrid NOS communication failed")
157
152
                LOG.Exception(err_message)
158
153
                raise plum_excep.PLUMgridException(err_message)
161
156
        return new_network
162
157
 
163
158
    def delete_network(self, context, net_id):
164
 
        """
165
 
        Delete network core Quantum API
166
 
        """
 
159
        """Delete network core Quantum API."""
167
160
        LOG.debug(_("QuantumPluginPLUMgrid Status: delete_network() called"))
168
161
        super(QuantumPluginPLUMgridV2, self).get_network(context, net_id)
169
162
 
170
163
        with context.session.begin(subtransactions=True):
171
164
            # Plugin DB - Network Delete
172
 
            net_deleted = super(QuantumPluginPLUMgridV2,
173
 
                                self).delete_network(context, net_id)
 
165
            super(QuantumPluginPLUMgridV2, self).delete_network(context,
 
166
                                                                net_id)
174
167
 
175
168
            try:
176
169
                nos_url = self.snippets.BASE_NOS_URL + net_id
178
171
                body_data = {}
179
172
                self.rest_conn.nos_rest_conn(nos_url,
180
173
                                             'DELETE', body_data, headers)
181
 
            except:
 
174
            except Exception:
182
175
                err_message = _("PLUMgrid NOS communication failed")
183
176
                LOG.Exception(err_message)
184
177
                raise plum_excep.PLUMgridException(err_message)
185
178
 
186
179
    def create_port(self, context, port):
187
 
        """
188
 
        Create port core Quantum API
189
 
        """
 
180
        """Create port core Quantum API."""
190
181
        LOG.debug(_("QuantumPluginPLUMgrid Status: create_port() called"))
191
182
 
192
183
        # Port operations on PLUMgrid NOS is an automatic operation from the
198
189
                                                                port)
199
190
 
200
191
    def update_port(self, context, port_id, port):
201
 
        """
202
 
        Update port core Quantum API
203
 
 
204
 
        """
 
192
        """Update port core Quantum API."""
205
193
        LOG.debug(_("QuantumPluginPLUMgrid Status: update_port() called"))
206
194
 
207
195
        # Port operations on PLUMgrid NOS is an automatic operation from the
212
200
            context, port_id, port)
213
201
 
214
202
    def delete_port(self, context, port_id):
215
 
        """
216
 
        Delete port core Quantum API
217
 
        """
 
203
        """Delete port core Quantum API."""
218
204
 
219
205
        LOG.debug(_("QuantumPluginPLUMgrid Status: delete_port() called"))
220
206
 
225
211
        super(QuantumPluginPLUMgridV2, self).delete_port(context, port_id)
226
212
 
227
213
    def create_subnet(self, context, subnet):
228
 
        """
229
 
        Create subnet core Quantum API
230
 
        """
 
214
        """Create subnet core Quantum API."""
231
215
 
232
216
        LOG.debug(_("QuantumPluginPLUMgrid Status: create_subnet() called"))
233
217
 
246
230
                    tenant_id, self.topology_name)
247
231
                self.rest_conn.nos_rest_conn(nos_url,
248
232
                                             'PUT', body_data, headers)
249
 
            except:
 
233
            except Exception:
250
234
                err_message = _("PLUMgrid NOS communication failed: ")
251
235
                LOG.Exception(err_message)
252
236
                raise plum_excep.PLUMgridException(err_message)
254
238
        return subnet
255
239
 
256
240
    def delete_subnet(self, context, subnet_id):
257
 
        """
258
 
        Delete subnet core Quantum API
259
 
        """
 
241
        """Delete subnet core Quantum API."""
260
242
 
261
243
        LOG.debug(_("QuantumPluginPLUMgrid Status: delete_subnet() called"))
262
244
        #Collecting subnet info
271
253
                body_data = {}
272
254
                net_id = subnet_details["network_id"]
273
255
                self._cleaning_nos_subnet_structure(body_data, headers, net_id)
274
 
            except:
 
256
            except Exception:
275
257
                err_message = _("PLUMgrid NOS communication failed: ")
276
258
                LOG.Exception(err_message)
277
259
                raise plum_excep.PLUMgridException(err_message)
279
261
        return del_subnet
280
262
 
281
263
    def update_subnet(self, context, subnet_id, subnet):
282
 
        """
283
 
        Update subnet core Quantum API
284
 
        """
 
264
        """Update subnet core Quantum API."""
285
265
 
286
266
        LOG.debug(_("update_subnet() called"))
287
267
        #Collecting subnet info
305
285
                self.rest_conn.nos_rest_conn(nos_url,
306
286
                                             'PUT', body_data, headers)
307
287
 
308
 
            except:
 
288
            except Exception:
309
289
                err_message = _("PLUMgrid NOS communication failed: ")
310
290
                LOG.Exception(err_message)
311
291
                raise plum_excep.PLUMgridException(err_message)
315
295
    """
316
296
    Extension API implementation
317
297
    """
318
 
    # TODO: (Edgar) Complete extensions for PLUMgrid
 
298
    # TODO(Edgar) Complete extensions for PLUMgrid
319
299
 
320
300
    """
321
301
    Internal PLUMgrid fuctions
338
318
                    LOG.warning(_("Network with admin_state_up=False are not "
339
319
                                  "supported yet by this plugin. Ignoring "
340
320
                                  "setting for network %s"), network_name)
341
 
        except:
 
321
        except Exception:
342
322
            err_message = _("Network Admin State Validation Falied: ")
343
323
            LOG.Exception(err_message)
344
324
            raise plum_excep.PLUMgridException(err_message)