Set correct deployment_status in deployment stages
We need to set the deployment status before stack deployment and for playbook failure after the stack deployment. Change-Id: Ic353b6552d28d66bcc53a7a4df318e60de5bd320
This commit is contained in:
parent
a947b57094
commit
9a6b7fa663
|
@ -1420,7 +1420,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'deploying',
|
||||
'DEPLOY_SUCCESS',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status']
|
||||
)
|
||||
mock_copy.assert_called_once()
|
||||
|
@ -1457,7 +1457,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'deploying',
|
||||
'DEPLOY_SUCCESS',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status'])
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
|
@ -1501,7 +1501,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'failed',
|
||||
'DEPLOY_FAILED',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status'])
|
||||
|
||||
@mock.patch('tripleoclient.utils.copy_clouds_yaml')
|
||||
|
|
|
@ -257,12 +257,15 @@ class TestOvercloudDeployPlan(utils.TestCommand):
|
|||
self.addCleanup(sleep_patch.stop)
|
||||
sleep_patch.start()
|
||||
|
||||
@mock.patch("tripleoclient.utils.update_deployment_status", autospec=True)
|
||||
@mock.patch("tripleoclient.utils.run_ansible_playbook", autospec=True)
|
||||
@mock.patch('tripleoclient.utils.wait_for_stack_ready', autospec=True)
|
||||
@mock.patch('os.chdir', autospec=True)
|
||||
@mock.patch('tempfile.mkdtemp', autospec=True)
|
||||
def test_overcloud_deploy_plan(self, mock_tmp, mock_cd,
|
||||
mock_for_stack_ready, mock_run_playbook):
|
||||
mock_for_stack_ready,
|
||||
mock_run_playbook,
|
||||
mock_update_status):
|
||||
|
||||
# Setup
|
||||
arglist = ['--run-validations', 'overcast']
|
||||
|
@ -295,6 +298,7 @@ class TestOvercloudDeployPlan(utils.TestCommand):
|
|||
},
|
||||
verbosity=3,
|
||||
)
|
||||
mock_update_status.assert_called()
|
||||
|
||||
|
||||
class TestOvercloudExportPlan(utils.TestCommand):
|
||||
|
|
|
@ -1010,7 +1010,7 @@ class DeployOvercloud(command.Command):
|
|||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
plan=stack.stack_name,
|
||||
status='deploying'
|
||||
status='DEPLOYING'
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -1051,11 +1051,15 @@ class DeployOvercloud(command.Command):
|
|||
in_flight_validations=parsed_args.inflight,
|
||||
deployment_timeout=timeout
|
||||
)
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
plan=stack.stack_name,
|
||||
status='DEPLOY_SUCCESS')
|
||||
except Exception:
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
plan=stack.stack_name,
|
||||
status='failed'
|
||||
status='DEPLOY_FAILED'
|
||||
)
|
||||
raise
|
||||
|
||||
|
|
|
@ -92,13 +92,22 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
|||
marker = events[0].id if events else None
|
||||
action = 'UPDATE'
|
||||
|
||||
deploy(
|
||||
container=plan_name,
|
||||
run_validations=run_validations,
|
||||
skip_deploy_identifier=skip_deploy_identifier,
|
||||
timeout=timeout,
|
||||
verbosity=verbose_level
|
||||
)
|
||||
set_deployment_status(clients=clients,
|
||||
plan=plan_name,
|
||||
status='DEPLOYING')
|
||||
|
||||
try:
|
||||
deploy(
|
||||
container=plan_name,
|
||||
run_validations=run_validations,
|
||||
skip_deploy_identifier=skip_deploy_identifier,
|
||||
timeout=timeout,
|
||||
verbosity=verbose_level)
|
||||
except Exception:
|
||||
set_deployment_status(clients=clients,
|
||||
plan=plan_name,
|
||||
status='DEPLOY_FAILED')
|
||||
raise
|
||||
|
||||
verbose_events = verbose_level >= 1
|
||||
|
||||
|
@ -111,7 +120,7 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
|||
set_deployment_status(
|
||||
clients=clients,
|
||||
plan=plan_name,
|
||||
status='failed'
|
||||
status='DEPLOY_FAILED'
|
||||
)
|
||||
if stack is None:
|
||||
raise exceptions.DeploymentError("Heat Stack create failed.")
|
||||
|
@ -593,8 +602,7 @@ def set_deployment_status(clients, plan, status):
|
|||
:param status: Current status of the deployment.
|
||||
:type status: String
|
||||
"""
|
||||
|
||||
deploy_status = 'DEPLOY_{}'.format(status.upper())
|
||||
deploy_status = '{}'.format(status.upper())
|
||||
utils.update_deployment_status(
|
||||
clients=clients,
|
||||
plan=plan,
|
||||
|
|
Loading…
Reference in New Issue