From bb72623e8c36936a37f6495e6c9f253b9a7f5aa7 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Tue, 4 Oct 2016 13:13:42 +0100 Subject: [PATCH] Save the result of direct action calls in Mistral Mistral now allows us to run actions synchronously and have the result be saved. This is useful for audit purposes as direct action calls will now show up in `mistal action-execution-list`. Closes-Bug: #1631281 Depends-On: I00c6301394512e123436ca6c5650827c2475308e Change-Id: I4d5167d5fea5e75ae7246d1e92537489fc9a6f1e --- tripleoclient/tests/v1/test_overcloud_parameters.py | 3 ++- tripleoclient/tests/v1/test_overcloud_plan.py | 6 ++++-- tripleoclient/tests/workflows/test_plan_management.py | 9 ++++++--- tripleoclient/workflows/base.py | 4 +++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tripleoclient/tests/v1/test_overcloud_parameters.py b/tripleoclient/tests/v1/test_overcloud_parameters.py index 52399d2ba..7a7998f2f 100644 --- a/tripleoclient/tests/v1/test_overcloud_parameters.py +++ b/tripleoclient/tests/v1/test_overcloud_parameters.py @@ -61,7 +61,8 @@ class TestSetParameters(utils.TestCommand): { 'container': 'overcast', 'parameters': data.get('parameter_defaults', data) - }) + }, + run_sync=True, save_result=True) def test_json_params_file(self): self._test_set_parameters(".json", json.dumps, { diff --git a/tripleoclient/tests/v1/test_overcloud_plan.py b/tripleoclient/tests/v1/test_overcloud_plan.py index 9a7dd2f30..237cf2e68 100644 --- a/tripleoclient/tests/v1/test_overcloud_plan.py +++ b/tripleoclient/tests/v1/test_overcloud_plan.py @@ -183,7 +183,8 @@ class TestOvercloudCreatePlan(utils.TestCommand): # Verify self.workflow.action_executions.create.assert_called_once_with( - 'tripleo.plan.create_container', {"container": "overcast"} + 'tripleo.plan.create_container', {"container": "overcast"}, + run_sync=True, save_result=True ) self.workflow.executions.create.assert_called_once_with( @@ -216,7 +217,8 @@ class TestOvercloudCreatePlan(utils.TestCommand): # Verify self.workflow.action_executions.create.assert_called_once_with( - 'tripleo.plan.create_container', {"container": "overcast"} + 'tripleo.plan.create_container', {"container": "overcast"}, + run_sync=True, save_result=True ) self.workflow.executions.create.assert_called_once_with( diff --git a/tripleoclient/tests/workflows/test_plan_management.py b/tripleoclient/tests/workflows/test_plan_management.py index 83e026cde..5cfd8878f 100644 --- a/tripleoclient/tests/workflows/test_plan_management.py +++ b/tripleoclient/tests/workflows/test_plan_management.py @@ -52,7 +52,8 @@ class TestPlanCreationWorkflows(utils.TestCommand): self.workflow.action_executions.create.assert_called_once_with( 'tripleo.plan.create_container', - {'container': 'test-overcloud'}) + {'container': 'test-overcloud'}, + run_sync=True, save_result=True) self.workflow.executions.create.assert_called_once_with( 'tripleo.plan_management.v1.create_deployment_plan', @@ -74,7 +75,8 @@ class TestPlanCreationWorkflows(utils.TestCommand): self.workflow.action_executions.create.assert_called_once_with( 'tripleo.plan.create_container', - {'container': 'test-overcloud'}) + {'container': 'test-overcloud'}, + run_sync=True, save_result=True) self.workflow.executions.create.assert_not_called() @@ -97,7 +99,8 @@ class TestPlanCreationWorkflows(utils.TestCommand): self.workflow.action_executions.create.assert_called_once_with( 'tripleo.plan.create_container', - {'container': 'test-overcloud'}) + {'container': 'test-overcloud'}, + run_sync=True, save_result=True) self.workflow.executions.create.assert_called_once_with( 'tripleo.plan_management.v1.create_deployment_plan', diff --git a/tripleoclient/workflows/base.py b/tripleoclient/workflows/base.py index 522bfb886..c40b65f55 100644 --- a/tripleoclient/workflows/base.py +++ b/tripleoclient/workflows/base.py @@ -15,7 +15,9 @@ import json def call_action(workflow_client, action, **input_): """Trigger a Mistral action and parse the JSON response""" - result = workflow_client.action_executions.create(action, input_) + result = workflow_client.action_executions.create( + action, input_, + save_result=True, run_sync=True) # Parse the JSON output. Mistral client should do this for us really. return json.loads(result.output)['result']