diff --git a/nova/compute/api.py b/nova/compute/api.py index e939de62c2c..0fd55f97d30 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -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]) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b70f444e9fe..b013444638b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -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',