Merge "Neutron network delete fails with brocade plugin"
This commit is contained in:
commit
6728b4e438
@ -295,10 +295,9 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
switch['username'],
|
switch['username'],
|
||||||
switch['password'],
|
switch['password'],
|
||||||
vlan_id)
|
vlan_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# Proper formatting
|
# Proper formatting
|
||||||
LOG.warning(_("Brocade NOS driver:"))
|
LOG.exception(_("Brocade NOS driver error"))
|
||||||
LOG.warning(_("%s"), e)
|
|
||||||
LOG.debug(_("Returning the allocated vlan (%d) to the pool"),
|
LOG.debug(_("Returning the allocated vlan (%d) to the pool"),
|
||||||
vlan_id)
|
vlan_id)
|
||||||
self._vlan_bitmap.release_vlan(int(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'],
|
self._driver.delete_network(switch['address'],
|
||||||
switch['username'],
|
switch['username'],
|
||||||
switch['password'],
|
switch['password'],
|
||||||
net_id)
|
vlan_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# Proper formatting
|
# Proper formatting
|
||||||
LOG.warning(_("Brocade NOS driver:"))
|
LOG.exception(_("Brocade NOS driver error"))
|
||||||
LOG.warning(_("%s"), e)
|
|
||||||
raise Exception(_("Brocade plugin raised exception, "
|
raise Exception(_("Brocade plugin raised exception, "
|
||||||
"check logs"))
|
"check logs"))
|
||||||
|
|
||||||
@ -393,10 +391,9 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
switch['password'],
|
switch['password'],
|
||||||
vlan_id,
|
vlan_id,
|
||||||
mac)
|
mac)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# Proper formatting
|
# Proper formatting
|
||||||
LOG.warning(_("Brocade NOS driver:"))
|
LOG.exception(_("Brocade NOS driver error"))
|
||||||
LOG.warning(_("%s"), e)
|
|
||||||
raise Exception(_("Brocade plugin raised exception, "
|
raise Exception(_("Brocade plugin raised exception, "
|
||||||
"check logs"))
|
"check logs"))
|
||||||
|
|
||||||
@ -410,6 +407,26 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
|
|
||||||
def delete_port(self, context, port_id):
|
def delete_port(self, context, port_id):
|
||||||
with context.session.begin(subtransactions=True):
|
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)
|
super(BrocadePluginV2, self).delete_port(context, port_id)
|
||||||
brocade_db.delete_port(context, port_id)
|
brocade_db.delete_port(context, port_id)
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class TestBrocadeDb(test_plugin.NeutronDbPluginV2TestCase):
|
|||||||
|
|
||||||
# Delete the network
|
# Delete the network
|
||||||
brocade_db.delete_network(self.context, net['id'])
|
brocade_db.delete_network(self.context, net['id'])
|
||||||
|
self.assertFalse(brocade_db.get_networks(self.context))
|
||||||
|
|
||||||
def test_create_port(self):
|
def test_create_port(self):
|
||||||
"""Test brocade specific port db."""
|
"""Test brocade specific port db."""
|
||||||
@ -96,3 +97,4 @@ class TestBrocadeDb(test_plugin.NeutronDbPluginV2TestCase):
|
|||||||
|
|
||||||
# Delete Port
|
# Delete Port
|
||||||
brocade_db.delete_port(self.context, port_id)
|
brocade_db.delete_port(self.context, port_id)
|
||||||
|
self.assertFalse(brocade_db.get_ports(self.context))
|
||||||
|
Loading…
Reference in New Issue
Block a user