Support single-AZ deployment

This supports the case where OpenStack is deployed with a single AZ
for both controller(s) and compute(s), and not all hosts in the AZ
that contains an instance are guaranteed to have the nova-compute
service.

Change-Id: If5a8bd0df863b94f3c3e7117df4586dbc56f48bc
This commit is contained in:
Chris St. Pierre 2016-05-11 08:07:33 -05:00
parent a801003308
commit e3ca09d478
2 changed files with 5 additions and 2 deletions

View File

@ -752,7 +752,7 @@ class NovaScenario(scenario.OpenStackScenario):
new_host = random.choice(
[key for key, value in six.iteritems(az.hosts)
if key != host and
value["nova-compute"]["available"] is True])
value.get("nova-compute", {}).get("available", False)])
return new_host
except IndexError:
raise exceptions.InvalidHostException(

View File

@ -633,6 +633,8 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
def test__find_host_to_migrate(self):
fake_server = self.server
fake_host = {"nova-compute": {"available": True}}
fake_host_compute_off = {"nova-compute": {"available": False}}
fake_host_no_compute = {"nova-conductor": {"available": True}}
self.admin_clients("nova").servers.get.return_value = fake_server
self.admin_clients("nova").availability_zones.list.return_value = [
mock.MagicMock(zoneName="a",
@ -640,7 +642,8 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
"a3": fake_host}),
mock.MagicMock(zoneName="b",
hosts={"b1": fake_host, "b2": fake_host,
"b3": fake_host}),
"b3": fake_host, "b4": fake_host_compute_off,
"b5": fake_host_no_compute}),
mock.MagicMock(zoneName="c",
hosts={"c1": fake_host,
"c2": fake_host, "c3": fake_host})