diff --git a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py index 43964a276..c2fc52a23 100644 --- a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py +++ b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py @@ -65,7 +65,8 @@ class TestDeleteNode(fakes.TestDeleteNode): self.websocket.wait_for_messages.return_value = iter([{ "execution_id": "IDID", - "status": "SUCCESS" + "status": "SUCCESS", + "message": "Success.", }]) self.stack_name.return_value = mock.Mock(stack_name="overcast") @@ -76,7 +77,7 @@ class TestDeleteNode(fakes.TestDeleteNode): self.workflow.executions.create.assert_called_with( 'tripleo.scale.v1.delete_node', workflow_input={ - 'container': 'overcast', + 'plan_name': 'overcast', 'nodes': ['instance1', 'instance2'], 'timeout': 90 }) @@ -111,7 +112,8 @@ class TestDeleteNode(fakes.TestDeleteNode): self.websocket.wait_for_messages.return_value = iter([{ "execution_id": "IDID", - "status": "SUCCESS" + "status": "SUCCESS", + "message": "Success.", }]) self.cmd.take_action(parsed_args) @@ -120,7 +122,7 @@ class TestDeleteNode(fakes.TestDeleteNode): self.workflow.executions.create.assert_called_with( 'tripleo.scale.v1.delete_node', workflow_input={ - 'container': 'overcloud', + 'plan_name': 'overcloud', 'nodes': ['instance1', ], 'timeout': 240 }) @@ -142,17 +144,9 @@ class TestDeleteNode(fakes.TestDeleteNode): following instances in stack overcloud: wrong_instance""" }]) - self.assertRaises(exceptions.InvalidConfiguration, - self.cmd.take_action, parsed_args) - # Verify - self.workflow.executions.create.assert_called_with( - 'tripleo.scale.v1.ansible_scale_down', - workflow_input={ - 'container': 'overcloud', - 'nodes': ['wrong_instance', ], - 'timeout': 240 - }) + self.assertRaises(exceptions.DeploymentError, + self.cmd.take_action, parsed_args) class TestProvideNode(fakes.TestOvercloudNode): diff --git a/tripleoclient/workflows/scale.py b/tripleoclient/workflows/scale.py index 2208321b9..78a1745ff 100644 --- a/tripleoclient/workflows/scale.py +++ b/tripleoclient/workflows/scale.py @@ -14,7 +14,7 @@ # under the License. from __future__ import print_function -from tripleoclient.exceptions import InvalidConfiguration +from tripleoclient import exceptions from tripleoclient.workflows import base @@ -22,26 +22,30 @@ def ansible_tear_down(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient + workflow_input['playbook_name'] = 'scale_playbook.yaml' with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, - 'tripleo.scale.v1.ansible_scale_down', + 'tripleo.deployment.v1.config_download_deploy', workflow_input=workflow_input ) for payload in base.wait_for_messages(workflow_client, ws, execution): - status = payload['status'] - if status == 'RUNNING': - continue - if status != 'SUCCESS': - raise InvalidConfiguration(payload['message']) + print(payload['message']) + + if payload['status'] == 'SUCCESS': + print("Scale-down configuration completed.") + else: + raise exceptions.DeploymentError("Scale-down configuration failed.") -def delete_node(clients, **workflow_input): +def delete_node(clients, timeout, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient + if timeout is not None: + workflow_input['timeout'] = timeout with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( @@ -55,7 +59,7 @@ def delete_node(clients, **workflow_input): if status == 'RUNNING': continue if status != 'SUCCESS': - raise InvalidConfiguration(payload['message']) + raise exceptions.InvalidConfiguration(payload['message']) def scale_down(clients, plan_name, nodes, timeout=None): @@ -68,12 +72,9 @@ def scale_down(clients, plan_name, nodes, timeout=None): """ workflow_input = { - "container": plan_name, + "plan_name": plan_name, "nodes": nodes, } - if timeout is not None: - workflow_input['timeout'] = timeout - ansible_tear_down(clients, **workflow_input) - delete_node(clients, **workflow_input) + delete_node(clients, timeout, **workflow_input)