]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Neutron network delete fails with brocade plugin
authorShiv Haris <sharis@brocade.com>
Thu, 12 Sep 2013 19:37:22 +0000 (12:37 -0700)
committerShiv Haris <sharis@brocade.com>
Tue, 24 Sep 2013 01:32:00 +0000 (01:32 +0000)
Fixes bug: 1223747

Change-Id: I4a8235d4dcb0c14477835afafd0b5459ce6b01f6

neutron/plugins/brocade/NeutronPlugin.py
neutron/tests/unit/brocade/test_brocade_db.py

index 37939f540219822e716001b895ad81039fdc170d..b49a6bafe17254496f448b9488f090d335022666 100644 (file)
@@ -295,10 +295,9 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                                             switch['username'],
                                             switch['password'],
                                             vlan_id)
-            except Exception as e:
+            except Exception:
                 # Proper formatting
-                LOG.warning(_("Brocade NOS driver:"))
-                LOG.warning(_("%s"), e)
+                LOG.exception(_("Brocade NOS driver error"))
                 LOG.debug(_("Returning the allocated vlan (%d) to the pool"),
                           vlan_id)
                 self._vlan_bitmap.release_vlan(int(vlan_id))
@@ -338,11 +337,10 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                 self._driver.delete_network(switch['address'],
                                             switch['username'],
                                             switch['password'],
-                                            net_id)
-            except Exception as e:
+                                            vlan_id)
+            except Exception:
                 # Proper formatting
-                LOG.warning(_("Brocade NOS driver:"))
-                LOG.warning(_("%s"), e)
+                LOG.exception(_("Brocade NOS driver error"))
                 raise Exception(_("Brocade plugin raised exception, "
                                   "check logs"))
 
@@ -393,10 +391,9 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                                                       switch['password'],
                                                       vlan_id,
                                                       mac)
-            except Exception as e:
+            except Exception:
                 # Proper formatting
-                LOG.warning(_("Brocade NOS driver:"))
-                LOG.warning(_("%s"), e)
+                LOG.exception(_("Brocade NOS driver error"))
                 raise Exception(_("Brocade plugin raised exception, "
                                   "check logs"))
 
@@ -410,6 +407,26 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
 
     def delete_port(self, context, port_id):
         with context.session.begin(subtransactions=True):
+            neutron_port = self.get_port(context, port_id)
+            interface_mac = neutron_port['mac_address']
+            # convert mac format: xx:xx:xx:xx:xx:xx -> xxxx.xxxx.xxxx
+            mac = self.mac_reformat_62to34(interface_mac)
+
+            brocade_port = brocade_db.get_port(context, port_id)
+            vlan_id = brocade_port['vlan_id']
+
+            switch = self._switch
+            try:
+                self._driver.dissociate_mac_from_network(switch['address'],
+                                                         switch['username'],
+                                                         switch['password'],
+                                                         vlan_id,
+                                                         mac)
+            except Exception:
+                LOG.exception(_("Brocade NOS driver error"))
+                raise Exception(
+                    _("Brocade plugin raised exception, check logs"))
+
             super(BrocadePluginV2, self).delete_port(context, port_id)
             brocade_db.delete_port(context, port_id)
 
index 68702529e585488c3cd4272b87e2d2b6ebd80059..127b516be130d2f8baef9accf5840c6ae5b6e2e5 100644 (file)
@@ -47,6 +47,7 @@ class TestBrocadeDb(test_plugin.NeutronDbPluginV2TestCase):
 
         # Delete the network
         brocade_db.delete_network(self.context, net['id'])
+        self.assertFalse(brocade_db.get_networks(self.context))
 
     def test_create_port(self):
         """Test brocade specific port db."""
@@ -96,3 +97,4 @@ class TestBrocadeDb(test_plugin.NeutronDbPluginV2TestCase):
 
         # Delete Port
         brocade_db.delete_port(self.context, port_id)
+        self.assertFalse(brocade_db.get_ports(self.context))