Merge lp:~snaiksat/neutron/sumit-post-diablo-rbp into lp:~cisco-openstack/neutron/post-diablo-rbp
- sumit-post-diablo-rbp
- Merge into post-diablo-rbp
Proposed by
Sumit Naiksatam
Status: | Merged |
---|---|
Merged at revision: | 73 |
Proposed branch: | lp:~snaiksat/neutron/sumit-post-diablo-rbp |
Merge into: | lp:~cisco-openstack/neutron/post-diablo-rbp |
Diff against target: |
795 lines (+262/-114) 17 files modified
extensions/_novatenant_view.py (+4/-0) extensions/novatenant.py (+23/-1) quantum/plugins/cisco/README (+24/-10) quantum/plugins/cisco/common/cisco_configparser.py (+0/-4) quantum/plugins/cisco/common/cisco_constants.py (+10/-0) quantum/plugins/cisco/common/cisco_credentials.py (+0/-4) quantum/plugins/cisco/common/cisco_exceptions.py (+8/-0) quantum/plugins/cisco/common/cisco_utils.py (+2/-3) quantum/plugins/cisco/db/ucs_db.py (+32/-0) quantum/plugins/cisco/l2network_plugin.py (+33/-10) quantum/plugins/cisco/models/l2network_multi_blade.py (+11/-4) quantum/plugins/cisco/models/l2network_single_blade.py (+9/-3) quantum/plugins/cisco/nova/vifdirect.py (+25/-19) quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py (+2/-3) quantum/plugins/cisco/ucs/cisco_ucs_inventory.py (+32/-13) quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py (+2/-4) quantum/plugins/cisco/ucs/cisco_ucs_plugin.py (+45/-36) |
To merge this branch: | bzr merge lp:~snaiksat/neutron/sumit-post-diablo-rbp |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ying Liu (community) | Approve | ||
Edgar Magana (community) | Approve | ||
Review via email: mp+78535@code.launchpad.net |
Commit message
Description of the change
* Clarification on hostname convention.
* The exceptions file was updated was not checked in before. Also fixed a bug in l2network_plugin, to reference the correct exception class.
* Updated README to clarify plug/unplug operations.
* update_
* removing debug statements
* Changes for component-specific logging and fixes for VIF-ID association and disassociation.
* Adding detach_port extension operation to be invoked from the unplug method in vif driver.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'extensions/_novatenant_view.py' |
2 | --- extensions/_novatenant_view.py 2011-08-26 19:31:57 +0000 |
3 | +++ extensions/_novatenant_view.py 2011-10-07 03:38:42 +0000 |
4 | @@ -45,3 +45,7 @@ |
5 | def build_vif(self, vif_data): |
6 | """Return VIF description.""" |
7 | return dict(vif_desc=vif_data[const.VIF_DESC]) |
8 | + |
9 | + def build_result(self, result_data): |
10 | + """Return result True/False""" |
11 | + return dict(result=result_data) |
12 | |
13 | === modified file 'extensions/novatenant.py' |
14 | --- extensions/novatenant.py 2011-08-30 16:16:23 +0000 |
15 | +++ extensions/novatenant.py 2011-10-07 03:38:42 +0000 |
16 | @@ -64,7 +64,8 @@ |
17 | parent_resource = dict(member_name="tenant", |
18 | collection_name="extensions/csco/tenants") |
19 | member_actions = {'schedule_host': "PUT", |
20 | - 'associate_port': "PUT"} |
21 | + 'associate_port': "PUT", |
22 | + 'detach_port': "PUT"} |
23 | controller = NovatenantsController(QuantumManager.get_plugin()) |
24 | return [extensions.ResourceExtension('novatenants', controller, |
25 | parent=parent_resource, |
26 | @@ -154,3 +155,24 @@ |
27 | return result |
28 | except qexception.PortNotFound as exp: |
29 | return faults.Fault(faults.PortNotFound(exp)) |
30 | + |
31 | + def detach_port(self, request, tenant_id, id): |
32 | + content_type = request.best_match_content_type() |
33 | + try: |
34 | + req_params = \ |
35 | + self._parse_request_params(request, |
36 | + self._schedule_host_ops_param_list) |
37 | + except exc.HTTPError as exp: |
38 | + return faults.Fault(exp) |
39 | + |
40 | + instance_id = req_params['instance_id'] |
41 | + instance_desc = req_params['instance_desc'] |
42 | + |
43 | + try: |
44 | + vif = self._plugin. \ |
45 | + detach_port(tenant_id, instance_id, instance_desc) |
46 | + builder = novatenant_view.get_view_builder(request) |
47 | + result = builder.build_result(True) |
48 | + return result |
49 | + except qexception.PortNotFound as exp: |
50 | + return faults.Fault(faults.PortNotFound(exp)) |
51 | |
52 | === modified file 'quantum/plugins/cisco/README' |
53 | --- quantum/plugins/cisco/README 2011-09-02 07:08:26 +0000 |
54 | +++ quantum/plugins/cisco/README 2011-10-07 03:38:42 +0000 |
55 | @@ -205,7 +205,9 @@ |
56 | quantum/plugins/cisco/conf/ucs_inventory.ini file. You can configure multiple |
57 | UCSMs per deployment, multiple chassis per UCSM, and multiple blades per |
58 | chassis. Chassis ID and blade ID can be obtained from the UCSM (they will |
59 | - typically be numbers like 1, 2, 3, etc.) |
60 | + typically be numbers like 1, 2, 3, etc.). Also make sure that you put the exact |
61 | + hostname as nova sees it (the host column in the services table of the nova |
62 | + DB will give you that information). |
63 | |
64 | [ucsm-1] |
65 | ip_address = <put_ucsm_ip_address_here> |
66 | @@ -241,8 +243,8 @@ |
67 | Multi NIC support for VMs |
68 | ------------------------- |
69 | As indicated earlier, if your Nova setup has a project with more than one network, |
70 | -Nova will try to create a vritual network interface (VIF) on the VM for each of those |
71 | -networks. That implies that, |
72 | +Nova will try to create a virtual network interface (VIF) on the VM for each of those |
73 | +networks. That implies - |
74 | |
75 | (1) You should create the same number of networks in Quantum as in your Nova |
76 | project. |
77 | @@ -325,12 +327,18 @@ |
78 | Note that when using UCS and the 802.1Qbh features, the association of the |
79 | VIF-ID (also referred to as interface ID) on the VM's NIC with a port will |
80 | happen automatically when the VM is instantiated. At this point, doing a |
81 | - show_port will reveal the VIF-ID associated with the port. |
82 | + show_port will reveal the VIF-ID associated with the port. To indicate that |
83 | + this VIF-ID is still detached from the network it would eventually be on, you |
84 | + will see the suffix "(detached)" on the VIF-ID. This indicates that although |
85 | + the VIF-ID and the port have been associated, the VIF still does not have |
86 | + connectivity to the network on which the port resides. That connectivity |
87 | + will be established only after the plug/attach operation is performed (as |
88 | + described in the next step). |
89 | |
90 | # PYTHONPATH=. python quantum/plugins/cisco/client/cli.py show_port demo c4a2bea7-a528-4caf-b16e-80397cd1663a 118ac473-294d-480e-8f6d-425acbbe81ae |
91 | Logical Port ID: 118ac473-294d-480e-8f6d-425acbbe81ae |
92 | administrative State: ACTIVE |
93 | -interface: b73e3585-d074-4379-8dde-931c0fc4db0e |
94 | +interface: b73e3585-d074-4379-8dde-931c0fc4db0e(detached) |
95 | on Virtual Network: c4a2bea7-a528-4caf-b16e-80397cd1663a |
96 | for Tenant: demo |
97 | |
98 | @@ -347,17 +355,23 @@ |
99 | |
100 | |
101 | 8. Unplug an interface and port from the network |
102 | - Note: Before unplugging, make a note of the interface ID (you can use the |
103 | - show_port CLI as before). While the VM, which has a VIF with this interface |
104 | - ID still exists, you can only plug that same interface back into this port. |
105 | - So the subsequent plug interface operation on this port will have to make |
106 | - use of the same interface ID. |
107 | |
108 | # PYTHONPATH=. python quantum/plugins/cisco/client/cli.py unplug_iface demo c4a2bea7-a528-4caf-b16e-80397cd1663a 118ac473-294d-480e-8f6d-425acbbe81ae |
109 | Unplugged interface from Logical Port: 118ac473-294d-480e-8f6d-425acbbe81ae |
110 | on Virtual Network: c4a2bea7-a528-4caf-b16e-80397cd1663a |
111 | for Tenant: demo |
112 | |
113 | + Note: After unplugging, if you check the details of the port, you will |
114 | + see the VIF-IF associated with the port (but now suffixed with the state |
115 | + "detached"). At this point, it is possible to plug the VIF into the network |
116 | + again making use of the same VIF-ID. In general, once associated, the VIF-ID |
117 | + cannot be disassociated with the port until the VM is terminated. After the |
118 | + VM is terminated, the VIF-ID will be automatically disassociated from the |
119 | + port. To summarize, association and disassociation of the VIF-ID with a port |
120 | + happens automatically at the time of creating and terminating the VM. The |
121 | + connectivity of the VIF to the network is controlled by the user via the |
122 | + plug and unplug operations. |
123 | + |
124 | |
125 | How to test the installation |
126 | ---------------------------- |
127 | |
128 | === modified file 'quantum/plugins/cisco/common/cisco_configparser.py' |
129 | --- quantum/plugins/cisco/common/cisco_configparser.py 2011-08-16 23:03:32 +0000 |
130 | +++ quantum/plugins/cisco/common/cisco_configparser.py 2011-10-07 03:38:42 +0000 |
131 | @@ -19,13 +19,9 @@ |
132 | # |
133 | """ |
134 | |
135 | -import logging as LOG |
136 | from configobj import ConfigObj |
137 | from quantum.plugins.cisco.common import cisco_constants as const |
138 | |
139 | -LOG.basicConfig(level=LOG.WARN) |
140 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
141 | - |
142 | |
143 | class CiscoConfigParser(ConfigObj): |
144 | """Config Parser based on the ConfigObj module""" |
145 | |
146 | === modified file 'quantum/plugins/cisco/common/cisco_constants.py' |
147 | --- quantum/plugins/cisco/common/cisco_constants.py 2011-01-08 00:44:09 +0000 |
148 | +++ quantum/plugins/cisco/common/cisco_constants.py 2011-10-07 03:38:42 +0000 |
149 | @@ -153,3 +153,13 @@ |
150 | NETID_LIST = 'net_id_list' |
151 | |
152 | DELIMITERS = "[,;:\b\s]" |
153 | + |
154 | +UUID_LENGTH = 36 |
155 | + |
156 | +UNPLUGGED = '(detached)' |
157 | + |
158 | +ASSOCIATION_STATUS = 'association_status' |
159 | + |
160 | +ATTACHED = 'attached' |
161 | + |
162 | +DETACHED = 'detached' |
163 | |
164 | === modified file 'quantum/plugins/cisco/common/cisco_credentials.py' |
165 | --- quantum/plugins/cisco/common/cisco_credentials.py 2011-08-26 02:54:08 +0000 |
166 | +++ quantum/plugins/cisco/common/cisco_credentials.py 2011-10-07 03:38:42 +0000 |
167 | @@ -19,7 +19,6 @@ |
168 | # |
169 | """ |
170 | |
171 | -import logging as LOG |
172 | import os |
173 | |
174 | from quantum.plugins.cisco.common import cisco_configparser as confp |
175 | @@ -27,9 +26,6 @@ |
176 | from quantum.plugins.cisco.common import cisco_exceptions as cexc |
177 | from quantum.plugins.cisco.db import l2network_db as cdb |
178 | |
179 | -LOG.basicConfig(level=LOG.WARN) |
180 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
181 | - |
182 | TENANT = const.NETWORK_ADMIN |
183 | |
184 | CREDENTIALS_FILE = "../conf/credentials.ini" |
185 | |
186 | === modified file 'quantum/plugins/cisco/common/cisco_exceptions.py' |
187 | --- quantum/plugins/cisco/common/cisco_exceptions.py 2011-08-30 23:09:51 +0000 |
188 | +++ quantum/plugins/cisco/common/cisco_exceptions.py 2011-10-07 03:38:42 +0000 |
189 | @@ -176,6 +176,14 @@ |
190 | message = _("PortVnic Binding %(port_id) is not present") |
191 | |
192 | |
193 | +class InvalidAttach(exceptions.QuantumException): |
194 | + message = _("Unable to plug the attachment %(att_id)s into port " \ |
195 | + "%(port_id)s for network %(net_id)s. Association of " \ |
196 | + "attachment ID with port ID happens implicitly when " \ |
197 | + "VM is instantiated; attach operation can be " \ |
198 | + "performed subsequently.") |
199 | + |
200 | + |
201 | try: |
202 | _("test") |
203 | except NameError: |
204 | |
205 | === modified file 'quantum/plugins/cisco/common/cisco_utils.py' |
206 | --- quantum/plugins/cisco/common/cisco_utils.py 2011-08-31 19:56:01 +0000 |
207 | +++ quantum/plugins/cisco/common/cisco_utils.py 2011-10-07 03:38:42 +0000 |
208 | @@ -20,7 +20,7 @@ |
209 | """ |
210 | |
211 | import hashlib |
212 | -import logging as LOG |
213 | +import logging |
214 | import MySQLdb |
215 | import traceback |
216 | |
217 | @@ -28,8 +28,7 @@ |
218 | from quantum.plugins.cisco.db import api as db |
219 | from quantum.plugins.cisco.db import l2network_db as cdb |
220 | |
221 | -LOG.basicConfig(level=LOG.WARN) |
222 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
223 | +LOG = logging.getLogger(__name__) |
224 | |
225 | |
226 | def get16ByteUUID(uuid): |
227 | |
228 | === modified file 'quantum/plugins/cisco/db/ucs_db.py' |
229 | --- quantum/plugins/cisco/db/ucs_db.py 2011-08-25 23:29:30 +0000 |
230 | +++ quantum/plugins/cisco/db/ucs_db.py 2011-10-07 03:38:42 +0000 |
231 | @@ -117,6 +117,38 @@ |
232 | raise c_exc.PortVnicNotFound(port_id=port_id) |
233 | |
234 | |
235 | +def update_portbinding_instance_id(port_id, instance_id): |
236 | + """Updates port binding for the instance ID""" |
237 | + LOG.debug("db update_portbinding_instance_id() called") |
238 | + session = db.get_session() |
239 | + try: |
240 | + port_binding = session.query(ucs_models.PortBinding).\ |
241 | + filter_by(port_id=port_id).\ |
242 | + one() |
243 | + port_binding.instance_id = instance_id |
244 | + session.merge(port_binding) |
245 | + session.flush() |
246 | + return port_binding |
247 | + except exc.NoResultFound: |
248 | + raise c_exc.PortVnicNotFound(port_id=port_id) |
249 | + |
250 | + |
251 | +def update_portbinding_vif_id(port_id, vif_id): |
252 | + """Updates port binding for the VIF ID""" |
253 | + LOG.debug("db update_portbinding_vif_id() called") |
254 | + session = db.get_session() |
255 | + try: |
256 | + port_binding = session.query(ucs_models.PortBinding).\ |
257 | + filter_by(port_id=port_id).\ |
258 | + one() |
259 | + port_binding.vif_id = vif_id |
260 | + session.merge(port_binding) |
261 | + session.flush() |
262 | + return port_binding |
263 | + except exc.NoResultFound: |
264 | + raise c_exc.PortVnicNotFound(port_id=port_id) |
265 | + |
266 | + |
267 | def get_portbinding_dn(blade_intf_dn): |
268 | """Lists a port binding""" |
269 | LOG.debug("get_portbinding_dn() called") |
270 | |
271 | === modified file 'quantum/plugins/cisco/l2network_plugin.py' |
272 | --- quantum/plugins/cisco/l2network_plugin.py 2011-08-31 04:06:34 +0000 |
273 | +++ quantum/plugins/cisco/l2network_plugin.py 2011-10-07 03:38:42 +0000 |
274 | @@ -20,7 +20,7 @@ |
275 | """ |
276 | |
277 | import inspect |
278 | -import logging as LOG |
279 | +import logging |
280 | import re |
281 | |
282 | from quantum.common import exceptions as exc |
283 | @@ -35,8 +35,7 @@ |
284 | from quantum.plugins.cisco.db import api as db |
285 | from quantum.plugins.cisco.db import l2network_db as cdb |
286 | |
287 | -LOG.basicConfig(level=LOG.WARN) |
288 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
289 | +LOG = logging.getLogger(__name__) |
290 | |
291 | |
292 | class L2Network(QuantumPluginBase): |
293 | @@ -246,35 +245,50 @@ |
294 | def plug_interface(self, tenant_id, net_id, port_id, |
295 | remote_interface_id): |
296 | """ |
297 | - Attaches a remote interface to the specified port on the |
298 | + Provides connectivity to a remote interface to the |
299 | specified Virtual Network. |
300 | """ |
301 | LOG.debug("plug_interface() called\n") |
302 | network = db.network_get(net_id) |
303 | port = db.port_get(net_id, port_id) |
304 | attachment_id = port[const.INTERFACEID] |
305 | - if attachment_id and remote_interface_id != attachment_id: |
306 | + if attachment_id == None: |
307 | + raise cexc.InvalidAttach(port_id=port_id, net_id=net_id, |
308 | + att_id=remote_interface_id) |
309 | + attachment_id = attachment_id[:const.UUID_LENGTH] |
310 | + remote_interface_id = remote_interface_id[:const.UUID_LENGTH] |
311 | + if remote_interface_id != attachment_id: |
312 | + LOG.debug("Existing attachment_id:%s, remote_interface_id:%s" % \ |
313 | + (attachment_id, remote_interface_id)) |
314 | raise exc.PortInUse(port_id=port_id, net_id=net_id, |
315 | att_id=attachment_id) |
316 | self._invoke_device_plugins(self._func_name(), [tenant_id, |
317 | net_id, port_id, |
318 | - remote_interface_id]) |
319 | - if attachment_id == None: |
320 | - db.port_set_attachment(net_id, port_id, remote_interface_id) |
321 | + attachment_id]) |
322 | + db.port_unset_attachment(net_id, port_id) |
323 | + db.port_set_attachment(net_id, port_id, attachment_id) |
324 | #Note: The remote_interface_id gets associated with the port |
325 | # when the VM is instantiated. The plug interface call results |
326 | # in putting the port on the VLAN associated with this network |
327 | |
328 | def unplug_interface(self, tenant_id, net_id, port_id): |
329 | """ |
330 | - Detaches a remote interface from the specified port on the |
331 | + Removes connectivity of a remote interface to the |
332 | specified Virtual Network. |
333 | """ |
334 | LOG.debug("unplug_interface() called\n") |
335 | network = db.network_get(net_id) |
336 | + port = db.port_get(net_id, port_id) |
337 | + attachment_id = port[const.INTERFACEID] |
338 | + if attachment_id == None: |
339 | + raise exc.InvalidDetach(port_id=port_id, net_id=net_id, |
340 | + att_id=remote_interface_id) |
341 | self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, |
342 | port_id]) |
343 | + attachment_id = attachment_id[:const.UUID_LENGTH] |
344 | + attachment_id = attachment_id + const.UNPLUGGED |
345 | db.port_unset_attachment(net_id, port_id) |
346 | + db.port_set_attachment(net_id, port_id, attachment_id) |
347 | |
348 | """ |
349 | Extension API implementation |
350 | @@ -473,13 +487,22 @@ |
351 | |
352 | def associate_port(self, tenant_id, instance_id, instance_desc): |
353 | """ |
354 | - Get the portprofile name and the device namei for the dynamic vnic |
355 | + Get the portprofile name and the device name for the dynamic vnic |
356 | """ |
357 | LOG.debug("associate_port() called\n") |
358 | return self._invoke_device_plugins(self._func_name(), [tenant_id, |
359 | instance_id, |
360 | instance_desc]) |
361 | |
362 | + def detach_port(self, tenant_id, instance_id, instance_desc): |
363 | + """ |
364 | + Remove the association of the VIF with the dynamic vnic |
365 | + """ |
366 | + LOG.debug("detach_port() called\n") |
367 | + return self._invoke_device_plugins(self._func_name(), [tenant_id, |
368 | + instance_id, |
369 | + instance_desc]) |
370 | + |
371 | def create_multiport(self, tenant_id, net_id_list, port_state, ports_desc): |
372 | """ |
373 | Creates multiple ports on the specified Virtual Network. |
374 | |
375 | === modified file 'quantum/plugins/cisco/models/l2network_multi_blade.py' |
376 | --- quantum/plugins/cisco/models/l2network_multi_blade.py 2011-01-08 00:44:09 +0000 |
377 | +++ quantum/plugins/cisco/models/l2network_multi_blade.py 2011-10-07 03:38:42 +0000 |
378 | @@ -21,7 +21,7 @@ |
379 | |
380 | from copy import deepcopy |
381 | import inspect |
382 | -import logging as LOG |
383 | +import logging |
384 | import platform |
385 | |
386 | from quantum.common import exceptions as exc |
387 | @@ -31,8 +31,7 @@ |
388 | from quantum.plugins.cisco.common import cisco_constants as const |
389 | from quantum.plugins.cisco.common import cisco_exceptions as cexc |
390 | |
391 | -LOG.basicConfig(level=LOG.WARN) |
392 | -LOG.getLogger(__name__) |
393 | +LOG = logging.getLogger(__name__) |
394 | |
395 | |
396 | class L2NetworkMultiBlade(L2NetworkModelBase): |
397 | @@ -182,12 +181,20 @@ |
398 | |
399 | def associate_port(self, args): |
400 | """ |
401 | - Get the portprofile name and the device namei for the dynamic vnic |
402 | + Get the portprofile name and the device name for the dynamic vnic |
403 | """ |
404 | LOG.debug("associate_port() called\n") |
405 | return self._invoke_inventory(const.UCS_PLUGIN, self._func_name(), |
406 | args) |
407 | |
408 | + def detach_port(self, args): |
409 | + """ |
410 | + Remove the association of the VIF with the dynamic vnic |
411 | + """ |
412 | + LOG.debug("detach_port() called\n") |
413 | + return self._invoke_plugin_per_device(const.UCS_PLUGIN, |
414 | + self._func_name(), args) |
415 | + |
416 | def create_multiport(self, args): |
417 | """Support for extension API call""" |
418 | self._invoke_plugin_per_device(const.UCS_PLUGIN, self._func_name(), |
419 | |
420 | === modified file 'quantum/plugins/cisco/models/l2network_single_blade.py' |
421 | --- quantum/plugins/cisco/models/l2network_single_blade.py 2011-08-30 23:12:49 +0000 |
422 | +++ quantum/plugins/cisco/models/l2network_single_blade.py 2011-10-07 03:38:42 +0000 |
423 | @@ -21,7 +21,7 @@ |
424 | |
425 | from copy import deepcopy |
426 | import inspect |
427 | -import logging as LOG |
428 | +import logging |
429 | import platform |
430 | |
431 | from quantum.common import exceptions as exc |
432 | @@ -31,8 +31,7 @@ |
433 | from quantum.plugins.cisco.common import cisco_constants as const |
434 | from quantum.plugins.cisco.common import cisco_exceptions as cexc |
435 | |
436 | -LOG.basicConfig(level=LOG.WARN) |
437 | -LOG.getLogger(__name__) |
438 | +LOG = logging.getLogger(__name__) |
439 | |
440 | |
441 | class L2NetworkSingleBlade(L2NetworkModelBase): |
442 | @@ -163,6 +162,13 @@ |
443 | return self._invoke_inventory(const.UCS_PLUGIN, self._func_name(), |
444 | args) |
445 | |
446 | + def detach_port(self, args): |
447 | + """ |
448 | + Remove the association of the VIF with the dynamic vnic |
449 | + """ |
450 | + LOG.debug("detach_port() called\n") |
451 | + return self._invoke_plugin_per_device(const.UCS_PLUGIN,self._func_name(), args) |
452 | + |
453 | def create_multiport(self, args): |
454 | """Support for extension API call""" |
455 | self._invoke_plugin_per_device(const.UCS_PLUGIN, self._func_name(), |
456 | |
457 | === modified file 'quantum/plugins/cisco/nova/vifdirect.py' |
458 | --- quantum/plugins/cisco/nova/vifdirect.py 2011-08-28 05:55:08 +0000 |
459 | +++ quantum/plugins/cisco/nova/vifdirect.py 2011-10-07 03:38:42 +0000 |
460 | @@ -45,7 +45,8 @@ |
461 | '/extensions/csco/tenants/{tenant_id}' |
462 | TENANT_ID = 'nova' |
463 | CSCO_EXT_NAME = 'Cisco Nova Tenant' |
464 | -ACTION = '/associate_port' |
465 | +ASSOCIATE_ACTION = '/associate_port' |
466 | +DETACH_ACTION = '/detach_port' |
467 | |
468 | |
469 | class Libvirt802dot1QbhDriver(VIFDriver): |
470 | @@ -70,7 +71,7 @@ |
471 | % CSCO_EXT_NAME) |
472 | raise excp.ServiceUnavailable() |
473 | |
474 | - def _get_configurations(self, instance, network, mapping): |
475 | + def _update_configurations(self, instance, network, mapping, action): |
476 | """Gets the device name and the profile name from Quantum""" |
477 | |
478 | instance_id = instance['id'] |
479 | @@ -88,26 +89,31 @@ |
480 | |
481 | client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, |
482 | action_prefix=ACTION_PREFIX_CSCO) |
483 | - request_url = "/novatenants/" + project_id + ACTION |
484 | + request_url = "/novatenants/" + project_id + action |
485 | data = client.do_request('PUT', request_url, body=instance_data_dict) |
486 | |
487 | - device = data['vif_desc']['device'] |
488 | - portprofile = data['vif_desc']['portprofile'] |
489 | - LOG.debug(_("Quantum provided the device: %s") % device) |
490 | - LOG.debug(_("Quantum provided the portprofile: %s") % portprofile) |
491 | - mac_id = mapping['mac'].replace(':', '') |
492 | - |
493 | - result = { |
494 | - 'id': mac_id, |
495 | - 'mac_address': mapping['mac'], |
496 | - 'device_name': device, |
497 | - 'profile_name': portprofile, |
498 | - } |
499 | - |
500 | - return result |
501 | + if action == ASSOCIATE_ACTION: |
502 | + device = data['vif_desc']['device'] |
503 | + portprofile = data['vif_desc']['portprofile'] |
504 | + LOG.debug(_("Quantum provided the device: %s") % device) |
505 | + LOG.debug(_("Quantum provided the portprofile: %s") % portprofile) |
506 | + mac_id = mapping['mac'].replace(':', '') |
507 | + |
508 | + result = { |
509 | + 'id': mac_id, |
510 | + 'mac_address': mapping['mac'], |
511 | + 'device_name': device, |
512 | + 'profile_name': portprofile, |
513 | + } |
514 | + |
515 | + return result |
516 | + else: |
517 | + return data |
518 | |
519 | def plug(self, instance, network, mapping): |
520 | - return self._get_configurations(instance, network, mapping) |
521 | + return self._update_configurations(instance, network, mapping, |
522 | + ASSOCIATE_ACTION) |
523 | |
524 | def unplug(self, instance, network, mapping): |
525 | - pass |
526 | + self._update_configurations(instance, network, mapping, |
527 | + DETACH_ACTION) |
528 | |
529 | === modified file 'quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py' |
530 | --- quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py 2011-08-20 09:51:59 +0000 |
531 | +++ quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py 2011-10-07 03:38:42 +0000 |
532 | @@ -19,15 +19,14 @@ |
533 | # |
534 | """ |
535 | |
536 | -import logging as LOG |
537 | +import logging |
538 | |
539 | from quantum.plugins.cisco.common import cisco_constants as const |
540 | from quantum.plugins.cisco.db import l2network_db as cdb |
541 | from quantum.plugins.cisco.l2network_segmentation_base \ |
542 | import L2NetworkSegmentationMgrBase |
543 | |
544 | -LOG.basicConfig(level=LOG.WARN) |
545 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
546 | +LOG = logging.getLogger(__name__) |
547 | |
548 | |
549 | class L2NetworkVLANMgr(L2NetworkSegmentationMgrBase): |
550 | |
551 | === modified file 'quantum/plugins/cisco/ucs/cisco_ucs_inventory.py' |
552 | --- quantum/plugins/cisco/ucs/cisco_ucs_inventory.py 2011-08-30 23:12:49 +0000 |
553 | +++ quantum/plugins/cisco/ucs/cisco_ucs_inventory.py 2011-10-07 03:38:42 +0000 |
554 | @@ -19,7 +19,7 @@ |
555 | # |
556 | """ |
557 | from copy import deepcopy |
558 | -import logging as LOG |
559 | +import logging |
560 | |
561 | from quantum.common import exceptions as exc |
562 | from quantum.plugins.cisco.l2device_inventory_base \ |
563 | @@ -34,8 +34,7 @@ |
564 | import cisco_ucs_inventory_configuration as conf |
565 | from quantum.plugins.cisco.ucs import cisco_ucs_network_driver |
566 | |
567 | -LOG.basicConfig(level=LOG.WARN) |
568 | -LOG.getLogger(__name__) |
569 | +LOG = logging.getLogger(__name__) |
570 | |
571 | """ |
572 | The _inventory data strcuture contains a nested disctioary: |
573 | @@ -337,7 +336,8 @@ |
574 | port_id = port_binding[const.PORTID] |
575 | udb.update_portbinding(port_id, instance_id=instance_id, |
576 | vif_id=vif_id) |
577 | - db.port_set_attachment_by_id(port_id, vif_id) |
578 | + db.port_set_attachment_by_id(port_id, vif_id + |
579 | + const.UNPLUGGED) |
580 | device_name = blade_intf_data[blade_intf]\ |
581 | [const.BLADE_INTF_RHEL_DEVICE_NAME] |
582 | profile_name = port_binding[const.PORTPROFILENAME] |
583 | @@ -355,9 +355,10 @@ |
584 | tenant_id) |
585 | return None |
586 | |
587 | - def _disassociate_vifid_from_port(self, tenant_id, port_id): |
588 | + def _disassociate_vifid_from_port(self, tenant_id, instance_id, vif_id): |
589 | """ |
590 | - Return the device name for a reserved interface |
591 | + Disassociate a VIF-ID from a port, this happens when a |
592 | + VM is destroyed |
593 | """ |
594 | for ucsm_ip in self._inventory_state.keys(): |
595 | ucsm = self._inventory_state[ucsm_ip] |
596 | @@ -371,21 +372,27 @@ |
597 | const.BLADE_INTF_RESERVED and \ |
598 | blade_intf_data[blade_intf]\ |
599 | [const.TENANTID] == tenant_id and \ |
600 | - blade_intf_data[blade_intf][const.PORTID] == \ |
601 | - port_id: |
602 | - vif_id = blade_intf_data[blade_intf][const.VIF_ID] |
603 | + blade_intf_data[blade_intf][const.INSTANCE_ID] == \ |
604 | + instance_id and \ |
605 | + blade_intf_data[blade_intf][const.VIF_ID]\ |
606 | + [:const.UUID_LENGTH] == vif_id: |
607 | blade_intf_data[blade_intf][const.VIF_ID] = \ |
608 | None |
609 | blade_intf_data[blade_intf][const.INSTANCE_ID] = \ |
610 | None |
611 | + port_binding = udb.get_portbinding_dn(blade_intf) |
612 | + port_id = port_binding[const.PORTID] |
613 | udb.update_portbinding(port_id, instance_id=None, |
614 | vif_id=None) |
615 | + db.port_unset_attachment_by_id(port_id) |
616 | LOG.debug("Disassociated VIF-ID: %s " \ |
617 | "from port: %s" \ |
618 | "in UCS inventory state for blade: %s" % |
619 | (vif_id, port_id, |
620 | blade_intf_data[blade_intf])) |
621 | - return |
622 | + device_params = {const.DEVICE_IP: [ucsm_ip], |
623 | + const.PORTID: port_id} |
624 | + return device_params |
625 | LOG.warn("Disassociating VIF-ID in UCS inventory failed. " \ |
626 | "Could not find a reserved dynamic nic for tenant: %s" % |
627 | tenant_id) |
628 | @@ -664,9 +671,6 @@ |
629 | on which a dynamic vnic was reserved for this port |
630 | """ |
631 | LOG.debug("unplug_interface() called\n") |
632 | - tenant_id = args[0] |
633 | - port_id = args[2] |
634 | - self._disassociate_vifid_from_port(tenant_id, port_id) |
635 | return self._get_blade_for_port(args) |
636 | |
637 | def schedule_host(self, args): |
638 | @@ -689,9 +693,24 @@ |
639 | vif_id = args[2][const.VIF_ID] |
640 | vif_info = self._get_instance_port(tenant_id, instance_id, vif_id) |
641 | vif_desc = {const.VIF_DESC: vif_info} |
642 | + |
643 | LOG.debug("vif_desc is: %s" % vif_desc) |
644 | return vif_desc |
645 | |
646 | + def detach_port(self, args): |
647 | + """ |
648 | + Remove the VIF-ID and instance name association |
649 | + with the port |
650 | + """ |
651 | + LOG.debug("detach_port() called\n") |
652 | + instance_id = args[1] |
653 | + tenant_id = args[2][const.PROJECT_ID] |
654 | + vif_id = args[2][const.VIF_ID] |
655 | + device_params = self._disassociate_vifid_from_port(tenant_id, |
656 | + instance_id, |
657 | + vif_id) |
658 | + return device_params |
659 | + |
660 | def create_multiport(self, args): |
661 | """ |
662 | Create multiple ports for a VM |
663 | |
664 | === modified file 'quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py' |
665 | --- quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py 2011-09-01 23:48:17 +0000 |
666 | +++ quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py 2011-10-07 03:38:42 +0000 |
667 | @@ -24,16 +24,14 @@ |
668 | """ |
669 | |
670 | import httplib |
671 | -import logging as LOG |
672 | +import logging |
673 | from xml.etree import ElementTree as et |
674 | |
675 | from quantum.plugins.cisco.common import cisco_exceptions as cexc |
676 | from quantum.plugins.cisco.common import cisco_constants as const |
677 | from quantum.plugins.cisco.ucs import cisco_getvif as gvif |
678 | |
679 | - |
680 | -LOG.basicConfig(level=LOG.WARN) |
681 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
682 | +LOG = logging.getLogger(__name__) |
683 | |
684 | COOKIE_VALUE = "cookie_placeholder" |
685 | PROFILE_NAME = "profilename_placeholder" |
686 | |
687 | === modified file 'quantum/plugins/cisco/ucs/cisco_ucs_plugin.py' |
688 | --- quantum/plugins/cisco/ucs/cisco_ucs_plugin.py 2011-09-08 06:29:55 +0000 |
689 | +++ quantum/plugins/cisco/ucs/cisco_ucs_plugin.py 2011-10-07 03:38:42 +0000 |
690 | @@ -19,7 +19,7 @@ |
691 | # |
692 | """ |
693 | |
694 | -import logging as LOG |
695 | +import logging |
696 | |
697 | from quantum.common import exceptions as exc |
698 | from quantum.common import utils |
699 | @@ -33,8 +33,7 @@ |
700 | from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase |
701 | from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf |
702 | |
703 | -LOG.basicConfig(level=LOG.WARN) |
704 | -LOG.getLogger(const.LOGGER_COMPONENT_NAME) |
705 | +LOG = logging.getLogger(__name__) |
706 | |
707 | |
708 | class UCSVICPlugin(L2DevicePluginBase): |
709 | @@ -255,6 +254,49 @@ |
710 | return udb.update_portbinding(port_id, vlan_name=new_vlan_name, |
711 | vlan_id=conf.DEFAULT_VLAN_ID) |
712 | |
713 | + def create_multiport(self, tenant_id, net_id_list, ports_num, port_id_list, |
714 | + **kwargs): |
715 | + """ |
716 | + Creates a port on the specified Virtual Network. |
717 | + """ |
718 | + LOG.debug("UCSVICPlugin:create_multiport() called\n") |
719 | + self._set_ucsm(kwargs[const.DEVICE_IP]) |
720 | + qos = None |
721 | + ucs_inventory = kwargs[const.UCS_INVENTORY] |
722 | + least_rsvd_blade_dict = kwargs[const.LEAST_RSVD_BLADE_DICT] |
723 | + chassis_id = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_CHASSIS] |
724 | + blade_id = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_ID] |
725 | + blade_data_dict = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_DATA] |
726 | + port_binding_list = [] |
727 | + for port_id, net_id in zip(port_id_list, net_id_list): |
728 | + new_port_profile = \ |
729 | + self._create_port_profile(tenant_id, net_id, port_id, |
730 | + conf.DEFAULT_VLAN_NAME, |
731 | + conf.DEFAULT_VLAN_ID) |
732 | + profile_name = new_port_profile[const.PROFILE_NAME] |
733 | + rsvd_nic_dict = ucs_inventory.\ |
734 | + reserve_blade_interface(self._ucsm_ip, chassis_id, |
735 | + blade_id, blade_data_dict, |
736 | + tenant_id, port_id, |
737 | + profile_name) |
738 | + port_binding = udb.update_portbinding(port_id, |
739 | + portprofile_name=profile_name, |
740 | + vlan_name=conf.DEFAULT_VLAN_NAME, |
741 | + vlan_id=conf.DEFAULT_VLAN_ID, |
742 | + qos=qos) |
743 | + port_binding_list.append(port_binding) |
744 | + return port_binding_list |
745 | + |
746 | + |
747 | + def detach_port(self, tenant_id, instance_id, instance_desc, **kwargs): |
748 | + """ |
749 | + Remove the association of the VIF with the dynamic vnic |
750 | + """ |
751 | + LOG.debug("detach_port() called\n") |
752 | + port_id = kwargs[const.PORTID] |
753 | + kwargs.pop(const.PORTID) |
754 | + return self.unplug_interface(tenant_id, None, port_id, **kwargs) |
755 | + |
756 | def _get_profile_name(self, port_id): |
757 | """Returns the port profile name based on the port UUID""" |
758 | profile_name = conf.PROFILE_NAME_PREFIX \ |
759 | @@ -296,36 +338,3 @@ |
760 | self._ucsm_ip = ucsm_ip |
761 | self._ucsm_username = cred.Store.getUsername(conf.UCSM_IP_ADDRESS) |
762 | self._ucsm_password = cred.Store.getPassword(conf.UCSM_IP_ADDRESS) |
763 | - |
764 | - def create_multiport(self, tenant_id, net_id_list, ports_num, port_id_list, |
765 | - **kwargs): |
766 | - """ |
767 | - Creates a port on the specified Virtual Network. |
768 | - """ |
769 | - LOG.debug("UCSVICPlugin:create_multiport() called\n") |
770 | - self._set_ucsm(kwargs[const.DEVICE_IP]) |
771 | - qos = None |
772 | - ucs_inventory = kwargs[const.UCS_INVENTORY] |
773 | - least_rsvd_blade_dict = kwargs[const.LEAST_RSVD_BLADE_DICT] |
774 | - chassis_id = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_CHASSIS] |
775 | - blade_id = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_ID] |
776 | - blade_data_dict = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_DATA] |
777 | - port_binding_list = [] |
778 | - for port_id, net_id in zip(port_id_list, net_id_list): |
779 | - new_port_profile = \ |
780 | - self._create_port_profile(tenant_id, net_id, port_id, |
781 | - conf.DEFAULT_VLAN_NAME, |
782 | - conf.DEFAULT_VLAN_ID) |
783 | - profile_name = new_port_profile[const.PROFILE_NAME] |
784 | - rsvd_nic_dict = ucs_inventory.\ |
785 | - reserve_blade_interface(self._ucsm_ip, chassis_id, |
786 | - blade_id, blade_data_dict, |
787 | - tenant_id, port_id, |
788 | - profile_name) |
789 | - port_binding = udb.update_portbinding(port_id, |
790 | - portprofile_name=profile_name, |
791 | - vlan_name=conf.DEFAULT_VLAN_NAME, |
792 | - vlan_id=conf.DEFAULT_VLAN_ID, |
793 | - qos=qos) |
794 | - port_binding_list.append(port_binding) |
795 | - return port_binding_list |
All code changes look good as well as the README section.