diff --git a/watcher/api/controllers/v1/action_plan.py b/watcher/api/controllers/v1/action_plan.py index 652bf6848..8ece4105c 100644 --- a/watcher/api/controllers/v1/action_plan.py +++ b/watcher/api/controllers/v1/action_plan.py @@ -386,7 +386,8 @@ class ActionPlansController(rest.RestController): if action_plan_to_update[field] != patch_val: action_plan_to_update[field] = patch_val - if field == 'state' and patch_val == 'STARTING': + if (field == 'state' + and patch_val == objects.action_plan.State.TRIGGERED): launch_action_plan = True action_plan_to_update.save() diff --git a/watcher/objects/action_plan.py b/watcher/objects/action_plan.py index 395fa826a..e780ffe79 100644 --- a/watcher/objects/action_plan.py +++ b/watcher/objects/action_plan.py @@ -77,6 +77,7 @@ from watcher.objects import utils as obj_utils class State(object): RECOMMENDED = 'RECOMMENDED' + TRIGGERED = 'TRIGGERED' ONGOING = 'ONGOING' FAILED = 'FAILED' SUCCEEDED = 'SUCCEEDED' diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index 3d55491b2..24183d6d2 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -419,7 +419,7 @@ class TestPatch(api_base.FunctionalTest): def test_replace_ok_state_starting(self): with mock.patch.object(aapi.ApplierAPI, 'launch_action_plan') as applier_mock: - new_state = 'STARTING' + new_state = objects.action_plan.State.TRIGGERED response = self.get_json( '/action_plans/%s' % self.action_plan.uuid) self.assertNotEqual(new_state, response['state']) diff --git a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py index 88408edba..10d969435 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py +++ b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py @@ -80,10 +80,10 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest): _, action_plan = self.client.show_action_plan(action_plan['uuid']) - # Execute the action by changing its state to STARTING + # Execute the action by changing its state to TRIGGERED _, updated_ap = self.client.update_action_plan( action_plan['uuid'], - patch=[{'path': '/state', 'op': 'replace', 'value': 'STARTING'}] + patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}] ) self.assertTrue(test.call_until_true( @@ -94,7 +94,7 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest): )) _, finished_ap = self.client.show_action_plan(action_plan['uuid']) - self.assertIn(updated_ap['state'], ('STARTING', 'ONGOING')) + self.assertIn(updated_ap['state'], ('TRIGGERED', 'ONGOING')) self.assertEqual(finished_ap['state'], 'SUCCEEDED') diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py index 46ba6b345..8d3dd319b 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py @@ -49,10 +49,10 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest): _, action_plan = self.client.show_action_plan(action_plan['uuid']) - # Execute the action by changing its state to STARTING + # Execute the action by changing its state to TRIGGERED _, updated_ap = self.client.update_action_plan( action_plan['uuid'], - patch=[{'path': '/state', 'op': 'replace', 'value': 'STARTING'}] + patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}] ) def has_finished(action_plan_uuid): @@ -65,5 +65,5 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest): )) _, finished_ap = self.client.show_action_plan(action_plan['uuid']) - self.assertIn(updated_ap['state'], ('STARTING', 'ONGOING')) + self.assertIn(updated_ap['state'], ('TRIGGERED', 'ONGOING')) self.assertEqual(finished_ap['state'], 'SUCCEEDED')