From 93516a528d83d4802421cfb3ee0695f06bdd5f8b Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Mon, 21 Jan 2013 12:39:47 -0500 Subject: Fix get Floating ip pools action name to match with its policy Get Floating IP Pools is always responding 403 (Forbidden) cause its method name, which is also being used as action name, doesn't match with the name in policy.json file. I opted for this approach cause it also fixes the different names between the extension (which is named floating **ip** pools instead of floating pools) and the backend. Another good practice would be change the default_floating_pool option to default_float_ip_pool, but that would require change the conf file and possibly break some compatibility. Fixes bug 1091668 Change-Id: I2627e8b0f45c5c39bbbf1a4a12b448e1992fa4b4 --- nova/network/api.py | 2 +- nova/network/manager.py | 14 ++++++++++++++ nova/network/rpcapi.py | 6 ++++-- nova/tests/network/test_rpcapi.py | 5 +++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/nova/network/api.py b/nova/network/api.py index 976be93ed..5e3762e89 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -111,7 +111,7 @@ class API(base.Base): return self.network_rpcapi.get_floating_ip(context, id) def get_floating_ip_pools(self, context): - return self.network_rpcapi.get_floating_pools(context) + return self.network_rpcapi.get_floating_ip_pools(context) def get_floating_ip_by_address(self, context, address): return self.network_rpcapi.get_floating_ip_by_address(context, address) diff --git a/nova/network/manager.py b/nova/network/manager.py index ccdac6f60..1933b552e 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -710,6 +710,13 @@ class FloatingIP(object): @wrap_check_policy def get_floating_pools(self, context): """Returns list of floating pools.""" + # NOTE(maurosr) This method should be removed in future, replaced by + # get_floating_ip_pools. See bug #1091668 + return self.get_floating_ip_pools(context) + + @wrap_check_policy + def get_floating_ip_pools(self, context): + """Returns list of floating ip pools.""" pools = self.db.floating_ip_get_pools(context) return [dict(pool.iteritems()) for pool in pools] @@ -2077,6 +2084,13 @@ class FlatManager(NetworkManager): @wrap_check_policy def get_floating_pools(self, context): """Returns list of floating pools.""" + # NOTE(maurosr) This method should be removed in future, replaced by + # get_floating_ip_pools. See bug #1091668 + return {} + + @wrap_check_policy + def get_floating_ip_pools(self, context): + """Returns list of floating ip pools.""" return {} @wrap_check_policy diff --git a/nova/network/rpcapi.py b/nova/network/rpcapi.py index 2f52add57..a7bffe17a 100644 --- a/nova/network/rpcapi.py +++ b/nova/network/rpcapi.py @@ -45,6 +45,7 @@ class NetworkAPI(rpc_proxy.RpcProxy): 1.4 - Add get_backdoor_port() 1.5 - Adds associate 1.6 - Adds instance_uuid to _{dis,}associate_floating_ip + 1.7 - Adds method get_floating_ip_pools to replace get_floating_pools ''' # @@ -94,8 +95,9 @@ class NetworkAPI(rpc_proxy.RpcProxy): def get_floating_ip(self, ctxt, id): return self.call(ctxt, self.make_msg('get_floating_ip', id=id)) - def get_floating_pools(self, ctxt): - return self.call(ctxt, self.make_msg('get_floating_pools')) + def get_floating_ip_pools(self, ctxt): + return self.call(ctxt, self.make_msg('get_floating_ip_pools'), + version="1.7") def get_floating_ip_by_address(self, ctxt, address): return self.call(ctxt, self.make_msg('get_floating_ip_by_address', diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py index 90bffeeaf..5ba7459fb 100644 --- a/nova/tests/network/test_rpcapi.py +++ b/nova/tests/network/test_rpcapi.py @@ -108,8 +108,9 @@ class NetworkRpcAPITestCase(test.TestCase): def test_get_floating_ip(self): self._test_network_api('get_floating_ip', rpc_method='call', id='id') - def test_get_floating_pools(self): - self._test_network_api('get_floating_pools', rpc_method='call') + def test_get_floating_ip_pools(self): + self._test_network_api('get_floating_ip_pools', rpc_method='call', + version="1.7") def test_get_floating_ip_by_address(self): self._test_network_api('get_floating_ip_by_address', rpc_method='call', -- cgit