From 880806936f7fe6653f7e8781dede69e81edb4324 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 15 Nov 2012 18:08:07 +0000 Subject: [PATCH] Cells: Add filtering and weight support This adds filtering and weighing support to the cells scheduler. Adds the following config options to the 'cells' group: scheduler_filter_classes -- list of filter classes scheduler_weight_classes -- list of weight classes Adds a couple of weighing modules as defaults (which removes the random cell selection): ram_by_instance_type: Select cells with the most capacity for the instance type being requested. weight_offset: Allows modifying the DB to weight a particular cell (useful for disabling a cell) Adds a filter class (TargetCellFilter) that allows specifying a scheduler hint to direct a build to a particular cell if you're an admin. DocImpact Implements blueprint cells-filter-scheduler Change-Id: I027c5734e3d6134127fcd4dd28b8ff39047416dc --- nova/tests/test_filters.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/nova/tests/test_filters.py b/nova/tests/test_filters.py index 3940ce0c..c06b50fd 100644 --- a/nova/tests/test_filters.py +++ b/nova/tests/test_filters.py @@ -123,3 +123,36 @@ class FiltersTestCase(test.TestCase): filter_objs_initial, filter_properties) self.assertEqual(filter_objs_last, result) + + def test_get_filtered_objects_none_response(self): + filter_objs_initial = ['initial', 'filter1', 'objects1'] + filter_properties = 'fake_filter_properties' + + def _fake_base_loader_init(*args, **kwargs): + pass + + self.stubs.Set(loadables.BaseLoader, '__init__', + _fake_base_loader_init) + + filt1_mock = self.mox.CreateMock(Filter1) + filt2_mock = self.mox.CreateMock(Filter2) + + self.mox.StubOutWithMock(sys.modules[__name__], 'Filter1', + use_mock_anything=True) + self.mox.StubOutWithMock(filt1_mock, 'filter_all') + # Shouldn't be called. + self.mox.StubOutWithMock(sys.modules[__name__], 'Filter2', + use_mock_anything=True) + self.mox.StubOutWithMock(filt2_mock, 'filter_all') + + Filter1().AndReturn(filt1_mock) + filt1_mock.filter_all(filter_objs_initial, + filter_properties).AndReturn(None) + self.mox.ReplayAll() + + filter_handler = filters.BaseFilterHandler(filters.BaseFilter) + filter_classes = [Filter1, Filter2] + result = filter_handler.get_filtered_objects(filter_classes, + filter_objs_initial, + filter_properties) + self.assertEqual(None, result)