]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Only delete VLAN information after Quantum network is deleted
authorGary Kotton <gkotton@redhat.com>
Sat, 28 Jul 2012 18:08:47 +0000 (14:08 -0400)
committerGary Kotton <gkotton@redhat.com>
Sat, 28 Jul 2012 18:08:47 +0000 (14:08 -0400)
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

quantum/plugins/linuxbridge/db/l2network_models_v2.py
quantum/plugins/linuxbridge/lb_quantum_plugin.py
quantum/plugins/openvswitch/ovs_quantum_plugin.py
quantum/plugins/ryu/ryu_quantum_plugin.py

index 577f2267228683a5e04c09c35bdd1f5e3d82eaac..925be3157c76b29f828da89d90a75fccfbd2f9f8 100644 (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)
 
index 573c7368e18c86997d108e588b61aee896ae9dc6..9d5ea28b20e3f9a688da984e4f68d1d9ee4e34bf 100644 (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,
index d04daf84ae9c357f1cbbac84ff670d2b39e07375..97f71944d14f5233da7e7bd2e09fa5010dc8566a 100644 (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,
index f88a78601c28715b6912dab0bed9aa9949755297..8a5dfdfbf13faf2010be38632c004d4d6888dada 100644 (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