Fix delete plan
This change fixes the delete plan function which was building context incorrectly and raising a soon to be irrelevant exception in the event of a failure. Change-Id: I063cecaeb89b7103938fd9545c5fb976e7e17e95 Closes-Bug: #1866247 Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
3c7a14d668
commit
31e631e950
|
@ -65,14 +65,12 @@ class TestOvercloudPlanList(utils.TestCommand):
|
|||
self.assertEqual([('test-plan-1',), ('test-plan-2',)], result[1])
|
||||
|
||||
|
||||
class TestOvercloudDeletePlan(utils.TestCommand):
|
||||
class TestOvercloudDeletePlan(fakes.FakePlaybookExecution):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOvercloudDeletePlan, self).setUp()
|
||||
|
||||
self.cmd = overcloud_plan.DeletePlan(self.app, None)
|
||||
self.context = mock.Mock()
|
||||
self.app.client_manager.create_mistral_context = self.context
|
||||
|
||||
@mock.patch("tripleo_common.actions.plan.DeletePlanAction.run",
|
||||
return_value=None)
|
||||
|
@ -82,8 +80,6 @@ class TestOvercloudDeletePlan(utils.TestCommand):
|
|||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run.assert_called_once_with(self.context())
|
||||
|
||||
@mock.patch("tripleo_common.actions.plan.DeletePlanAction.run",
|
||||
return_value=None)
|
||||
def test_delete_multiple_plans(self, mock_run):
|
||||
|
@ -93,9 +89,6 @@ class TestOvercloudDeletePlan(utils.TestCommand):
|
|||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run.assert_has_calls([
|
||||
mock.call(self.context()), mock.call(self.context())])
|
||||
|
||||
|
||||
class TestOvercloudCreatePlan(utils.TestCommand):
|
||||
|
||||
|
|
|
@ -94,12 +94,20 @@ def create_deployment_plan(clients, **workflow_input):
|
|||
|
||||
|
||||
def delete_deployment_plan(clients, container):
|
||||
mistral_context = clients.create_mistral_context()
|
||||
result = plan.DeletePlanAction(container=container).run(mistral_context)
|
||||
"""Delete a deployment plan.
|
||||
|
||||
:param clients: Application client object.
|
||||
:type clients: Object
|
||||
|
||||
:param container: Container name to pull from.
|
||||
:type container: String
|
||||
"""
|
||||
|
||||
context = clients.tripleoclient.create_mistral_context()
|
||||
result = plan.DeletePlanAction(container=container).run(context=context)
|
||||
# The action returns None if there are no errors.
|
||||
if result and result.error:
|
||||
raise exceptions.WorkflowServiceError(
|
||||
'Exception deleting plan: {}'.format(result.error))
|
||||
if result:
|
||||
raise RuntimeError(result)
|
||||
|
||||
|
||||
def update_deployment_plan(clients, **workflow_input):
|
||||
|
|
Loading…
Reference in New Issue