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 /nova/api | |
| 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
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/coverage_ext.py | 57 |
1 files changed, 18 insertions, 39 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): |
