From: Gary Kotton Date: Tue, 3 Jul 2012 17:11:31 +0000 (-0400) Subject: Delete IP allocation range for subnet when deleting subnet X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=06900100ad6ddf81c7e5d48a17db079969dd80ce;p=openstack-build%2Fneutron-build.git Delete IP allocation range for subnet when deleting subnet Fixes bug 1020563 Change-Id: I034e490825603ab71662a0bbad9b325f419a9e43 --- diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index ab4da9090..b91334fb0 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -591,9 +591,12 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2): subnet = self._get_subnet(context, id) # Check if ports are using this subnet allocated_qry = context.session.query(models_v2.IPAllocation) - allocated = allocated_qry.filter_by(port_id=id).all() + allocated = allocated_qry.filter_by(subnet_id=id).all() if allocated: raise q_exc.SubnetInUse(subnet_id=id) + # Delete IP Allocations on subnet + range_qry = context.session.query(models_v2.IPAllocationRange) + range_qry.filter_by(subnet_id=id).delete() context.session.delete(subnet) def get_subnet(self, context, id, fields=None, verbose=None):