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
(cherry picked from commit 7097e01a15)
This commit is contained in:
deevi rani 2012-05-03 06:42:47 -04:00 committed by Vishvananda Ishaya
parent c3376bb44e
commit caae0e9ca3
3 changed files with 11 additions and 0 deletions

View File

@ -204,3 +204,4 @@ Zed Shaw <zedshaw@zedshaw.com>
Zhixue Wu <Zhixue.Wu@citrix.com>
Zhongyue Luo <lzyeval@gmail.com>
Ziad Sawalha <github@highbridgellc.com>
Deevi Rani <deevi_rani@persistent.co.in>

View File

@ -1639,6 +1639,8 @@ class API(BaseAPI):
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):

View File

@ -148,10 +148,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.