diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-06-20 19:37:42 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-06-20 19:37:42 +0000 |
| commit | 5226d4054cb2b25bca9a00636663cd56d4f1ddb5 (patch) | |
| tree | 00722fe4864646d7579ff6df0303b271e83e7c4e /nova | |
| parent | ba3754e3ff672a877d90c78486c7f4d5fd4bf7b0 (diff) | |
| parent | 2c0adf1304e73eb1c940a6fbfd50bf34f870e282 (diff) | |
Merge "Fix bug 1014925: fix os-hosts"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/openstack/compute/contrib/hosts.py | 8 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_hosts.py | 15 |
2 files changed, 14 insertions, 9 deletions
diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py index 6cdca56c8..e24ef3605 100644 --- a/nova/api/openstack/compute/contrib/hosts.py +++ b/nova/api/openstack/compute/contrib/hosts.py @@ -27,7 +27,6 @@ from nova import db from nova import exception from nova import flags from nova import log as logging -from nova.scheduler import rpcapi as scheduler_rpcapi LOG = logging.getLogger(__name__) @@ -98,8 +97,11 @@ def _list_hosts(req, service=None): by service type. """ context = req.environ['nova.context'] - rpcapi = scheduler_rpcapi.SchedulerAPI() - hosts = rpcapi.get_host_list(context) + services = db.service_get_all(context, False) + + hosts = [] + for host in services: + hosts.append({"host_name": host['host'], 'service': host['topic']}) if service: hosts = [host for host in hosts if host["service"] == service] diff --git a/nova/tests/api/openstack/compute/contrib/test_hosts.py b/nova/tests/api/openstack/compute/contrib/test_hosts.py index 2e4064c21..40805bb66 100644 --- a/nova/tests/api/openstack/compute/contrib/test_hosts.py +++ b/nova/tests/api/openstack/compute/contrib/test_hosts.py @@ -24,22 +24,25 @@ from nova import db from nova import exception from nova import flags from nova import log as logging -from nova.scheduler import rpcapi as scheduler_rpcapi from nova import test FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) -# Simulate the hosts returned by the zone manager. HOST_LIST = [ {"host_name": "host_c1", "service": "compute"}, {"host_name": "host_c2", "service": "compute"}, {"host_name": "host_v1", "service": "volume"}, {"host_name": "host_v2", "service": "volume"}] +SERVICES_LIST = [ + {"host": "host_c1", "topic": "compute"}, + {"host": "host_c2", "topic": "compute"}, + {"host": "host_v1", "topic": "volume"}, + {"host": "host_v2", "topic": "volume"}] -def stub_get_host_list(self, req): - return HOST_LIST +def stub_service_get_all(self, req): + return SERVICES_LIST def stub_set_host_enabled(context, host, enabled): @@ -104,8 +107,8 @@ class HostTestCase(test.TestCase): super(HostTestCase, self).setUp() self.controller = os_hosts.HostController() self.req = FakeRequest() - self.stubs.Set(scheduler_rpcapi.SchedulerAPI, 'get_host_list', - stub_get_host_list) + self.stubs.Set(db, 'service_get_all', + stub_service_get_all) self.stubs.Set(self.controller.api, 'set_host_enabled', stub_set_host_enabled) self.stubs.Set(self.controller.api, 'set_host_maintenance', |
