Fix nits and log from I996d257e089f0676e316f2b14207c343063ccf8e

This commit fixes some nits and improve logging for
I996d257e089f0676e316f2b14207c343063ccf8e

Change-Id: I0fdf0fdea650a19959031d0217c3157ce2aff67c
This commit is contained in:
ghanshyam
2018-07-31 05:40:22 +00:00
committed by zhufl
parent 34afeb295a
commit 676492a6cc

View File

@@ -206,17 +206,19 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
az_name = data_utils.rand_name(self.az_name_prefix)
aggregate = self._create_test_aggregate(availability_zone=az_name)
# Find a host that has not been added to other zone,
# for one host can't be added to different zones.
# Find a host that has not been added to other availability zone,
# for one host can't be added to different availability zones.
aggregates = self.client.list_aggregates()['aggregates']
hosts_in_zone = []
for v in aggregates:
if v['availability_zone']:
hosts_in_zone.extend(v['hosts'])
for agg in aggregates:
if agg['availability_zone']:
hosts_in_zone.extend(agg['hosts'])
hosts = [v for v in self.hosts_available if v not in hosts_in_zone]
if not hosts:
raise self.skipException("All hosts are already in other zones, "
"so can't add host to aggregate.")
raise self.skipException("All hosts are already in other "
"availability zones, so can't add "
"host to aggregate. \nAggregates list: "
"%s" % aggregates)
host = hosts[0]
self.client.add_host(aggregate['id'], host=host)