diff --git a/quantum/plugins/linuxbridge/db/l2network_models_v2.py b/quantum/plugins/linuxbridge/db/l2network_models_v2.py index 577f226722..925be3157c 100644 --- a/quantum/plugins/linuxbridge/db/l2network_models_v2.py +++ b/quantum/plugins/linuxbridge/db/l2network_models_v2.py @@ -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) diff --git a/quantum/plugins/linuxbridge/lb_quantum_plugin.py b/quantum/plugins/linuxbridge/lb_quantum_plugin.py index 573c7368e1..9d5ea28b20 100644 --- a/quantum/plugins/linuxbridge/lb_quantum_plugin.py +++ b/quantum/plugins/linuxbridge/lb_quantum_plugin.py @@ -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, diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index d04daf84ae..97f71944d1 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -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, diff --git a/quantum/plugins/ryu/ryu_quantum_plugin.py b/quantum/plugins/ryu/ryu_quantum_plugin.py index f88a78601c..8a5dfdfbf1 100644 --- a/quantum/plugins/ryu/ryu_quantum_plugin.py +++ b/quantum/plugins/ryu/ryu_quantum_plugin.py @@ -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