Remove mistral from the delete_node workflow

This change removes mistral from the scale_down workflow by managing
the mistral context and calling the required methods directly.

Story: 2007212
Task: 38423

Change-Id: I17c74e8a5f0ed166316e67e9a62966194869df6a
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-02-03 17:00:18 -06:00 committed by Alex Schultz
parent 219dc82d9f
commit 045bd823a8
2 changed files with 33 additions and 58 deletions

View File

@ -47,7 +47,10 @@ class TestDeleteNode(fakes.TestDeleteNode):
self.websocket.__exit__ = lambda s, *exc: None
self.tripleoclient = mock.Mock()
self.tripleoclient.messaging_websocket.return_value = self.websocket
self.app.client_manager.tripleoclient = self.tripleoclient
tc = self.app.client_manager.tripleoclient = self.tripleoclient
tc.create_mistral_context = plugin.ClientWrapper(
instance=ooofakes.FakeInstanceData
).create_mistral_context
self.workflow = self.app.client_manager.workflow_engine
self.stack_name = self.app.client_manager.orchestration.stacks.get
@ -56,6 +59,14 @@ class TestDeleteNode(fakes.TestDeleteNode):
execution.id = "IDID"
self.workflow.executions.create.return_value = execution
delete_node = mock.patch(
'tripleo_common.actions.scale.ScaleDownAction.run',
autospec=True
)
delete_node.start()
delete_node.return_value = None
self.addCleanup(delete_node.stop)
# TODO(someone): This test does not pass with autospec=True, it should
# probably be fixed so that it can pass with that.
def test_node_delete(self):
@ -77,15 +88,6 @@ class TestDeleteNode(fakes.TestDeleteNode):
self.cmd.take_action(parsed_args)
# Verify
self.workflow.executions.create.assert_called_with(
'tripleo.scale.v1.delete_node',
workflow_input={
'plan_name': 'overcast',
'nodes': ['instance1', 'instance2'],
'timeout': 90
})
@mock.patch('tripleoclient.utils.prompt_user_for_confirmation',
return_value=False)
def test_node_delete_no_confirm(self, confirm_mock):
@ -137,15 +139,6 @@ class TestDeleteNode(fakes.TestDeleteNode):
self.cmd.take_action(parsed_args)
# Verify
self.workflow.executions.create.assert_called_with(
'tripleo.scale.v1.delete_node',
workflow_input={
'plan_name': 'overcloud',
'nodes': ['instance1', ],
'timeout': 240
})
def test_node_delete_wrong_instance(self):
argslist = ['wrong_instance', '--templates',
@ -282,18 +275,6 @@ class TestDeleteNode(fakes.TestDeleteNode):
stackname='overcast'
)
])
self.workflow.executions.create.assert_called_with(
'tripleo.scale.v1.delete_node',
workflow_input={
'plan_name': 'overcast',
'nodes': ['aaaa', 'dddd'],
'timeout': 90
})
mock_undeploy_roles.assert_called_once_with(
self.app.client_manager,
roles=bm_yaml,
plan='overcast'
)
@mock.patch('tripleoclient.workflows.baremetal.expand_roles',
autospec=True)

View File

@ -14,6 +14,8 @@
# under the License.
from __future__ import print_function
from tripleo_common.actions import scale
from tripleoclient import exceptions
from tripleoclient.workflows import base
@ -40,35 +42,21 @@ def ansible_tear_down(clients, **workflow_input):
raise exceptions.DeploymentError("Scale-down configuration failed.")
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(
workflow_client,
'tripleo.scale.v1.delete_node',
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 exceptions.InvalidConfiguration(payload['message'])
def scale_down(clients, plan_name, nodes, timeout=None):
"""Unprovision and deletes overcloud nodes from a heat stack.
:param clients: openstack clients
:param plan_name: name of the container holding the plan data
:param nodes: list of node id's to remove from the stack
:param timeout: timeout for stack update operation
:param clients: Application client object.
:type clients: Object
:param timeout: Timeout to use when deleting nodes. If timeout is None
it will be set to 240.
:type timeout: Integer
:param plan: Plan name.
:type plan: String
:param nodes: List of nodes to delete.
:type nodes: List
"""
workflow_input = {
@ -77,4 +65,10 @@ def scale_down(clients, plan_name, nodes, timeout=None):
}
ansible_tear_down(clients, **workflow_input)
delete_node(clients, timeout, **workflow_input)
if not timeout:
timeout = 240
context = clients.tripleoclient.create_mistral_context()
scale_down_action = scale.ScaleDownAction(nodes=nodes, timeout=timeout)
scale_down_action.run(context=context)