Replace list_hypervisors with list_services

This fixes a regression introduced with commit 88c7ea8 which replaced
list_hosts with list_hypervisors because the former is deprecated.
However, the hypervisor_hostname cannot be used as replacement for
compute hostname. This patch fixes the problem by switching to
list_services which returns compute hostnames.

Change-Id: I948429075e71e11e091703c4b12378c71c37bc29
This commit is contained in:
Radoslav Gerganov 2018-04-04 10:27:34 +03:00
parent cad11526e3
commit 30d8b8ecde
2 changed files with 9 additions and 7 deletions

View File

@ -27,15 +27,16 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
def setup_clients(cls): def setup_clients(cls):
super(AggregatesAdminNegativeTestJSON, cls).setup_clients() super(AggregatesAdminNegativeTestJSON, cls).setup_clients()
cls.client = cls.os_admin.aggregates_client cls.client = cls.os_admin.aggregates_client
cls.hyper_client = cls.os_admin.hypervisor_client cls.services_client = cls.os_admin.services_client
@classmethod @classmethod
def resource_setup(cls): def resource_setup(cls):
super(AggregatesAdminNegativeTestJSON, cls).resource_setup() super(AggregatesAdminNegativeTestJSON, cls).resource_setup()
cls.aggregate_name_prefix = 'test_aggregate' cls.aggregate_name_prefix = 'test_aggregate'
hyper_list = cls.hyper_client.list_hypervisors()['hypervisors'] svc_list = cls.services_client.list_services(
cls.hosts = [v['hypervisor_hostname'] for v in hyper_list binary='nova-compute')['services']
cls.hosts = [v['host'] for v in svc_list
if v['status'] == 'enabled' and v['state'] == 'up'] if v['status'] == 'enabled' and v['state'] == 'up']
def _create_test_aggregate(self): def _create_test_aggregate(self):

View File

@ -37,7 +37,7 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
super(TestAggregatesBasicOps, cls).setup_clients() super(TestAggregatesBasicOps, cls).setup_clients()
# Use admin client by default # Use admin client by default
cls.aggregates_client = cls.os_admin.aggregates_client cls.aggregates_client = cls.os_admin.aggregates_client
cls.hyper_client = cls.os_admin.hypervisor_client cls.services_client = cls.os_admin.services_client
def _create_aggregate(self, **kwargs): def _create_aggregate(self, **kwargs):
aggregate = (self.aggregates_client.create_aggregate(**kwargs) aggregate = (self.aggregates_client.create_aggregate(**kwargs)
@ -51,9 +51,10 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
return aggregate return aggregate
def _get_host_name(self): def _get_host_name(self):
hyper_list = self.hyper_client.list_hypervisors()['hypervisors'] svc_list = self.services_client.list_services(
self.assertNotEmpty(hyper_list) binary='nova-compute')['services']
return hyper_list[0]['hypervisor_hostname'] self.assertNotEmpty(svc_list)
return svc_list[0]['host']
def _add_host(self, aggregate_id, host): def _add_host(self, aggregate_id, host):
aggregate = (self.aggregates_client.add_host(aggregate_id, host=host) aggregate = (self.aggregates_client.add_host(aggregate_id, host=host)