diff options
| author | Russell Bryant <rbryant@redhat.com> | 2013-04-10 00:59:03 +0200 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2013-04-24 15:02:56 -0400 |
| commit | ddb3199318bf91e76b4c4e7330956ee581c91ccc (patch) | |
| tree | 5e9789b714483481d6d1b68d94debb92ed42ab0c | |
| parent | a025d7eee28026cb21cb0e732e6510d5d9b7d96f (diff) | |
| download | nova-ddb3199318bf91e76b4c4e7330956ee581c91ccc.tar.gz nova-ddb3199318bf91e76b4c4e7330956ee581c91ccc.tar.xz nova-ddb3199318bf91e76b4c4e7330956ee581c91ccc.zip | |
Move get_backdoor_port to base rpc API.
Each service implemented the get_backdoor_port method individually. This
patch moves the implementation of this method to the base rpc API
instead, and removes the now unnecessary code from each of the services.
The server side method was left on all of the managers for rpc backwards
copmatibility. They can be removed on the next major rpc version bump
of those APIs.
Part of blueprint base-rpc-api.
Change-Id: Ia8838fafd80eb86a1c2d66f5e97370042d8d8c53
38 files changed, 56 insertions, 232 deletions
diff --git a/nova/api/openstack/compute/contrib/coverage_ext.py b/nova/api/openstack/compute/contrib/coverage_ext.py index b8a1681d0..50003bdab 100644 --- a/nova/api/openstack/compute/contrib/coverage_ext.py +++ b/nova/api/openstack/compute/contrib/coverage_ext.py @@ -28,15 +28,10 @@ from oslo.config import cfg from webob import exc from nova.api.openstack import extensions -from nova.cert import rpcapi as cert_api -from nova.compute import api as compute_api -from nova.conductor import api as conductor_api -from nova.console import api as console_api -from nova.consoleauth import rpcapi as consoleauth_api +from nova import baserpc from nova import db -from nova.network import api as network_api from nova.openstack.common import log as logging -from nova.scheduler import rpcapi as scheduler_api +from nova.openstack.common.rpc import common as rpc_common LOG = logging.getLogger(__name__) @@ -48,13 +43,6 @@ class CoverageController(object): """The Coverage report API controller for the OpenStack API.""" def __init__(self): self.data_path = tempfile.mkdtemp(prefix='nova-coverage_') - self.compute_api = compute_api.API() - self.network_api = network_api.API() - self.conductor_api = conductor_api.API() - self.consoleauth_api = consoleauth_api.ConsoleAuthAPI() - self.console_api = console_api.API() - self.scheduler_api = scheduler_api.SchedulerAPI() - self.cert_api = cert_api.CertAPI() self.services = [] self.combine = False self._cover_inst = None @@ -84,37 +72,28 @@ class CoverageController(object): def _find_ports(self, req, hosts): """Return a list of backdoor ports for all services in the list.""" context = req.environ['nova.context'] - - apicommands = { - "compute": self.compute_api.get_backdoor_port, - "network": self.network_api.get_backdoor_port, - "conductor": self.conductor_api.get_backdoor_port, - "consoleauth": self.consoleauth_api.get_backdoor_port, - "console": self.console_api.get_backdoor_port, - "scheduler": self.scheduler_api.get_backdoor_port, - "cert": self.cert_api.get_backdoor_port, - } ports = [] #TODO(mtreinish): Figure out how to bind the backdoor socket to 0.0.0.0 # Currently this will only work if the host is resolved as loopback on # the same host as api-server for host in hosts: - if host['service'] in apicommands: - get_port_fn = apicommands[host['service']] - _host = host - _host['port'] = get_port_fn(context, host['host']) - #NOTE(mtreinish): if the port is None then it wasn't set in - # the configuration file for this service. However, that - # doesn't necessarily mean that we don't have backdoor ports - # for all the services. So, skip the telnet connection for - # this service. - if _host['port']: - ports.append(_host) - else: - LOG.warning(_("Can't connect to service: %s, no port" - "specified\n"), host['service']) + base = baserpc.BaseAPI(host['service']) + _host = host + try: + _host['port'] = base.get_backdoor_port(context, host['host']) + except rpc_common.UnsupportedRpcVersion: + _host['port'] = None + + #NOTE(mtreinish): if the port is None then it wasn't set in + # the configuration file for this service. However, that + # doesn't necessarily mean that we don't have backdoor ports + # for all the services. So, skip the telnet connection for + # this service. + if _host['port']: + ports.append(_host) else: - LOG.debug(_("No backdoor API command for service: %s\n"), host) + LOG.warning(_("Can't connect to service: %s, no port" + "specified\n"), host['service']) return ports def _start_coverage_telnet(self, tn, service): diff --git a/nova/baserpc.py b/nova/baserpc.py index 803a1b614..1cb474209 100644 --- a/nova/baserpc.py +++ b/nova/baserpc.py @@ -19,6 +19,7 @@ Base RPC client and server common to all services. """ from nova.openstack.common import jsonutils +from nova.openstack.common import rpc import nova.openstack.common.rpc.proxy as rpc_proxy @@ -31,6 +32,7 @@ class BaseAPI(rpc_proxy.RpcProxy): API version history: 1.0 - Initial version. + 1.1 - Add get_backdoor_port """ # @@ -53,16 +55,26 @@ class BaseAPI(rpc_proxy.RpcProxy): msg = self.make_namespaced_msg('ping', self.namespace, arg=arg_p) return self.call(context, msg, timeout=timeout) + def get_backdoor_port(self, context, host): + msg = self.make_namespaced_msg('get_backdoor_port', self.namespace) + return self.call(context, msg, + topic=rpc.queue_get_for(context, self.topic, host), + version='1.1') + class BaseRPCAPI(object): """Server side of the base RPC API.""" RPC_API_NAMESPACE = _NAMESPACE - RPC_API_VERSION = '1.0' + RPC_API_VERSION = '1.1' - def __init__(self, service_name): + def __init__(self, service_name, backdoor_port): self.service_name = service_name + self.backdoor_port = backdoor_port def ping(self, context, arg): resp = {'service': self.service_name, 'arg': arg} return jsonutils.to_primitive(resp) + + def get_backdoor_port(self, context): + return self.backdoor_port diff --git a/nova/cert/manager.py b/nova/cert/manager.py index a5f14fb69..303cb547e 100644 --- a/nova/cert/manager.py +++ b/nova/cert/manager.py @@ -68,5 +68,7 @@ class CertManager(manager.Manager): """Decrypt base64 encoded text using the projects private key.""" return crypto.decrypt_text(project_id, base64.b64decode(text)) + # NOTE(russellb) This method can be removed in 2.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): return self.backdoor_port diff --git a/nova/cert/rpcapi.py b/nova/cert/rpcapi.py index 7dd843813..505efe75f 100644 --- a/nova/cert/rpcapi.py +++ b/nova/cert/rpcapi.py @@ -86,7 +86,3 @@ class CertAPI(nova.openstack.common.rpc.proxy.RpcProxy): return self.call(ctxt, self.make_msg('decrypt_text', project_id=project_id, text=text)) - - def get_backdoor_port(self, context, host): - return self.call(context, self.make_msg('get_backdoor_port'), - version='1.1') diff --git a/nova/compute/api.py b/nova/compute/api.py index 1b1a3c506..dd2d05dc9 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -2107,10 +2107,6 @@ class API(base.Base): """Retrieve diagnostics for the given instance.""" return self.compute_rpcapi.get_diagnostics(context, instance=instance) - def get_backdoor_port(self, context, host_name): - """Retrieve backdoor port.""" - return self.compute_rpcapi.get_backdoor_port(context, host_name) - @wrap_check_policy @check_instance_lock @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.RESCUED]) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7fbe8910e..3a1d7e8ab 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -650,6 +650,8 @@ class ComputeManager(manager.SchedulerDependentManager): except exception.NotFound: return power_state.NOSTATE + # NOTE(russellb) This method can be removed in 3.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): """Return backdoor port for eventlet_backdoor.""" return self.backdoor_port diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index dfa19517e..a8d7eaa47 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -620,10 +620,6 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): instance=instance_p), topic=_compute_topic(self.topic, ctxt, None, instance)) - def get_backdoor_port(self, ctxt, host): - return self.call(ctxt, self.make_msg('get_backdoor_port'), - topic=_compute_topic(self.topic, ctxt, host, None)) - def publish_service_capabilities(self, ctxt): self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities')) diff --git a/nova/conductor/api.py b/nova/conductor/api.py index bf2a66860..e8fcc2c2c 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -19,7 +19,6 @@ from oslo.config import cfg from nova import baserpc from nova.conductor import manager from nova.conductor import rpcapi -from nova import exception as exc from nova.openstack.common import log as logging from nova.openstack.common.rpc import common as rpc_common from nova import utils @@ -175,9 +174,6 @@ class LocalAPI(object): last_ctr_in, last_ctr_out, last_refreshed) - def get_backdoor_port(self, context, host): - raise exc.InvalidRequest - def security_group_get_by_instance(self, context, instance): return self._manager.security_group_get_by_instance(context, instance) @@ -510,12 +506,6 @@ class API(object): bw_in, bw_out, last_ctr_in, last_ctr_out, last_refreshed) - #NOTE(mtreinish): This doesn't work on multiple conductors without any - # topic calculation in conductor_rpcapi. So the host param isn't used - # currently. - def get_backdoor_port(self, context, host): - return self.conductor_rpcapi.get_backdoor_port(context) - def security_group_get_by_instance(self, context, instance): return self.conductor_rpcapi.security_group_get_by_instance(context, instance) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 2d027a8f2..84aca2e93 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -207,6 +207,8 @@ class ConductorManager(manager.Manager): usage = self.db.bw_usage_get(context, uuid, start_period, mac) return jsonutils.to_primitive(usage) + # NOTE(russellb) This method can be removed in 2.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): return self.backdoor_port diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 6bd4be59b..e86a0acaa 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -199,10 +199,6 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): last_refreshed=last_refreshed) return self.call(context, msg, version='1.5') - def get_backdoor_port(self, context): - msg = self.make_msg('get_backdoor_port') - return self.call(context, msg, version='1.6') - def security_group_get_by_instance(self, context, instance): instance_p = jsonutils.to_primitive(instance) msg = self.make_msg('security_group_get_by_instance', diff --git a/nova/console/api.py b/nova/console/api.py index 91966a7ff..32bf27009 100644 --- a/nova/console/api.py +++ b/nova/console/api.py @@ -69,8 +69,3 @@ class API(base.Base): else: instance = self.db.instance_get(context, instance_uuid) return instance - - def get_backdoor_port(self, context, host): - topic = self._get_console_topic(context, host) - rpcapi = console_rpcapi.ConsoleAPI(topic=topic) - return rpcapi.get_backdoor_port(context, host) diff --git a/nova/console/manager.py b/nova/console/manager.py index 777f051bb..382689381 100644 --- a/nova/console/manager.py +++ b/nova/console/manager.py @@ -133,5 +133,7 @@ class ConsoleProxyManager(manager.Manager): pool = self.db.console_pool_create(context, pool_info) return pool + # NOTE(russellb) This method can be removed in 2.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): return self.backdoor_port diff --git a/nova/console/rpcapi.py b/nova/console/rpcapi.py index 78c0c9c1a..86debae32 100644 --- a/nova/console/rpcapi.py +++ b/nova/console/rpcapi.py @@ -62,7 +62,3 @@ class ConsoleAPI(nova.openstack.common.rpc.proxy.RpcProxy): def remove_console(self, ctxt, console_id): self.cast(ctxt, self.make_msg('remove_console', console_id=console_id)) - - def get_backdoor_port(self, ctxt, host): - return self.call(ctxt, self.make_msg('get_backdoor_port'), - version='1.1') diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py index 18d75e68c..c305ed5d7 100644 --- a/nova/consoleauth/manager.py +++ b/nova/consoleauth/manager.py @@ -122,5 +122,7 @@ class ConsoleAuthManager(manager.Manager): self.mc.delete(token) self.mc.delete(instance_uuid.encode('UTF-8')) + # NOTE(russellb) This method can be removed in 2.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): return self.backdoor_port diff --git a/nova/consoleauth/rpcapi.py b/nova/consoleauth/rpcapi.py index 9ab477340..62aeab8da 100644 --- a/nova/consoleauth/rpcapi.py +++ b/nova/consoleauth/rpcapi.py @@ -71,7 +71,3 @@ class ConsoleAuthAPI(nova.openstack.common.rpc.proxy.RpcProxy): self.make_msg('delete_tokens_for_instance', instance_uuid=instance_uuid), version="1.2") - - def get_backdoor_port(self, ctxt, host): - return self.call(ctxt, self.make_msg('get_backdoor_port'), - version='1.1') diff --git a/nova/manager.py b/nova/manager.py index f2a0636d1..50f26a1b4 100644 --- a/nova/manager.py +++ b/nova/manager.py @@ -209,13 +209,13 @@ class Manager(base.Base): pluginmgr = pluginmanager.PluginManager('nova', self.__class__) pluginmgr.load_plugins() - def create_rpc_dispatcher(self): + def create_rpc_dispatcher(self, backdoor_port=None): '''Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method. ''' - base_rpc = baserpc.BaseRPCAPI(self.service_name) + base_rpc = baserpc.BaseRPCAPI(self.service_name, backdoor_port) return rpc_dispatcher.RpcDispatcher([self, base_rpc]) def periodic_tasks(self, context, raise_on_error=False): diff --git a/nova/network/api.py b/nova/network/api.py index 4d1c145f8..b8baf9810 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -173,10 +173,6 @@ class API(base.Base): return [floating_ip['address'] for floating_ip in floating_ips] @wrap_check_policy - def get_backdoor_port(self, context, host): - return self.network_rpcapi.get_backdoor_port(context, host) - - @wrap_check_policy def get_instance_id_by_floating_address(self, context, address): fixed_ip = self.db.fixed_ip_get_by_floating_address(context, address) if fixed_ip is None: diff --git a/nova/network/manager.py b/nova/network/manager.py index c910956d0..3c736e1ce 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -777,6 +777,8 @@ class NetworkManager(manager.Manager): return self.get_instance_nw_info(context, instance_id, rxtx_factor, host) + # NOTE(russellb) This method can be removed in 2.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): """Return backdoor port for eventlet_backdoor.""" return self.backdoor_port diff --git a/nova/network/rpcapi.py b/nova/network/rpcapi.py index 82263f85f..c335c9cb4 100644 --- a/nova/network/rpcapi.py +++ b/nova/network/rpcapi.py @@ -124,11 +124,6 @@ class NetworkAPI(rpc_proxy.RpcProxy): 'get_instance_id_by_floating_address', address=address)) - 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 # data by instance_uuid, this should pass uuid instead. diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 94438a2cd..8fd89858d 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -291,6 +291,8 @@ class SchedulerManager(manager.Manager): def _expire_reservations(self, context): QUOTAS.expire(context) + # NOTE(russellb) This method can be removed in 3.0 of this API. It is + # deprecated in favor of the method in the base API. def get_backdoor_port(self, context): return self.backdoor_port diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py index 47b1de79b..ac2244de4 100644 --- a/nova/scheduler/rpcapi.py +++ b/nova/scheduler/rpcapi.py @@ -116,10 +116,6 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy): capabilities=capabilities), version='2.4') - def get_backdoor_port(self, context, host): - return self.call(context, self.make_msg('get_backdoor_port'), - version='2.5') - def select_hosts(self, ctxt, request_spec, filter_properties): return self.call(ctxt, self.make_msg('select_hosts', request_spec=request_spec, diff --git a/nova/service.py b/nova/service.py index 0aa66310a..fd99dd25b 100644 --- a/nova/service.py +++ b/nova/service.py @@ -445,7 +445,7 @@ class Service(object): self.manager.pre_start_hook(rpc_connection=self.conn) - rpc_dispatcher = self.manager.create_rpc_dispatcher() + rpc_dispatcher = self.manager.create_rpc_dispatcher(self.backdoor_port) # Share this same connection for these Consumers self.conn.create_consumer(self.topic, rpc_dispatcher, fanout=False) diff --git a/nova/tests/cert/test_rpcapi.py b/nova/tests/cert/test_rpcapi.py index b743ca1e5..bacbfc194 100644 --- a/nova/tests/cert/test_rpcapi.py +++ b/nova/tests/cert/test_rpcapi.py @@ -37,9 +37,6 @@ class CertRpcAPITestCase(test.TestCase): expected_msg = rpcapi.make_msg(method, **kwargs) expected_msg['version'] = expected_version - if method == 'get_backdoor_port': - del expected_msg['args']['host'] - self.call_ctxt = None self.call_topic = None self.call_msg = None @@ -88,7 +85,3 @@ class CertRpcAPITestCase(test.TestCase): def test_decrypt_text(self): self._test_cert_api('decrypt_text', project_id='fake_project_id', text='blah') - - def test_get_backdoor_port(self): - self._test_cert_api('get_backdoor_port', host='fake_host', - version='1.1') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index dbd72a797..c9de65ed7 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -6822,24 +6822,6 @@ class ComputeAPITestCase(BaseTestCase): db.instance_destroy(self.context, instance['uuid']) - def test_get_backdoor_port(self): - # Test api call to get backdoor_port. - fake_backdoor_port = 59697 - - self.mox.StubOutWithMock(rpc, 'call') - - rpc_msg = {'method': 'get_backdoor_port', - 'namespace': None, - 'args': {}, - 'version': compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION} - rpc.call(self.context, 'compute.fake_host', rpc_msg, - None).AndReturn(fake_backdoor_port) - - self.mox.ReplayAll() - - port = self.compute_api.get_backdoor_port(self.context, 'fake_host') - self.assertEqual(port, fake_backdoor_port) - def test_console_output(self): fake_instance = {'uuid': 'fake_uuid', 'host': 'fake_compute_host'} @@ -7529,19 +7511,6 @@ class ComputeAPIAggrTestCase(BaseTestCase): self.context, aggr['id'], 'invalid_host') -class ComputeBackdoorPortTestCase(BaseTestCase): - """This is for unit test coverage of backdoor port rpc.""" - - def setUp(self): - super(ComputeBackdoorPortTestCase, self).setUp() - self.context = context.get_admin_context() - self.compute.backdoor_port = 59697 - - def test_get_backdoor_port(self): - port = self.compute.get_backdoor_port(self.context) - self.assertEqual(port, self.compute.backdoor_port) - - class ComputeAggrTestCase(BaseTestCase): """This is for unit coverage of aggregate-related methods defined in nova.compute.manager.""" diff --git a/nova/tests/compute/test_compute_cells.py b/nova/tests/compute/test_compute_cells.py index 952a557fb..40ae4e3de 100644 --- a/nova/tests/compute/test_compute_cells.py +++ b/nova/tests/compute/test_compute_cells.py @@ -148,9 +148,6 @@ class CellsComputeAPITestCase(test_compute.ComputeAPITestCase): def test_live_migrate(self): self.skipTest("Test is incompatible with cells.") - def test_get_backdoor_port(self): - self.skipTest("Test is incompatible with cells.") - def test_snapshot_given_image_uuid(self): self.skipTest("Test doesn't apply to API cell.") diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 2edf2e20f..2c04f8060 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -189,9 +189,6 @@ class ComputeRpcAPITestCase(test.TestCase): self._test_compute_api('host_power_action', 'call', action='action', host='host') - def test_get_backdoor_port(self): - self._test_compute_api('get_backdoor_port', 'call', host='host') - def test_inject_file(self): self._test_compute_api('inject_file', 'cast', instance=self.fake_instance, path='path', file_contents='fc') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 73bdf5d71..9731a76d7 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -266,30 +266,6 @@ class _BaseTestCase(object): result = self.conductor.bw_usage_update(*update_args) self.assertEqual(result, 'foo') - def test_get_backdoor_port(self): - backdoor_port = 59697 - - def fake_get_backdoor_port(self, context): - return backdoor_port - - if isinstance(self.conductor, conductor_api.API): - self.stubs.Set(conductor_manager.ConductorManager, - 'get_backdoor_port', fake_get_backdoor_port) - port = self.conductor.get_backdoor_port(self.context, 'fake_host') - elif isinstance(self.conductor, conductor_api.LocalAPI): - try: - self.conductor.get_backdoor_port(self.context, 'fake_host') - except exc.InvalidRequest: - port = backdoor_port - else: - if isinstance(self.conductor, conductor_rpcapi.ConductorAPI): - self.stubs.Set(conductor_manager.ConductorManager, - 'get_backdoor_port', fake_get_backdoor_port) - self.conductor.backdoor_port = backdoor_port - port = self.conductor.get_backdoor_port(self.context) - - self.assertEqual(port, backdoor_port) - def test_security_group_get_by_instance(self): fake_instance = {'id': 'fake-instance'} self.mox.StubOutWithMock(db, 'security_group_get_by_instance') diff --git a/nova/tests/console/test_console.py b/nova/tests/console/test_console.py index 54bcb32ca..e4211f258 100644 --- a/nova/tests/console/test_console.py +++ b/nova/tests/console/test_console.py @@ -186,13 +186,3 @@ class ConsoleAPITestCase(test.TestCase): self.mox.ReplayAll() self.console_api.create_console(self.context, self.fake_uuid) - - def test_get_backdoor_port(self): - self.mox.StubOutWithMock(console_rpcapi.ConsoleAPI, - 'get_backdoor_port') - - console_rpcapi.ConsoleAPI.get_backdoor_port(self.context, 'fake_host') - - self.mox.ReplayAll() - - self.console_api.get_backdoor_port(self.context, 'fake_host') diff --git a/nova/tests/console/test_rpcapi.py b/nova/tests/console/test_rpcapi.py index 298c59c4e..691e0ef8d 100644 --- a/nova/tests/console/test_rpcapi.py +++ b/nova/tests/console/test_rpcapi.py @@ -37,9 +37,6 @@ class ConsoleRpcAPITestCase(test.TestCase): expected_msg = rpcapi.make_msg(method, **kwargs) expected_msg['version'] = expected_version - if method == 'get_backdoor_port': - del expected_msg['args']['host'] - self.fake_args = None self.fake_kwargs = None @@ -65,7 +62,3 @@ class ConsoleRpcAPITestCase(test.TestCase): def test_remove_console(self): self._test_console_api('remove_console', console_id='i', rpc_method='cast') - - def test_get_backdoor_port(self): - self._test_console_api('get_backdoor_port', host='fake_host', - rpc_method='call', version='1.1') diff --git a/nova/tests/consoleauth/test_consoleauth.py b/nova/tests/consoleauth/test_consoleauth.py index 41bec05e1..459da2fd8 100644 --- a/nova/tests/consoleauth/test_consoleauth.py +++ b/nova/tests/consoleauth/test_consoleauth.py @@ -102,11 +102,6 @@ class ConsoleauthTestCase(test.TestCase): instance_uuid=None) self.assertFalse(self.manager.check_token(self.context, "token")) - def test_get_backdoor_port(self): - self.manager.backdoor_port = 59697 - port = self.manager.get_backdoor_port(self.context) - self.assertEqual(port, self.manager.backdoor_port) - class CellsConsoleauthTestCase(ConsoleauthTestCase): """Test Case for consoleauth w/ cells enabled.""" diff --git a/nova/tests/consoleauth/test_rpcapi.py b/nova/tests/consoleauth/test_rpcapi.py index 308c0d812..605322e75 100644 --- a/nova/tests/consoleauth/test_rpcapi.py +++ b/nova/tests/consoleauth/test_rpcapi.py @@ -38,9 +38,6 @@ class ConsoleAuthRpcAPITestCase(test.TestCase): expected_msg = rpcapi.make_msg(method, **kwargs) expected_msg['version'] = expected_version - if method == 'get_backdoor_port': - del expected_msg['args']['host'] - self.call_ctxt = None self.call_topic = None self.call_msg = None @@ -81,7 +78,3 @@ class ConsoleAuthRpcAPITestCase(test.TestCase): _do_cast=True, instance_uuid="instance", version='1.2') - - def test_get_backdoor_port(self): - self._test_consoleauth_api('get_backdoor_port', host='fake_host', - version='1.1') diff --git a/nova/tests/fake_policy.py b/nova/tests/fake_policy.py index b87360d0e..3f2d423f4 100644 --- a/nova/tests/fake_policy.py +++ b/nova/tests/fake_policy.py @@ -228,7 +228,6 @@ policy_data = """ "network:get_instance_uuids_by_ip_filter": "", "network:get_instance_id_by_floating_address": "", "network:setup_networks_on_host": "", - "network:get_backdoor_port": "", "network:get_floating_ip": "", "network:get_floating_ip_pools": "", diff --git a/nova/tests/network/test_api.py b/nova/tests/network/test_api.py index 7a53dc8d4..304229b20 100644 --- a/nova/tests/network/test_api.py +++ b/nova/tests/network/test_api.py @@ -255,15 +255,3 @@ class ApiTestCase(test.TestCase): instance = {'uuid': FAKE_UUID} result = self.network_api._is_multi_host(self.context, instance) self.assertEqual(is_multi_host, result) - - def test_get_backdoor_port(self): - backdoor_port = 59697 - - 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, 'fake_host') - self.assertEqual(port, backdoor_port) diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index f0d8e58a9..fd70e1584 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -1870,19 +1870,6 @@ class RPCAllocateTestCase(test.TestCase): self.assertEqual(rval, address) -class BackdoorPortTestCase(test.TestCase): - """Tests nova.network.manager.get_backdoor_port.""" - def setUp(self): - super(BackdoorPortTestCase, self).setUp() - self.manager = network_manager.NetworkManager() - self.manager.backdoor_port = 59697 - self.context = context.RequestContext('fake', 'fake') - - def test_backdoor_port(self): - port = self.manager.get_backdoor_port(self.context) - self.assertEqual(port, self.manager.backdoor_port) - - class TestFloatingIPManager(floating_ips.FloatingIP, network_manager.NetworkManager): """Dummy manager that implements FloatingIP.""" diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py index 55d502915..fbe0e7a8b 100644 --- a/nova/tests/network/test_rpcapi.py +++ b/nova/tests/network/test_rpcapi.py @@ -50,7 +50,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', 'get_backdoor_port', + 'migrate_instance_finish', 'allocate_for_instance', 'deallocate_for_instance', ] if method in targeted_methods and 'host' in kwargs: @@ -138,10 +138,6 @@ class NetworkRpcAPITestCase(test.TestCase): self._test_network_api('get_instance_id_by_floating_address', rpc_method='call', address='w.x.y.z') - def test_get_backdoor_port(self): - 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', rpc_method='call', instance_id='fake_id') diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py index 62038c722..9a7615c86 100644 --- a/nova/tests/scheduler/test_rpcapi.py +++ b/nova/tests/scheduler/test_rpcapi.py @@ -37,9 +37,6 @@ class SchedulerRpcAPITestCase(test.TestCase): expected_msg = rpcapi.make_msg(method, **kwargs) expected_msg['version'] = expected_version - if method == 'get_backdoor_port': - del expected_msg['args']['host'] - self.fake_args = None self.fake_kwargs = None @@ -88,10 +85,6 @@ class SchedulerRpcAPITestCase(test.TestCase): host='fake_host', capabilities='fake_capabilities', version='2.4') - def test_get_backdoor_port(self): - self._test_scheduler_api('get_backdoor_port', rpc_method='call', - host='fake_host', version='2.5') - def test_select_hosts(self): self._test_scheduler_api('select_hosts', rpc_method='call', request_spec='fake_request_spec', diff --git a/nova/tests/test_baserpc.py b/nova/tests/test_baserpc.py index 1e33fba67..d9013fb99 100644 --- a/nova/tests/test_baserpc.py +++ b/nova/tests/test_baserpc.py @@ -43,3 +43,8 @@ class BaseAPITestCase(test.TestCase): def test_ping(self): res = self.base_rpcapi.ping(self.context, 'foo') self.assertEqual(res, {'service': 'compute', 'arg': 'foo'}) + + def test_get_backdoor_port(self): + res = self.base_rpcapi.get_backdoor_port(self.context, + self.compute.host) + self.assertEqual(res, self.compute.backdoor_port) diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py index efe84fbb1..2cbc82fda 100644 --- a/nova/tests/test_service.py +++ b/nova/tests/test_service.py @@ -159,7 +159,7 @@ class ServiceTestCase(test.TestCase): # pre_start_hook is called after service record is created, # but before RPC consumer is created self.manager_mock.pre_start_hook(rpc_connection=mox.IgnoreArg()) - self.manager_mock.create_rpc_dispatcher() + self.manager_mock.create_rpc_dispatcher(None) # post_start_hook is called after RPC consumer is created. self.manager_mock.post_start_hook() |
