From: Dan Wendlandt Date: Wed, 8 Aug 2012 22:30:48 +0000 (-0700) Subject: fix missing deallocation of gateway ip X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bcde97b48552072bda453e08f6a5c669b2838c05;p=openstack-build%2Fneutron-build.git fix missing deallocation of gateway ip bug 1032506 when deleting a port that uses the gateway IP, we were not removing the IPAllocation entry, which resulted in a depedency issue when we deleted the port that the IPAllocation entry referenced. Change-Id: I272a6572c389ef8c12585f4b62204f5877cda078 --- diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index d07e5d0d0..ed3922ac9 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -240,6 +240,12 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2): last_ip=ip_address) context.session.add(ip_range) LOG.debug("Recycle: created new %s-%s", ip_address, ip_address) + QuantumDbPluginV2._delete_ip_allocation(context, network_id, subnet_id, + port_id, ip_address) + + @staticmethod + def _delete_ip_allocation(context, network_id, subnet_id, port_id, + ip_address): # Delete the IP address from the IPAllocate table LOG.debug("Delete allocated IP %s (%s/%s/%s)", ip_address, @@ -834,9 +840,14 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2): allocated = allocated_qry.filter_by(port_id=id).all() if allocated: for a in allocated: - # Gateway address will not be recycled subnet = self._get_subnet(context, a['subnet_id']) if a['ip_address'] == subnet['gateway_ip']: + # Gateway address will not be recycled, but we do + # need to delete the allocation from the DB + QuantumDbPluginV2._delete_ip_allocation( + context, + a['network_id'], a['subnet_id'], + id, a['ip_address']) LOG.debug("Gateway address (%s/%s) is not recycled", a['ip_address'], a['subnet_id']) continue