From 7097e01a15ecd5c28b6b771e5043f18da243607e Mon Sep 17 00:00:00 2001 From: deevi rani Date: Thu, 3 May 2012 06:42:47 -0400 Subject: Updates the cache fixes bug 939122 Following are the changes done: 1. in compute/api.py to display the floating ip in nova list command upon its association with an instance. 2. in network/api.py to solve the similar issue upon the floating ip disassocaition Updated version of: https://review.openstack.org/#/c/7059 Change-Id: Ief1a3f544c3d14bd61cc0814612df3ee521ddec2 --- nova/compute/api.py | 2 ++ nova/network/api.py | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'nova') diff --git a/nova/compute/api.py b/nova/compute/api.py index 922a8bace..1e28f0190 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1623,6 +1623,8 @@ class API(base.Base): self.network_api.associate_floating_ip(context, floating_address=address, fixed_address=ips[0]['address']) + self.network_api.invalidate_instance_cache(context.elevated(), + instance) @wrap_check_policy def get_instance_metadata(self, context, instance): diff --git a/nova/network/api.py b/nova/network/api.py index ecef022bc..715d054d5 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -146,10 +146,18 @@ class API(base.Base): def disassociate_floating_ip(self, context, address, affect_auto_assigned=False): """Disassociates a floating ip from fixed ip it is associated with.""" + floating_ip = self.db.floating_ip_get_by_address(context, address) + fixed_ip = self.db.fixed_ip_get(context, floating_ip['fixed_ip_id']) + instance = self.db.instance_get(context, fixed_ip['instance_id']) rpc.cast(context, FLAGS.network_topic, {'method': 'disassociate_floating_ip', 'args': {'address': address}}) + self.invalidate_instance_cache(context, instance) + + def invalidate_instance_cache(self, context, instance): + # NOTE(vish): get_instance_nw_info will recreate the cache for us + self.get_instance_nw_info(context, instance) def allocate_for_instance(self, context, instance, **kwargs): """Allocates all network structures for an instance. -- cgit