Skip to content

Commit

Permalink
Updates the cache
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deevi rani authored and vishvananda committed Jun 14, 2012
1 parent aa1e71d commit 7097e01
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -221,3 +221,4 @@ Zhiteng Huang <zhiteng.huang@intel.com>
Zhixue Wu <Zhixue.Wu@citrix.com>
Zhongyue Luo <lzyeval@gmail.com>
Ziad Sawalha <github@highbridgellc.com>
Deevi Rani <deevi_rani@persistent.co.in>
2 changes: 2 additions & 0 deletions nova/compute/api.py
Expand Up @@ -1623,6 +1623,8 @@ def associate_floating_ip(self, context, instance, address):

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):
Expand Down
8 changes: 8 additions & 0 deletions nova/network/api.py
Expand Up @@ -146,10 +146,18 @@ def associate_floating_ip(self, context, floating_address, fixed_address,
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.
Expand Down

0 comments on commit 7097e01

Please sign in to comment.