Skip adding host to aggregate with az if host already in other zone
Running test_aggregate_basic_ops fails if the selected host is already in an other zone: "Cannot add host to aggregate 1773. Reason: One or more hosts already in availability zone(s)" This is to find an up and enabled host that has not been added to other zone, and skip test_aggregate_basic_ops if all hosts in the system are already in other zones. Change-Id: I2c196ca22c963af976b256016c36f4095ccf8f61
This commit is contained in:
parent
9ddee691f3
commit
4de3d536b0
|
@ -51,10 +51,27 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||||
return aggregate
|
return aggregate
|
||||||
|
|
||||||
def _get_host_name(self):
|
def _get_host_name(self):
|
||||||
|
# Find a host that has not been added to other availability zone,
|
||||||
|
# for one host can't be added to different availability zones.
|
||||||
svc_list = self.services_client.list_services(
|
svc_list = self.services_client.list_services(
|
||||||
binary='nova-compute')['services']
|
binary='nova-compute')['services']
|
||||||
self.assertNotEmpty(svc_list)
|
self.assertNotEmpty(svc_list)
|
||||||
return svc_list[0]['host']
|
hosts_available = []
|
||||||
|
for host in svc_list:
|
||||||
|
if (host['state'] == 'up' and host['status'] == 'enabled'):
|
||||||
|
hosts_available.append(host['host'])
|
||||||
|
aggregates = self.aggregates_client.list_aggregates()['aggregates']
|
||||||
|
hosts_in_zone = []
|
||||||
|
for agg in aggregates:
|
||||||
|
if agg['availability_zone']:
|
||||||
|
hosts_in_zone.extend(agg['hosts'])
|
||||||
|
hosts = [v for v in hosts_available if v not in hosts_in_zone]
|
||||||
|
if not hosts:
|
||||||
|
raise self.skipException("All hosts are already in other "
|
||||||
|
"availability zones, so can't add "
|
||||||
|
"host to aggregate. \nAggregates list: "
|
||||||
|
"%s" % aggregates)
|
||||||
|
return hosts[0]
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue