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
This commit is contained in:
parent
51a9880702
commit
16326a86c2
@ -65,7 +65,8 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = iter([{
|
self.websocket.wait_for_messages.return_value = iter([{
|
||||||
"execution_id": "IDID",
|
"execution_id": "IDID",
|
||||||
"status": "SUCCESS"
|
"status": "SUCCESS",
|
||||||
|
"message": "Success.",
|
||||||
}])
|
}])
|
||||||
|
|
||||||
self.stack_name.return_value = mock.Mock(stack_name="overcast")
|
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(
|
self.workflow.executions.create.assert_called_with(
|
||||||
'tripleo.scale.v1.delete_node',
|
'tripleo.scale.v1.delete_node',
|
||||||
workflow_input={
|
workflow_input={
|
||||||
'container': 'overcast',
|
'plan_name': 'overcast',
|
||||||
'nodes': ['instance1', 'instance2'],
|
'nodes': ['instance1', 'instance2'],
|
||||||
'timeout': 90
|
'timeout': 90
|
||||||
})
|
})
|
||||||
@ -111,7 +112,8 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = iter([{
|
self.websocket.wait_for_messages.return_value = iter([{
|
||||||
"execution_id": "IDID",
|
"execution_id": "IDID",
|
||||||
"status": "SUCCESS"
|
"status": "SUCCESS",
|
||||||
|
"message": "Success.",
|
||||||
}])
|
}])
|
||||||
|
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
@ -120,7 +122,7 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||||||
self.workflow.executions.create.assert_called_with(
|
self.workflow.executions.create.assert_called_with(
|
||||||
'tripleo.scale.v1.delete_node',
|
'tripleo.scale.v1.delete_node',
|
||||||
workflow_input={
|
workflow_input={
|
||||||
'container': 'overcloud',
|
'plan_name': 'overcloud',
|
||||||
'nodes': ['instance1', ],
|
'nodes': ['instance1', ],
|
||||||
'timeout': 240
|
'timeout': 240
|
||||||
})
|
})
|
||||||
@ -142,17 +144,9 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||||||
following instances in stack overcloud: wrong_instance"""
|
following instances in stack overcloud: wrong_instance"""
|
||||||
}])
|
}])
|
||||||
|
|
||||||
self.assertRaises(exceptions.InvalidConfiguration,
|
|
||||||
self.cmd.take_action, parsed_args)
|
|
||||||
|
|
||||||
# Verify
|
# Verify
|
||||||
self.workflow.executions.create.assert_called_with(
|
self.assertRaises(exceptions.DeploymentError,
|
||||||
'tripleo.scale.v1.ansible_scale_down',
|
self.cmd.take_action, parsed_args)
|
||||||
workflow_input={
|
|
||||||
'container': 'overcloud',
|
|
||||||
'nodes': ['wrong_instance', ],
|
|
||||||
'timeout': 240
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TestProvideNode(fakes.TestOvercloudNode):
|
class TestProvideNode(fakes.TestOvercloudNode):
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from tripleoclient.exceptions import InvalidConfiguration
|
from tripleoclient import exceptions
|
||||||
from tripleoclient.workflows import base
|
from tripleoclient.workflows import base
|
||||||
|
|
||||||
|
|
||||||
@ -22,26 +22,30 @@ def ansible_tear_down(clients, **workflow_input):
|
|||||||
|
|
||||||
workflow_client = clients.workflow_engine
|
workflow_client = clients.workflow_engine
|
||||||
tripleoclients = clients.tripleoclient
|
tripleoclients = clients.tripleoclient
|
||||||
|
workflow_input['playbook_name'] = 'scale_playbook.yaml'
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
with tripleoclients.messaging_websocket() as ws:
|
||||||
execution = base.start_workflow(
|
execution = base.start_workflow(
|
||||||
workflow_client,
|
workflow_client,
|
||||||
'tripleo.scale.v1.ansible_scale_down',
|
'tripleo.deployment.v1.config_download_deploy',
|
||||||
workflow_input=workflow_input
|
workflow_input=workflow_input
|
||||||
)
|
)
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
||||||
status = payload['status']
|
print(payload['message'])
|
||||||
if status == 'RUNNING':
|
|
||||||
continue
|
if payload['status'] == 'SUCCESS':
|
||||||
if status != 'SUCCESS':
|
print("Scale-down configuration completed.")
|
||||||
raise InvalidConfiguration(payload['message'])
|
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
|
workflow_client = clients.workflow_engine
|
||||||
tripleoclients = clients.tripleoclient
|
tripleoclients = clients.tripleoclient
|
||||||
|
if timeout is not None:
|
||||||
|
workflow_input['timeout'] = timeout
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
with tripleoclients.messaging_websocket() as ws:
|
||||||
execution = base.start_workflow(
|
execution = base.start_workflow(
|
||||||
@ -55,7 +59,7 @@ def delete_node(clients, **workflow_input):
|
|||||||
if status == 'RUNNING':
|
if status == 'RUNNING':
|
||||||
continue
|
continue
|
||||||
if status != 'SUCCESS':
|
if status != 'SUCCESS':
|
||||||
raise InvalidConfiguration(payload['message'])
|
raise exceptions.InvalidConfiguration(payload['message'])
|
||||||
|
|
||||||
|
|
||||||
def scale_down(clients, plan_name, nodes, timeout=None):
|
def scale_down(clients, plan_name, nodes, timeout=None):
|
||||||
@ -68,12 +72,9 @@ def scale_down(clients, plan_name, nodes, timeout=None):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
workflow_input = {
|
workflow_input = {
|
||||||
"container": plan_name,
|
"plan_name": plan_name,
|
||||||
"nodes": nodes,
|
"nodes": nodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
if timeout is not None:
|
|
||||||
workflow_input['timeout'] = timeout
|
|
||||||
|
|
||||||
ansible_tear_down(clients, **workflow_input)
|
ansible_tear_down(clients, **workflow_input)
|
||||||
delete_node(clients, **workflow_input)
|
delete_node(clients, timeout, **workflow_input)
|
||||||
|
Loading…
Reference in New Issue
Block a user