diff options
| author | Dan Wendlandt <dan@nicira.com> | 2012-06-01 17:07:13 -0700 |
|---|---|---|
| committer | Dan Wendlandt <dan@nicira.com> | 2012-06-01 17:07:13 -0700 |
| commit | e6e0bf343f73fb664167f173ef2ae80d39a06540 (patch) | |
| tree | bc06292310a9b202b74a4b49eb3dad9497ed8cb4 | |
| parent | 18734e9bc7eaf99caea5957618aa77e70c69db81 (diff) | |
| download | nova-e6e0bf343f73fb664167f173ef2ae80d39a06540.tar.gz nova-e6e0bf343f73fb664167f173ef2ae80d39a06540.tar.xz nova-e6e0bf343f73fb664167f173ef2ae80d39a06540.zip | |
Quantum Manager disassociate floating-ips on instance delete.
bug #997763
Change-Id: I4a1e6c63d2a27c361433b9150dd5ad5218578c02
| -rw-r--r-- | nova/network/quantum/nova_ipam_lib.py | 21 |
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 88c0ed95c..55a5718ed 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']) |
