Browse Source

Merge "Remove mistral from the delete_node workflow"

tags/13.1.0
Zuul Gerrit Code Review 2 weeks ago
parent
commit
8ef069008d
2 changed files with 32 additions and 57 deletions
  1. +12
    -31
      tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py
  2. +20
    -26
      tripleoclient/workflows/scale.py

+ 12
- 31
tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py 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)


+ 20
- 26
tripleoclient/workflows/scale.py 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
)
def scale_down(clients, plan_name, nodes, timeout=None):
"""Unprovision and deletes overcloud nodes from a heat stack.

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'])
: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

def scale_down(clients, plan_name, nodes, timeout=None):
"""Unprovision and deletes overcloud nodes from a heat stack.
:param plan: Plan name.
:type plan: String

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

Loading…
Cancel
Save