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:
parent
9a6b7fa663
commit
025b88aa38
|
@ -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())
|
||||
|
|
|
@ -2520,7 +2520,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.
|
||||
|
@ -2531,14 +2531,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
|
||||
|
@ -2550,15 +2544,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'
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue