summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Wendlandt <dan@nicira.com>2012-06-01 17:07:13 -0700
committerGary Kotton <gkotton@redhat.com>2012-06-17 09:23:49 -0400
commit9b789bed095e6110d126f8d355e1434a2b0c60f0 (patch)
treea3a41e4299a626e768e0ca7d4f3cb22ad91292dc
parent259638d32a39cb256fc3779cc3b56f0794e64cab (diff)
downloadnova-9b789bed095e6110d126f8d355e1434a2b0c60f0.tar.gz
Quantum Manager disassociate floating-ips on instance delete.
bug #997763 Change-Id: I4a1e6c63d2a27c361433b9150dd5ad5218578c02
-rw-r--r--nova/network/quantum/nova_ipam_lib.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/nova/network/quantum/nova_ipam_lib.py b/nova/network/quantum/nova_ipam_lib.py
index 7b138b89d0..fff32432ab 100644
--- a/nova/network/quantum/nova_ipam_lib.py
+++ b/nova/network/quantum/nova_ipam_lib.py
@@ -228,10 +228,31 @@ class QuantumNovaIPAMLib(object):
# - otherwise, _disassociate_stale_fixed_ips is called periodically
# to disassociate all fixed ips that are unallocated
# but still associated with an instance-id.
+
+ read_deleted_context = admin_context.elevated(read_deleted='yes')
for fixed_ip in fixed_ips:
db.fixed_ip_update(admin_context, fixed_ip['address'],
{'allocated': False,
'virtual_interface_id': None})
+ fixed_id = fixed_ip['id']
+ floating_ips = self.net_manager.db.floating_ip_get_by_fixed_ip_id(
+ admin_context,
+ fixed_id)
+ # disassociate floating ips related to fixed_ip
+ for floating_ip in floating_ips:
+ address = floating_ip['address']
+ manager.FloatingIP.disassociate_floating_ip(
+ self.net_manager,
+ read_deleted_context,
+ address,
+ affect_auto_assigned=True)
+ # deallocate if auto_assigned
+ if floating_ip['auto_assigned']:
+ manager.FloatingIP.deallocate_floating_ip(
+ read_deleted_context,
+ address,
+ affect_auto_assigned=True)
+
if len(fixed_ips) == 0:
LOG.error(_('No fixed IPs to deallocate for vif %s') %
vif_ref['id'])