Neutron network delete fails with brocade plugin

Fixes bug: 1223747

Change-Id: I4a8235d4dcb0c14477835afafd0b5459ce6b01f6
This commit is contained in:
Shiv Haris 2013-09-12 12:37:22 -07:00
parent 2776e4d91e
commit 2bdfa6383f
2 changed files with 29 additions and 10 deletions

View 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)

View 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))