Merge "Replacing deprecated list_hosts with list_hypervisors"
This commit is contained in:
@@ -27,16 +27,16 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def setup_clients(cls):
|
||||
super(AggregatesAdminNegativeTestJSON, cls).setup_clients()
|
||||
cls.client = cls.os_admin.aggregates_client
|
||||
cls.hyper_client = cls.os_admin.hypervisor_client
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(AggregatesAdminNegativeTestJSON, cls).resource_setup()
|
||||
cls.aggregate_name_prefix = 'test_aggregate'
|
||||
|
||||
hosts_all = cls.os_admin.hosts_client.list_hosts()['hosts']
|
||||
hosts = ([host['host_name']
|
||||
for host in hosts_all if host['service'] == 'compute'])
|
||||
cls.host = hosts[0]
|
||||
hyper_list = cls.hyper_client.list_hypervisors()['hypervisors']
|
||||
cls.hosts = [v['hypervisor_hostname'] for v in hyper_list
|
||||
if v['status'] == 'enabled' and v['state'] == 'up']
|
||||
|
||||
def _create_test_aggregate(self):
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
@@ -123,11 +123,9 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@decorators.idempotent_id('0ef07828-12b4-45ba-87cc-41425faf5711')
|
||||
def test_aggregate_add_non_exist_host(self):
|
||||
# Adding a non-exist host to an aggregate should raise exceptions.
|
||||
hosts_all = self.os_admin.hosts_client.list_hosts()['hosts']
|
||||
hosts = map(lambda x: x['host_name'], hosts_all)
|
||||
while True:
|
||||
non_exist_host = data_utils.rand_name('nonexist_host')
|
||||
if non_exist_host not in hosts:
|
||||
if non_exist_host not in self.hosts:
|
||||
break
|
||||
aggregate = self._create_test_aggregate()
|
||||
self.assertRaises(lib_exc.NotFound, self.client.add_host,
|
||||
@@ -140,7 +138,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
aggregate = self._create_test_aggregate()
|
||||
self.assertRaises(lib_exc.Forbidden,
|
||||
self.aggregates_client.add_host,
|
||||
aggregate['id'], host=self.host)
|
||||
aggregate['id'], host=self.hosts[0])
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('19dd44e1-c435-4ee1-a402-88c4f90b5950')
|
||||
@@ -148,12 +146,12 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate = self._create_test_aggregate()
|
||||
|
||||
self.client.add_host(aggregate['id'], host=self.host)
|
||||
self.client.add_host(aggregate['id'], host=self.hosts[0])
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'],
|
||||
host=self.host)
|
||||
host=self.hosts[0])
|
||||
|
||||
self.assertRaises(lib_exc.Conflict, self.client.add_host,
|
||||
aggregate['id'], host=self.host)
|
||||
aggregate['id'], host=self.hosts[0])
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('7a53af20-137a-4e44-a4ae-e19260e626d9')
|
||||
@@ -162,13 +160,13 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate = self._create_test_aggregate()
|
||||
|
||||
self.client.add_host(aggregate['id'], host=self.host)
|
||||
self.client.add_host(aggregate['id'], host=self.hosts[0])
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'],
|
||||
host=self.host)
|
||||
host=self.hosts[0])
|
||||
|
||||
self.assertRaises(lib_exc.Forbidden,
|
||||
self.aggregates_client.remove_host,
|
||||
aggregate['id'], host=self.host)
|
||||
aggregate['id'], host=self.hosts[0])
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('95d6a6fa-8da9-4426-84d0-eec0329f2e4d')
|
||||
|
||||
@@ -37,7 +37,7 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
super(TestAggregatesBasicOps, cls).setup_clients()
|
||||
# Use admin client by default
|
||||
cls.aggregates_client = cls.os_admin.aggregates_client
|
||||
cls.hosts_client = cls.os_admin.hosts_client
|
||||
cls.hyper_client = cls.os_admin.hypervisor_client
|
||||
|
||||
def _create_aggregate(self, **kwargs):
|
||||
aggregate = (self.aggregates_client.create_aggregate(**kwargs)
|
||||
@@ -51,10 +51,9 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
return aggregate
|
||||
|
||||
def _get_host_name(self):
|
||||
hosts = self.hosts_client.list_hosts()['hosts']
|
||||
self.assertNotEmpty(hosts)
|
||||
computes = [x for x in hosts if x['service'] == 'compute']
|
||||
return computes[0]['host_name']
|
||||
hyper_list = self.hyper_client.list_hypervisors()['hypervisors']
|
||||
self.assertNotEmpty(hyper_list)
|
||||
return hyper_list[0]['hypervisor_hostname']
|
||||
|
||||
def _add_host(self, aggregate_id, host):
|
||||
aggregate = (self.aggregates_client.add_host(aggregate_id, host=host)
|
||||
|
||||
Reference in New Issue
Block a user