Change the overcloud delete command to use undeploy_plan
We don't have a CLI command to properly undeploy the overcloud.
There is a workflow for it, and the GUI uses the right workflow,
but the CLI doesn't support it yet.
Updating "openstack overcloud delete" command to call the proper workflow
Added a release note because this is not a backwards compatible change
Change-Id: If14a7876445b052cd255cdd5142ff400a815ace9
Closes-Bug: #1802102
(cherry picked from commit 2ac2e9b57d
)
This commit is contained in:
parent
3659cb71af
commit
b64127a01e
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
openstack overcloud delete PLAN_NAME now instead of deleting the stack and
|
||||||
|
the plan instead it undeploys the plan to maintain the correct status
|
||||||
|
internally and deletes the stack. This is a backwards incompatible change
|
||||||
|
because we are no longer deleting the plan as it was done previously.
|
|
@ -29,28 +29,51 @@ class TestDeleteOvercloud(fakes.TestDeployOvercloud):
|
||||||
self.workflow = self.app.client_manager.workflow_engine
|
self.workflow = self.app.client_manager.workflow_engine
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'tripleoclient.workflows.stack_management.delete_stack', autospec=True)
|
'tripleoclient.workflows.stack_management.plan_undeploy',
|
||||||
def test_stack_delete(self, mock_delete_stack):
|
autospec=True)
|
||||||
|
def test_plan_undeploy(self, mock_plan_undeploy):
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
orchestration_client = clients.orchestration
|
orchestration_client = clients.orchestration
|
||||||
|
|
||||||
stack = mock.Mock()
|
stack = mock.Mock()
|
||||||
stack.id = 12345
|
stack.id = 12345
|
||||||
|
stack.name = "foobar"
|
||||||
orchestration_client.stacks.get.return_value = stack
|
orchestration_client.stacks.get.return_value = stack
|
||||||
|
|
||||||
self.cmd._stack_delete(clients, 'overcloud')
|
self.cmd._plan_undeploy(clients, 'overcloud')
|
||||||
|
|
||||||
orchestration_client.stacks.get.assert_called_once_with('overcloud')
|
orchestration_client.stacks.get.assert_called_once_with('overcloud')
|
||||||
mock_delete_stack.assert_called_once_with(
|
mock_plan_undeploy.assert_called_once_with(
|
||||||
clients, stack=12345)
|
clients, plan="foobar")
|
||||||
|
|
||||||
def test_stack_delete_no_stack(self):
|
@mock.patch(
|
||||||
|
'tripleoclient.workflows.stack_management.base.start_workflow',
|
||||||
|
autospec=True)
|
||||||
|
def test_plan_undeploy_wf_params(self, mock_plan_undeploy_wf):
|
||||||
|
clients = self.app.client_manager
|
||||||
|
orchestration_client = clients.orchestration
|
||||||
|
workflow_engine = clients.workflow_engine
|
||||||
|
|
||||||
|
stack = mock.Mock()
|
||||||
|
stack.id = 12345
|
||||||
|
stack.name = "foobar"
|
||||||
|
orchestration_client.stacks.get.return_value = stack
|
||||||
|
|
||||||
|
self.cmd._plan_undeploy(clients, 'overcloud')
|
||||||
|
|
||||||
|
orchestration_client.stacks.get.assert_called_once_with('overcloud')
|
||||||
|
mock_plan_undeploy_wf.assert_called_once_with(
|
||||||
|
workflow_engine,
|
||||||
|
"tripleo.deployment.v1.undeploy_plan",
|
||||||
|
workflow_input={"container": "foobar"})
|
||||||
|
|
||||||
|
def test_plan_undeploy_no_stack(self):
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
orchestration_client = clients.orchestration
|
orchestration_client = clients.orchestration
|
||||||
type(orchestration_client.stacks.get).return_value = None
|
type(orchestration_client.stacks.get).return_value = None
|
||||||
self.cmd.log.warning = mock.MagicMock()
|
self.cmd.log.warning = mock.MagicMock()
|
||||||
|
|
||||||
self.cmd._stack_delete(clients, 'overcloud')
|
self.cmd._plan_undeploy(clients, 'overcloud')
|
||||||
|
|
||||||
orchestration_client.stacks.get.assert_called_once_with('overcloud')
|
orchestration_client.stacks.get.assert_called_once_with('overcloud')
|
||||||
self.cmd.log.warning.assert_called_once_with(
|
self.cmd.log.warning.assert_called_once_with(
|
||||||
|
|
|
@ -47,19 +47,19 @@ class DeleteOvercloud(command.Command):
|
||||||
raise oscexc.CommandError(
|
raise oscexc.CommandError(
|
||||||
"You must specify a stack name")
|
"You must specify a stack name")
|
||||||
|
|
||||||
def _stack_delete(self, clients, stack_name):
|
def _plan_undeploy(self, clients, stack_name):
|
||||||
orchestration_client = clients.orchestration
|
orchestration_client = clients.orchestration
|
||||||
|
|
||||||
print("Deleting stack {s}...".format(s=stack_name))
|
print("Undeploying stack {s}...".format(s=stack_name))
|
||||||
stack = utils.get_stack(orchestration_client, stack_name)
|
stack = utils.get_stack(orchestration_client, stack_name)
|
||||||
if stack is None:
|
if stack is None:
|
||||||
self.log.warning("No stack found ('{s}'), skipping delete".
|
self.log.warning("No stack found ('{s}'), skipping delete".
|
||||||
format(s=stack_name))
|
format(s=stack_name))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
stack_management.delete_stack(
|
stack_management.plan_undeploy(
|
||||||
clients,
|
clients,
|
||||||
stack=stack.id
|
plan=stack.name
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise oscexc.CommandError(
|
raise oscexc.CommandError(
|
||||||
|
@ -91,6 +91,6 @@ class DeleteOvercloud(command.Command):
|
||||||
|
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
|
|
||||||
self._stack_delete(clients, parsed_args.stack)
|
self._plan_undeploy(clients, parsed_args.stack)
|
||||||
self._plan_delete(clients, parsed_args.stack)
|
self._plan_delete(clients, parsed_args.stack)
|
||||||
print("Success.")
|
print("Success.")
|
||||||
|
|
|
@ -18,24 +18,24 @@ from tripleoclient.exceptions import InvalidConfiguration
|
||||||
from tripleoclient.workflows import base
|
from tripleoclient.workflows import base
|
||||||
|
|
||||||
|
|
||||||
def delete_stack(clients, stack):
|
def plan_undeploy(clients, plan):
|
||||||
"""Deletes the stack named in the workflow_input.
|
"""Undeploy the plan and deletes the stack named in the workflow_input.
|
||||||
|
|
||||||
:param workflow_client: Workflow client
|
:param workflow_client: Workflow client
|
||||||
:param stack: Name or ID of stack to delete
|
:param plan: Name or ID of plan to delete
|
||||||
"""
|
"""
|
||||||
|
|
||||||
workflow_client = clients.workflow_engine
|
workflow_client = clients.workflow_engine
|
||||||
tripleoclient = clients.tripleoclient
|
tripleoclient = clients.tripleoclient
|
||||||
|
|
||||||
workflow_input = {
|
workflow_input = {
|
||||||
'stack': stack
|
'container': plan
|
||||||
}
|
}
|
||||||
|
|
||||||
with tripleoclient.messaging_websocket() as ws:
|
with tripleoclient.messaging_websocket() as ws:
|
||||||
execution = base.start_workflow(
|
execution = base.start_workflow(
|
||||||
workflow_client,
|
workflow_client,
|
||||||
'tripleo.stack.v1.delete_stack',
|
'tripleo.deployment.v1.undeploy_plan',
|
||||||
workflow_input=workflow_input
|
workflow_input=workflow_input
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue