diff --git a/watcher/decision_engine/solution/default.py b/watcher/decision_engine/solution/default.py index a64950cb5..8c0381628 100644 --- a/watcher/decision_engine/solution/default.py +++ b/watcher/decision_engine/solution/default.py @@ -41,6 +41,9 @@ class DefaultSolution(base.BaseSolution): if baction.BaseAction.RESOURCE_ID in input_parameters.keys(): raise exception.ReservedWord(name=baction.BaseAction. RESOURCE_ID) + else: + input_parameters = {} + if resource_id is not None: input_parameters[baction.BaseAction.RESOURCE_ID] = resource_id action = { diff --git a/watcher/tests/decision_engine/solution/test_default_solution.py b/watcher/tests/decision_engine/solution/test_default_solution.py index 642ba6d9e..c0fc8393b 100644 --- a/watcher/tests/decision_engine/solution/test_default_solution.py +++ b/watcher/tests/decision_engine/solution/test_default_solution.py @@ -43,3 +43,18 @@ class TestDefaultSolution(base.TestCase): solution.actions[0].get('action_type')) self.assertEqual(expected_parameters, solution.actions[0].get('input_parameters')) + + def test_default_solution_with_no_input_parameters(self): + solution = default.DefaultSolution( + goal=mock.Mock(), strategy=mock.Mock()) + solution.add_action(action_type="nop", + resource_id="b199db0c-1408-4d52-b5a5-5ca14de0ff36") + self.assertEqual(1, len(solution.actions)) + expected_action_type = "nop" + expected_parameters = { + "resource_id": "b199db0c-1408-4d52-b5a5-5ca14de0ff36" + } + self.assertEqual(expected_action_type, + solution.actions[0].get('action_type')) + self.assertEqual(expected_parameters, + solution.actions[0].get('input_parameters'))