Skip to content

Commit

Permalink
Call get_instance_nw_info with elevated context, as documented in nov…
Browse files Browse the repository at this point in the history
…a/network/manager.py

* Fixes Bug 904976
* Add coverage for this in associate_floating_ip unit test

Change-Id: I5bc35632ca382d011eb42e738140ba54d9cdc93f
  • Loading branch information
sleepsonthefloor committed Dec 16, 2011
1 parent 2ea74ba commit 59193f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ def associate_floating_ip(self, context, instance, address):
# accommodate the info containing floating as well as fixed ip
# addresses
fixed_ip_addrs = []
for info in self.network_api.get_instance_nw_info(context,
for info in self.network_api.get_instance_nw_info(context.elevated(),
instance):
ips = info[1]['ips']
fixed_ip_addrs.extend([ip_dict['ip'] for ip_dict in ips])
Expand Down
3 changes: 2 additions & 1 deletion nova/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,8 @@ def fake_associate_ip_network_api(self, ctxt, floating_address,

nw_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)

def fake_get_nw_info(self, ctxt, instance):
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
return nw_info

self.stubs.Set(nova.network.API, 'associate_floating_ip',
Expand Down

0 comments on commit 59193f1

Please sign in to comment.