filters: Stop handling cells v1
Part of blueprint remove-cells-v1 Change-Id: Ie8c934b131df75ad275226d357b8ce5cb9453738
This commit is contained in:
parent
4aa4da8ea8
commit
43dd054685
@ -104,28 +104,20 @@ class BaseFilterHandler(loadables.BaseLoader):
|
||||
{'cls_name': cls_name, 'obj_len': len(list_objs)})
|
||||
if not list_objs:
|
||||
# Log the filtration history
|
||||
# NOTE(sbauza): Since the Cells scheduler still provides a legacy
|
||||
# dictionary for filter_props, and since we agreed on not modifying
|
||||
# the Cells scheduler to support that because of Cells v2, we
|
||||
# prefer to define a compatible way to address both types
|
||||
if isinstance(spec_obj, dict):
|
||||
rspec = spec_obj.get("request_spec", {})
|
||||
inst_props = rspec.get("instance_properties", {})
|
||||
inst_uuid = inst_props.get("uuid", "")
|
||||
else:
|
||||
inst_uuid = spec_obj.instance_uuid
|
||||
msg_dict = {"inst_uuid": inst_uuid,
|
||||
msg_dict = {
|
||||
"inst_uuid": spec_obj.instance_uuid,
|
||||
"str_results": str(full_filter_results),
|
||||
}
|
||||
full_msg = ("Filtering removed all hosts for the request with "
|
||||
"instance ID "
|
||||
"'%(inst_uuid)s'. Filter results: %(str_results)s"
|
||||
) % msg_dict
|
||||
LOG.debug(full_msg)
|
||||
|
||||
msg_dict["str_results"] = str(part_filter_results)
|
||||
part_msg = _LI("Filtering removed all hosts for the request with "
|
||||
part_msg = ("Filtering removed all hosts for the request with "
|
||||
"instance ID "
|
||||
"'%(inst_uuid)s'. Filter results: %(str_results)s"
|
||||
) % msg_dict
|
||||
LOG.debug(full_msg)
|
||||
LOG.info(part_msg)
|
||||
return list_objs
|
||||
|
@ -234,34 +234,3 @@ class FiltersTestCase(test.NoDBTestCase):
|
||||
cargs = mock_log.call_args[0][0]
|
||||
self.assertIn("with instance ID '%s'" % fake_uuid, cargs)
|
||||
self.assertIn(exp_output, cargs)
|
||||
|
||||
def test_get_filtered_objects_compatible_with_filt_props_dicts(self):
|
||||
LOG = filters.LOG
|
||||
|
||||
class FilterA(filters.BaseFilter):
|
||||
def filter_all(self, list_objs, spec_obj):
|
||||
# return all but the first object
|
||||
return list_objs[1:]
|
||||
|
||||
class FilterB(filters.BaseFilter):
|
||||
def filter_all(self, list_objs, spec_obj):
|
||||
# return an empty list
|
||||
return []
|
||||
|
||||
filter_a = FilterA()
|
||||
filter_b = FilterB()
|
||||
all_filters = [filter_a, filter_b]
|
||||
hosts = ["Host0", "Host1", "Host2"]
|
||||
fake_uuid = uuids.instance
|
||||
filt_props = {"request_spec": {"instance_properties": {
|
||||
"uuid": fake_uuid}}}
|
||||
with mock.patch.object(LOG, "info") as mock_log:
|
||||
result = self.filter_handler.get_filtered_objects(
|
||||
all_filters, hosts, filt_props)
|
||||
self.assertFalse(result)
|
||||
# FilterA should leave Host1 and Host2; FilterB should leave None.
|
||||
exp_output = ("['FilterA: (start: 3, end: 2)', "
|
||||
"'FilterB: (start: 2, end: 0)']")
|
||||
cargs = mock_log.call_args[0][0]
|
||||
self.assertIn("with instance ID '%s'" % fake_uuid, cargs)
|
||||
self.assertIn(exp_output, cargs)
|
||||
|
Loading…
Reference in New Issue
Block a user