diff --git a/nova/scheduler/utils.py b/nova/scheduler/utils.py index 00f8ec20b6cd..dd3eaf203195 100644 --- a/nova/scheduler/utils.py +++ b/nova/scheduler/utils.py @@ -815,20 +815,18 @@ def build_filter_properties(scheduler_hints, forced_host, def populate_filter_properties(filter_properties, selection): """Add additional information to the filter properties after a node has been selected by the scheduling process. + + :param filter_properties: dict of filter properties (the legacy form of + the RequestSpec) + :param selection: Selection object """ - if isinstance(selection, dict): - # TODO(edleafe): remove support for dicts - host = selection['host'] - nodename = selection['nodename'] - limits = selection['limits'] + host = selection.service_host + nodename = selection.nodename + # Need to convert SchedulerLimits object to older dict format. + if "limits" in selection and selection.limits is not None: + limits = selection.limits.to_dict() else: - host = selection.service_host - nodename = selection.nodename - # Need to convert SchedulerLimits object to older dict format. - if "limits" in selection and selection.limits is not None: - limits = selection.limits.to_dict() - else: - limits = {} + limits = {} # Adds a retry entry for the selected compute host and node: _add_retry_host(filter_properties, host, nodename) diff --git a/nova/tests/unit/scheduler/test_scheduler_utils.py b/nova/tests/unit/scheduler/test_scheduler_utils.py index afbcab480c35..651acfbf2983 100644 --- a/nova/tests/unit/scheduler/test_scheduler_utils.py +++ b/nova/tests/unit/scheduler/test_scheduler_utils.py @@ -153,7 +153,7 @@ class SchedulerUtilsTestCase(test.NoDBTestCase): self.assertNotIn('forced_host', filt_props) self.assertNotIn('forced_node', filt_props) - def _test_populate_filter_props(self, selection_obj=True, + def _test_populate_filter_props(self, with_retry=True, force_hosts=None, force_nodes=None, @@ -183,9 +183,6 @@ class SchedulerUtilsTestCase(test.NoDBTestCase): memory_mb=3, numa_topology=None) selection = objects.Selection(service_host="fake-host", nodename="fake-node", limits=fake_limits) - if not selection_obj: - selection = selection.to_dict() - fake_limits = fake_limits.to_dict() scheduler_utils.populate_filter_properties(filter_properties, selection) @@ -219,9 +216,6 @@ class SchedulerUtilsTestCase(test.NoDBTestCase): def test_populate_filter_props(self): self._test_populate_filter_props() - def test_populate_filter_props_host_dict(self): - self._test_populate_filter_props(selection_obj=False) - def test_populate_filter_props_no_retry(self): self._test_populate_filter_props(with_retry=False)