Merge "Aggregate Extra Specs Filter should return if extra_specs is empty"
This commit is contained in:
commit
a334ea49d4
@ -40,7 +40,9 @@ class AggregateInstanceExtraSpecsFilter(filters.BaseHostFilter):
|
||||
the metadata provided by aggregates. If not present return False.
|
||||
"""
|
||||
instance_type = filter_properties.get('instance_type')
|
||||
if 'extra_specs' not in instance_type:
|
||||
# If 'extra_specs' is not present or extra_specs are empty then we
|
||||
# need not proceed further
|
||||
if not instance_type.get('extra_specs'):
|
||||
return True
|
||||
|
||||
metadata = utils.aggregate_metadata_get_by_host(host_state)
|
||||
|
@ -33,6 +33,15 @@ class TestAggregateInstanceExtraSpecsFilter(test.NoDBTestCase):
|
||||
self.assertTrue(self.filt_cls.host_passes(host, filter_properties))
|
||||
self.assertFalse(agg_mock.called)
|
||||
|
||||
def test_aggregate_filter_passes_empty_extra_specs(self, agg_mock):
|
||||
capabilities = {'opt1': 1, 'opt2': 2}
|
||||
|
||||
filter_properties = {'context': mock.sentinel.ctx, 'instance_type':
|
||||
{'memory_mb': 1024, 'extra_specs': {}}}
|
||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||
self.assertTrue(self.filt_cls.host_passes(host, filter_properties))
|
||||
self.assertFalse(agg_mock.called)
|
||||
|
||||
def _do_test_aggregate_filter_extra_specs(self, especs, passes):
|
||||
filter_properties = {'context': mock.sentinel.ctx,
|
||||
'instance_type': {'memory_mb': 1024, 'extra_specs': especs}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user