Delete IP allocation range for subnet when deleting subnet
Fixes bug 1020563 Change-Id: I034e490825603ab71662a0bbad9b325f419a9e43
This commit is contained in:
@@ -591,9 +591,12 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
subnet = self._get_subnet(context, id)
|
subnet = self._get_subnet(context, id)
|
||||||
# Check if ports are using this subnet
|
# Check if ports are using this subnet
|
||||||
allocated_qry = context.session.query(models_v2.IPAllocation)
|
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:
|
if allocated:
|
||||||
raise q_exc.SubnetInUse(subnet_id=id)
|
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)
|
context.session.delete(subnet)
|
||||||
|
|
||||||
def get_subnet(self, context, id, fields=None, verbose=None):
|
def get_subnet(self, context, id, fields=None, verbose=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user