From e3ca09d478cd72781f3a7fbfb7aa9ca71b9a7583 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 11 May 2016 08:07:33 -0500 Subject: [PATCH] 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 --- rally/plugins/openstack/scenarios/nova/utils.py | 2 +- tests/unit/plugins/openstack/scenarios/nova/test_utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 53ab7514..a1b1a1ed 100644 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -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( diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index 35ef41bc..e8630804 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -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})