Merge "overcloud status report the correct cd for the given plan" into stable/train
This commit is contained in:
commit
2d4385d97f
|
@ -450,14 +450,17 @@ class DeploymentStatusAction(base.TripleOAction):
|
|||
# Will get set to new status if an update is required
|
||||
status_update = None
|
||||
|
||||
cd_execs = workflow_client.executions.find(
|
||||
workflow_name='tripleo.deployment.v1.config_download_deploy')
|
||||
cd_execs.sort(key=lambda x: x.updated_at)
|
||||
if cd_execs:
|
||||
cd_exec = workflow_client.executions.get(cd_execs[-1].id)
|
||||
cd_status = cd_exec.state
|
||||
ansible_status = json.loads(
|
||||
cd_exec.output).get('deployment_status')
|
||||
for cd_exec in workflow_client.executions.list(
|
||||
sort_keys="updated_at",
|
||||
sort_dirs="desc",
|
||||
fields=['input', 'output', 'state'],
|
||||
workflow_name='tripleo.deployment.v1.config_download_deploy'
|
||||
):
|
||||
if json.loads(cd_exec.input).get('plan_name') == self.plan:
|
||||
cd_status = cd_exec.state
|
||||
ansible_status = json.loads(
|
||||
cd_exec.output).get('deployment_status')
|
||||
break
|
||||
|
||||
def update_status(status):
|
||||
# If we need to update the status return it
|
||||
|
|
|
@ -751,8 +751,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -782,8 +783,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -813,8 +815,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -844,8 +847,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -875,8 +879,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_FAILED"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -906,8 +911,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||
execution.input = '{"plan_name":"overcloud"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.find.return_value = [execution]
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
@ -915,6 +921,38 @@ class DeploymentStatusActionTest(base.TestCase):
|
|||
self.assertEqual(result['status_update'], None)
|
||||
self.assertEqual(result['deployment_status'], None)
|
||||
|
||||
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||
'get_object_client')
|
||||
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||
'get_workflow_client')
|
||||
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||
'get_orchestration_client')
|
||||
def test_get_deployment_status_different_plan(
|
||||
self, heat, mistral, swift):
|
||||
|
||||
mock_stack = mock.Mock()
|
||||
mock_stack.stack_status = 'COMPLETE'
|
||||
heat().stacks.get.return_value = mock_stack
|
||||
|
||||
body = 'deployment_status: DEPLOY_SUCCESS'
|
||||
swift().get_object.return_value = [mock.Mock(), body]
|
||||
|
||||
execution = mock.Mock()
|
||||
execution.updated_at = 1
|
||||
execution.state = 'SUCCESS'
|
||||
execution.output = '{"deployment_status":"DEPLOY_FAILED"}'
|
||||
execution.input = '{"plan_name":"foobar"}'
|
||||
mistral().executions.get.return_value = execution
|
||||
mistral().executions.list.return_value = [execution]
|
||||
|
||||
action = deployment.DeploymentStatusAction(self.plan)
|
||||
result = action.run(self.ctx)
|
||||
|
||||
self.assertEqual(result['stack_status'], 'COMPLETE')
|
||||
self.assertEqual(result['cd_status'], None)
|
||||
self.assertEqual(result['deployment_status'], 'DEPLOY_SUCCESS')
|
||||
self.assertEqual(result['status_update'], None)
|
||||
|
||||
|
||||
class DeploymentFailuresActionTest(base.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue