Simplify setting deployment status

We don't use mistral anymore to set the deployment status.
This simplifies setting of the deployment status and also
removes the usage of DeploymentStatusAction.

Change-Id: I5454510dc3aae681d5b37570a15cf0d0c8a3a114
This commit is contained in:
Rabi Mishra 2020-04-11 18:59:20 +05:30
parent 9a6b7fa663
commit 025b88aa38
4 changed files with 25 additions and 48 deletions

View File

@ -1823,20 +1823,11 @@ class TestGetDeploymentStatus(utils.TestCommand):
obj.put_object = mock.Mock() obj.put_object = mock.Mock()
obj.put_container = mock.Mock() obj.put_container = mock.Mock()
@mock.patch( @mock.patch("tripleoclient.workflows.deployment.get_deployment_status")
'tripleo_common.actions.deployment.DeploymentStatusAction.run',
autospec=True
)
def test_get_deployment_status(self, mock_get_deployment_status): def test_get_deployment_status(self, mock_get_deployment_status):
parsed_args = self.check_parser(self.cmd, [], []) parsed_args = self.check_parser(self.cmd, [], [])
self.cmd.app.stdout = six.StringIO() self.cmd.app.stdout = six.StringIO()
status = dict( status = 'DEPLOY_SUCCESS'
cd_status='SUCCESS',
stack_status='SUCCESS',
deployment_status='SUCCESS',
ansible_status='SUCCESS',
status_update='SUCCESS'
)
mock_get_deployment_status.return_value = status mock_get_deployment_status.return_value = status
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
@ -1845,7 +1836,7 @@ class TestGetDeploymentStatus(utils.TestCommand):
'+-----------+-------------------+\n' '+-----------+-------------------+\n'
'| Plan Name | Deployment Status |\n' '| Plan Name | Deployment Status |\n'
'+-----------+-------------------+\n' '+-----------+-------------------+\n'
'| overcloud | SUCCESS |\n' '| overcloud | DEPLOY_SUCCESS |\n'
'+-----------+-------------------+\n') '+-----------+-------------------+\n')
self.assertEqual(expected, self.cmd.app.stdout.getvalue()) self.assertEqual(expected, self.cmd.app.stdout.getvalue())

View File

@ -2520,7 +2520,7 @@ def copy_clouds_yaml(user):
raise exceptions.DeploymentError(msg) raise exceptions.DeploymentError(msg)
def update_deployment_status(clients, plan, status, message=None): def update_deployment_status(clients, plan, status):
"""Update the deployment status object in swift. """Update the deployment status object in swift.
:param clients: application client object. :param clients: application client object.
@ -2531,14 +2531,8 @@ def update_deployment_status(clients, plan, status, message=None):
:param status: Status information. :param status: Status information.
:type status: Dictionary :type status: Dictionary
:param message: Status message.
:type message: String
""" """
if not message:
message = 'Status updated without mistral.'
container = '{}-messages'.format(plan) container = '{}-messages'.format(plan)
# create {plan}-messages container if not there # create {plan}-messages container if not there
@ -2550,15 +2544,11 @@ def update_deployment_status(clients, plan, status, message=None):
'deployment_status.yaml', 'deployment_status.yaml',
yaml.safe_dump( yaml.safe_dump(
{ {
'deployment_status': status['status_update'], 'deployment_status': status,
'workflow_status': { 'workflow_status': {
'payload': { 'payload': {
'deployment_status': status['status_update'], 'deployment_status': status,
'execution_id': 'UNDEFINED',
'message': message,
'plan_name': plan, 'plan_name': plan,
'root_execution_id': 'UNDEFINED',
'status': status['status_update']
}, },
'type': 'tripleoclient' 'type': 'tripleoclient'
} }

View File

@ -1109,7 +1109,7 @@ class GetDeploymentStatus(command.Command):
self.log.debug("take_action(%s)" % parsed_args) self.log.debug("take_action(%s)" % parsed_args)
plan = parsed_args.plan plan = parsed_args.plan
status, plan = deployment.get_deployment_status( status = deployment.get_deployment_status(
self.app.client_manager, self.app.client_manager,
plan=plan plan=plan
) )

View File

@ -14,11 +14,13 @@ from __future__ import print_function
import copy import copy
import getpass import getpass
import os import os
import yaml
import six
from heatclient.common import event_utils from heatclient.common import event_utils
from heatclient import exc as heat_exc
from openstackclient import shell from openstackclient import shell
import six
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import ansible from tripleo_common.actions import ansible
from tripleo_common.actions import config from tripleo_common.actions import config
from tripleo_common.actions import deployment from tripleo_common.actions import deployment
@ -573,21 +575,20 @@ def get_deployment_status(clients, plan):
:returns: string :returns: string
""" """
try:
clients.orchestration.stacks.get(plan)
except heat_exc.HTTPNotFound:
return None
context = clients.tripleoclient.create_mistral_context() try:
get_deployment_status = deployment.DeploymentStatusAction(plan=plan) body = swift_utils.get_object_string(
status = get_deployment_status.run(context=context) clients.tripleoclient.object_store,
status_update = status.get('status_update') '%s-messages' % plan,
deployment_status = status.get('deployment_status') 'deployment_status.yaml')
if status_update:
utils.update_deployment_status( return yaml.safe_load(body)['deployment_status']
clients=clients, except swiftexceptions.ClientException:
plan=plan, return None
status=status
)
return status_update, plan
else:
return deployment_status, plan
def set_deployment_status(clients, plan, status): def set_deployment_status(clients, plan, status):
@ -602,15 +603,10 @@ def set_deployment_status(clients, plan, status):
:param status: Current status of the deployment. :param status: Current status of the deployment.
:type status: String :type status: String
""" """
deploy_status = '{}'.format(status.upper())
utils.update_deployment_status( utils.update_deployment_status(
clients=clients, clients=clients,
plan=plan, plan=plan,
status={ status=status)
'deployment_status': deploy_status,
'status_update': deploy_status
}
)
def get_deployment_failures(clients, plan): def get_deployment_failures(clients, plan):