From e0024580d2360d84486a7387df82c2f6a4d3de37 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 8 Jul 2013 08:55:19 -0400 Subject: [PATCH] Don't ignore 'capabilities' flavor extra_spec The ComputeCapabilitiesFilter would improperly ignore an extra spec of 'capabilities' since it matched the scope name. When it's not scoped, it should be treated as an unscoped extra_spec. Fix bug 1198941. Change-Id: I781754ae0cb9b2a9f7e7e973f4531f2a99a98d86 --- nova/scheduler/filters/compute_capabilities_filter.py | 9 +++++---- nova/tests/scheduler/test_host_filters.py | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nova/scheduler/filters/compute_capabilities_filter.py b/nova/scheduler/filters/compute_capabilities_filter.py index 36629435c928..770ebbdb30cc 100644 --- a/nova/scheduler/filters/compute_capabilities_filter.py +++ b/nova/scheduler/filters/compute_capabilities_filter.py @@ -34,10 +34,11 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter): for key, req in instance_type['extra_specs'].iteritems(): # Either not scope format, or in capabilities scope scope = key.split(':') - if len(scope) > 1 and scope[0] != "capabilities": - continue - elif scope[0] == "capabilities": - del scope[0] + if len(scope) > 1: + if scope[0] != "capabilities": + continue + else: + del scope[0] cap = capabilities for index in range(0, len(scope)): try: diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index 3d674a4f33d3..8d081a2b93ee 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -795,6 +795,13 @@ class HostFiltersTestCase(test.NoDBTestCase): 'trust:trusted_host': 'true'}, passes=True) + def test_compute_filter_pass_extra_specs_same_as_scope(self): + # Make sure this still works even if the key is the same as the scope + self._do_test_compute_filter_extra_specs( + ecaps={'capabilities': 1}, + especs={'capabilities': '1'}, + passes=True) + def test_compute_filter_extra_specs_simple_with_wrong_scope(self): self._do_test_compute_filter_extra_specs( ecaps={'opt1': 1, 'opt2': 2},