Delete all allocatable_ips on ip_block delete

* Calls the delete method on the ip generator to clear the block of any
  allocatable_ips so the FK doesn't fail the constraint on block delete
* Fixes LP963396

Change-Id: Iaa1915e79adde23970ad7405477e8d82467a8a58
This commit is contained in:
Jason Kölker 2012-03-23 14:44:53 -05:00
parent 72ebf18512
commit 91d1ec0753
2 changed files with 4 additions and 0 deletions

View File

@ -287,6 +287,7 @@ class IpBlock(ModelBase):
for block in self.subnets():
block.delete()
IpAddress.find_all(ip_block_id=self.id).delete()
ipv4.plugin().get_generator(self).delete()
super(IpBlock, self).delete()
def policy(self):

View File

@ -49,3 +49,6 @@ class DbBasedIpGenerator(object):
def ip_removed(self, address):
models.AllocatableIp.create(ip_block_id=self.ip_block.id,
address=address)
def delete(self):
models.AllocatableIp.find_all(ip_block_id=self.ip_block.id).delete()