Comment 2 for bug 1091946

Revision history for this message
Itsuro Oda (oda-g) wrote :

This patch seems fixing this problem. But please ask to an sclalchemy specialist.
Thanks.
--- a/quantum/db/models_v2.py
+++ b/quantum/db/models_v2.py
@@ -65,7 +65,7 @@ class IPAllocationPool(model_base.BASEV2, HasId):
     last_ip = sa.Column(sa.String(64), nullable=False)
     available_ranges = orm.relationship(IPAvailabilityRange,
                                         backref='ipallocationpool',
- lazy="dynamic")
+ lazy="dynamic", cascade='delete')

     def __repr__(self):
         return "%s - %s" % (self.first_ip, self.last_ip)
@@ -132,7 +132,7 @@ class Subnet(model_base.BASEV2, HasId, HasTenant):
     gateway_ip = sa.Column(sa.String(64))
     allocation_pools = orm.relationship(IPAllocationPool,
                                         backref='subnet',
- lazy="dynamic")
+ lazy="dynamic", cascade='delete')
     enable_dhcp = sa.Column(sa.Boolean())
     dns_nameservers = orm.relationship(DNSNameServer,
                                        backref='subnet',