diff options
author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-01-28 10:07:42 +0000 |
---|---|---|
committer | Tarmac <> | 2011-01-28 10:07:42 +0000 |
commit | 396b02f876030f1f54b7af32cf94fccbbe1fe46b (patch) | |
tree | c521d11ecf13ca78c20343e7a9eee223e79b816a | |
parent | be89c642e335e76bcb304b2880a4fd8241783436 (diff) | |
parent | 98cc358d4cc04b61fc19ce77f5db58cf88c6e908 (diff) | |
download | nova-396b02f876030f1f54b7af32cf94fccbbe1fe46b.tar.gz nova-396b02f876030f1f54b7af32cf94fccbbe1fe46b.tar.xz nova-396b02f876030f1f54b7af32cf94fccbbe1fe46b.zip |
Disassociate all floating ips on terminate instance.
-rw-r--r-- | nova/compute/manager.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0f9bf301f..f4418af26 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -37,7 +37,6 @@ terminating it. import datetime import random import string -import logging import socket import functools @@ -231,22 +230,25 @@ class ComputeManager(manager.Manager): instance_ref = self.db.instance_get(context, instance_id) LOG.audit(_("Terminating instance %s"), instance_id, context=context) - if not FLAGS.stub_network: - address = self.db.instance_get_floating_address(context, - instance_ref['id']) - if address: - LOG.debug(_("Disassociating address %s"), address, + fixed_ip = instance_ref.get('fixed_ip') + if not FLAGS.stub_network and fixed_ip: + floating_ips = fixed_ip.get('floating_ips') or [] + for floating_ip in floating_ips: + address = floating_ip['address'] + LOG.debug("Disassociating address %s", address, context=context) # NOTE(vish): Right now we don't really care if the ip is # disassociated. We may need to worry about # checking this later. + network_topic = self.db.queue_get_for(context, + FLAGS.network_topic, + floating_ip['host']) rpc.cast(context, - self.get_network_topic(context), + network_topic, {"method": "disassociate_floating_ip", "args": {"floating_address": address}}) - address = self.db.instance_get_fixed_address(context, - instance_ref['id']) + address = fixed_ip['address'] if address: LOG.debug(_("Deallocating address %s"), address, context=context) @@ -256,7 +258,7 @@ class ComputeManager(manager.Manager): self.network_manager.deallocate_fixed_ip(context.elevated(), address) - volumes = instance_ref.get('volumes', []) or [] + volumes = instance_ref.get('volumes') or [] for volume in volumes: self.detach_volume(context, instance_id, volume['id']) if instance_ref['state'] == power_state.SHUTOFF: |