diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py index 97dcd5016..c6430e3d6 100644 --- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py +++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py @@ -1823,20 +1823,11 @@ class TestGetDeploymentStatus(utils.TestCommand): obj.put_object = mock.Mock() obj.put_container = mock.Mock() - @mock.patch( - 'tripleo_common.actions.deployment.DeploymentStatusAction.run', - autospec=True - ) + @mock.patch("tripleoclient.workflows.deployment.get_deployment_status") def test_get_deployment_status(self, mock_get_deployment_status): parsed_args = self.check_parser(self.cmd, [], []) self.cmd.app.stdout = six.StringIO() - status = dict( - cd_status='SUCCESS', - stack_status='SUCCESS', - deployment_status='SUCCESS', - ansible_status='SUCCESS', - status_update='SUCCESS' - ) + status = 'DEPLOY_SUCCESS' mock_get_deployment_status.return_value = status self.cmd.take_action(parsed_args) @@ -1845,7 +1836,7 @@ class TestGetDeploymentStatus(utils.TestCommand): '+-----------+-------------------+\n' '| Plan Name | Deployment Status |\n' '+-----------+-------------------+\n' - '| overcloud | SUCCESS |\n' + '| overcloud | DEPLOY_SUCCESS |\n' '+-----------+-------------------+\n') self.assertEqual(expected, self.cmd.app.stdout.getvalue()) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index f5777ec00..b599441c9 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2513,7 +2513,7 @@ def copy_clouds_yaml(user): 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. :param clients: application client object. @@ -2524,14 +2524,8 @@ def update_deployment_status(clients, plan, status, message=None): :param status: Status information. :type status: Dictionary - - :param message: Status message. - :type message: String """ - if not message: - message = 'Status updated without mistral.' - container = '{}-messages'.format(plan) # create {plan}-messages container if not there @@ -2543,15 +2537,11 @@ def update_deployment_status(clients, plan, status, message=None): 'deployment_status.yaml', yaml.safe_dump( { - 'deployment_status': status['status_update'], + 'deployment_status': status, 'workflow_status': { 'payload': { - 'deployment_status': status['status_update'], - 'execution_id': 'UNDEFINED', - 'message': message, + 'deployment_status': status, 'plan_name': plan, - 'root_execution_id': 'UNDEFINED', - 'status': status['status_update'] }, 'type': 'tripleoclient' } diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index a32d44d7b..b6e84762d 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -1109,7 +1109,7 @@ class GetDeploymentStatus(command.Command): self.log.debug("take_action(%s)" % parsed_args) plan = parsed_args.plan - status, plan = deployment.get_deployment_status( + status = deployment.get_deployment_status( self.app.client_manager, plan=plan ) diff --git a/tripleoclient/workflows/deployment.py b/tripleoclient/workflows/deployment.py index b0f045bfe..2753df373 100644 --- a/tripleoclient/workflows/deployment.py +++ b/tripleoclient/workflows/deployment.py @@ -14,11 +14,13 @@ from __future__ import print_function import copy import getpass import os - -import six +import yaml from heatclient.common import event_utils +from heatclient import exc as heat_exc from openstackclient import shell +import six +from swiftclient import exceptions as swiftexceptions from tripleo_common.actions import ansible from tripleo_common.actions import config from tripleo_common.actions import deployment @@ -573,21 +575,20 @@ def get_deployment_status(clients, plan): :returns: string """ + try: + clients.orchestration.stacks.get(plan) + except heat_exc.HTTPNotFound: + return None - context = clients.tripleoclient.create_mistral_context() - get_deployment_status = deployment.DeploymentStatusAction(plan=plan) - status = get_deployment_status.run(context=context) - status_update = status.get('status_update') - deployment_status = status.get('deployment_status') - if status_update: - utils.update_deployment_status( - clients=clients, - plan=plan, - status=status - ) - return status_update, plan - else: - return deployment_status, plan + try: + body = swift_utils.get_object_string( + clients.tripleoclient.object_store, + '%s-messages' % plan, + 'deployment_status.yaml') + + return yaml.safe_load(body)['deployment_status'] + except swiftexceptions.ClientException: + return None 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. :type status: String """ - deploy_status = '{}'.format(status.upper()) utils.update_deployment_status( clients=clients, plan=plan, - status={ - 'deployment_status': deploy_status, - 'status_update': deploy_status - } - ) + status=status) def get_deployment_failures(clients, plan):