From: Shiv Haris Date: Thu, 12 Sep 2013 19:37:22 +0000 (-0700) Subject: Neutron network delete fails with brocade plugin X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f3076fea667c3eef4746440b4b80e9d0603ef3a6;p=openstack-build%2Fneutron-build.git Neutron network delete fails with brocade plugin Fixes bug: 1223747 Change-Id: I4a8235d4dcb0c14477835afafd0b5459ce6b01f6 --- diff --git a/neutron/plugins/brocade/NeutronPlugin.py b/neutron/plugins/brocade/NeutronPlugin.py index 37939f540..b49a6bafe 100644 --- a/neutron/plugins/brocade/NeutronPlugin.py +++ b/neutron/plugins/brocade/NeutronPlugin.py @@ -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) diff --git a/neutron/tests/unit/brocade/test_brocade_db.py b/neutron/tests/unit/brocade/test_brocade_db.py index 68702529e..127b516be 100644 --- a/neutron/tests/unit/brocade/test_brocade_db.py +++ b/neutron/tests/unit/brocade/test_brocade_db.py @@ -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))