Delete IP allocation range for subnet when deleting subnet

Fixes bug 1020563

Change-Id: I034e490825603ab71662a0bbad9b325f419a9e43
This commit is contained in:
Gary Kotton 2012-07-03 13:11:31 -04:00
parent e39fbbcedb
commit 06900100ad
1 changed files with 4 additions and 1 deletions

View File

@ -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):