Set strategy planner

The default planner can not create actions with right order,
The node_resouce_consolidation strategy needs to use its
own planner.
Partially Implements: blueprint node-resource-consolidation
Depends-on: I586e67f782e2965234826634ba3ff51681af4df8
Change-Id: I05b02905a3335a73b6926966de6331c632842293
This commit is contained in:
licanwei 2019-09-17 02:15:45 -07:00
parent 62020cac30
commit 0559cd7a04
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(