Merge "Set strategy planner"

This commit is contained in:
Zuul 2019-09-19 02:25:22 +00:00 committed by Gerrit Code Review
commit 511a24e011
2 changed files with 13 additions and 1 deletions

View File

@ -250,7 +250,8 @@ class NodeResourceConsolidation(base.ServerConsolidationBaseStrategy):
def pre_execute(self):
self._pre_execute()
self.host_choice = self.input_parameters.host_choice
self.host_choice = self.input_parameters.get('host_choice', 'auto')
self.planner = 'node_resource_consolidation'
def do_execute(self, audit=None):
"""Strategy execution phase

View File

@ -34,6 +34,17 @@ class TestNodeResourceConsolidation(TestBaseStrategy):
config=mock.Mock())
self.model = self.fake_c_cluster.generate_scenario_10()
self.m_c_model.return_value = self.model
self.strategy.input_parameters = {'host_choice': 'auto'}
def test_pre_execute(self):
planner = 'node_resource_consolidation'
self.assertEqual('auto', self.strategy.host_choice)
self.assertNotEqual(planner, self.strategy.planner)
self.strategy.input_parameters.update(
{'host_choice': 'specify'})
self.strategy.pre_execute()
self.assertEqual(planner, self.strategy.planner)
self.assertEqual('specify', self.strategy.host_choice)
def test_check_resources(self):
instance = [self.model.get_instance_by_uuid(