From a7551a20b2f54daf952097a93126c554b91098cc Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 4 Dec 2012 11:10:51 -0500 Subject: Add host to get_backdoor_port() for network api. get_backdoor_port() in the network api doesn't have a host parameter. However, if there are more than one network service running on multiple hosts then you will only be able to get the backdoor port for one of those services. So the host field is needed to target the rpc call. Also, the RPC_API_VERSION number was incremented because this was overlooked in change id: I95fdb5ca9bce9f3128300e3b5601fb2b2fc5e82f Change-Id: I90357548c0483559982469b7c26d40511755924e --- nova/network/api.py | 4 ++-- nova/network/manager.py | 2 +- nova/network/rpcapi.py | 7 +++++-- nova/tests/network/test_api.py | 4 ++-- nova/tests/network/test_rpcapi.py | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nova/network/api.py b/nova/network/api.py index bd12e73c0..b61de3cf6 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -123,8 +123,8 @@ class API(base.Base): return self.network_rpcapi.get_floating_ips_by_fixed_address(context, fixed_address) - def get_backdoor_port(self, context): - return self.network_rpcapi.get_backdoor_port(context) + def get_backdoor_port(self, context, host): + return self.network_rpcapi.get_backdoor_port(context, host) def get_instance_id_by_floating_address(self, context, address): # NOTE(tr3buchet): i hate this diff --git a/nova/network/manager.py b/nova/network/manager.py index 7583eaef9..465863615 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -876,7 +876,7 @@ class NetworkManager(manager.SchedulerDependentManager): The one at a time part is to flatten the layout to help scale """ - RPC_API_VERSION = '1.3' + RPC_API_VERSION = '1.4' # If True, this manager requires VIF to create a bridge. SHOULD_CREATE_BRIDGE = False diff --git a/nova/network/rpcapi.py b/nova/network/rpcapi.py index dc2ae6698..f7bc02d84 100644 --- a/nova/network/rpcapi.py +++ b/nova/network/rpcapi.py @@ -36,6 +36,7 @@ class NetworkAPI(rpc_proxy.RpcProxy): 1.1 - Adds migrate_instance_[start|finish] 1.2 - Make migrate_instance_[start|finish] a little more flexible 1.3 - Adds fanout cast update_dns for multi_host networks + 1.4 - Add get_backdoor_port() ''' # @@ -105,8 +106,10 @@ class NetworkAPI(rpc_proxy.RpcProxy): 'get_instance_id_by_floating_address', address=address)) - def get_backdoor_port(self, ctxt): - return self.call(ctxt, self.make_msg('get_backdoor_port')) + def get_backdoor_port(self, ctxt, host): + return self.call(ctxt, self.make_msg('get_backdoor_port'), + topic=rpc.queue_get_for(ctxt, self.topic, host), + version='1.4') def get_vifs_by_instance(self, ctxt, instance_id): # NOTE(vish): When the db calls are converted to store network diff --git a/nova/tests/network/test_api.py b/nova/tests/network/test_api.py index a033c6506..ef97a4982 100644 --- a/nova/tests/network/test_api.py +++ b/nova/tests/network/test_api.py @@ -202,11 +202,11 @@ class ApiTestCase(test.TestCase): def test_get_backdoor_port(self): backdoor_port = 59697 - def fake_get_backdoor_port(ctxt): + def fake_get_backdoor_port(ctxt, host): return backdoor_port self.stubs.Set(self.network_api.network_rpcapi, 'get_backdoor_port', fake_get_backdoor_port) - port = self.network_api.get_backdoor_port(self.context) + port = self.network_api.get_backdoor_port(self.context, 'fake_host') self.assertEqual(port, backdoor_port) diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py index c31b34a51..dd6cccf0f 100644 --- a/nova/tests/network/test_rpcapi.py +++ b/nova/tests/network/test_rpcapi.py @@ -46,7 +46,7 @@ class NetworkRpcAPITestCase(test.TestCase): '_rpc_allocate_fixed_ip', 'deallocate_fixed_ip', 'update_dns', '_associate_floating_ip', '_disassociate_floating_ip', 'lease_fixed_ip', 'release_fixed_ip', 'migrate_instance_start', - 'migrate_instance_finish', + 'migrate_instance_finish', 'get_backdoor_port' ] if method in targeted_methods and 'host' in kwargs: if method != 'deallocate_fixed_ip': @@ -122,7 +122,8 @@ class NetworkRpcAPITestCase(test.TestCase): rpc_method='call', address='w.x.y.z') def test_get_backdoor_port(self): - self._test_network_api('get_backdoor_port', rpc_method='call') + self._test_network_api('get_backdoor_port', rpc_method='call', + host='fake_host', version='1.4') def test_get_vifs_by_instance(self): self._test_network_api('get_vifs_by_instance', -- cgit