Only delete VLAN information after Quantum network is deleted

Fixes bug 1030271

In the case where a network is deleted and there is a VLAN tag in a
separate table then the tag should only be deleted if the network
is deleted.

Change-Id: I99130f863928abf30a521e9a2b6d1233a274d9c6
This commit is contained in:
Gary Kotton 2012-07-28 14:08:47 -04:00
parent 787f763a33
commit bc3d89c5ab
4 changed files with 8 additions and 5 deletions

View File

@ -38,7 +38,8 @@ class VlanBinding(model_base.BASEV2):
"""Represents a binding of vlan_id to network_id"""
__tablename__ = 'vlan_bindings'
network_id = sa.Column(sa.String(36), sa.ForeignKey('networks.id'),
network_id = sa.Column(sa.String(36), sa.ForeignKey('networks.id',
ondelete="CASCADE"),
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False)

View File

@ -88,10 +88,10 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
return net
def delete_network(self, context, id):
result = super(LinuxBridgePluginV2, self).delete_network(context, id)
vlan_binding = cdb.get_vlan_binding(id)
cdb.release_vlanid(vlan_binding['vlan_id'])
cdb.remove_vlan_binding(id)
return super(LinuxBridgePluginV2, self).delete_network(context, id)
return result
def get_network(self, context, id, fields=None, verbose=None):
net = super(LinuxBridgePluginV2, self).get_network(context, id,

View File

@ -320,9 +320,10 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
return net
def delete_network(self, context, id):
result = super(OVSQuantumPluginV2, self).delete_network(context, id)
ovs_db_v2.remove_vlan_binding(id)
self.vmap.release(id)
return super(OVSQuantumPluginV2, self).delete_network(context, id)
return result
def get_network(self, context, id, fields=None, verbose=None):
net = super(OVSQuantumPluginV2, self).get_network(context, id,

View File

@ -108,5 +108,6 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
return net
def delete_network(self, context, id):
result = super(RyuQuantumPluginV2, self).delete_network(context, id)
self.client.delete_network(id)
return super(RyuQuantumPluginV2, self).delete_network(context, id)
return result