workflows/scale: re-use the deployment workbook to run Ansible

To avoid tasks duplications in the tripleo-common workbooks, let's
re-use the deployment workbook with the right parameters so we can avoid
all the config-download tasks.

This patch will reuse tripleo.deployment.v1.config_download_deploy with
the right parameters for a scale-down.

Depends-On: Ibc980e9162bf109de7e7ef338c9bd602174c8448
Change-Id: Ie8e15589197e9725a1cae2d29137f05fefa427c1
changes/52/657552/5
Emilien Macchi 3 years ago
parent 51a9880702
commit 16326a86c2
  1. 22
      tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py
  2. 29
      tripleoclient/workflows/scale.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):

@ -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)

Loading…
Cancel
Save