summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-04-25 18:54:05 +0000
committerGerrit Code Review <review@openstack.org>2013-04-25 18:54:05 +0000
commit858d1f4ea23ad8210f818367ec2ba0fe125a8b72 (patch)
treee55d98f330b7b6e525a3936b14f9c6469e4b9921 /nova/api
parentd50edab2bc5403f3184efe3480642fcb725cac22 (diff)
parentddb3199318bf91e76b4c4e7330956ee581c91ccc (diff)
downloadnova-858d1f4ea23ad8210f818367ec2ba0fe125a8b72.tar.gz
nova-858d1f4ea23ad8210f818367ec2ba0fe125a8b72.tar.xz
nova-858d1f4ea23ad8210f818367ec2ba0fe125a8b72.zip
Merge "Move get_backdoor_port to base rpc API."
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/coverage_ext.py57
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):