Use ansible playbook for plan deploy
Depends-On: https://review.opendev.org/713641 Depends-On: https://review.opendev.org/714280 Change-Id: I9b9488672293558747c6dc41eb6d41c18bdc9e05
This commit is contained in:
parent
4a55e5b9c2
commit
becee11a5a
tripleoclient
tests
v1
workflows
@ -531,7 +531,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
clients.tripleoclient.object_store, mock.ANY, 'overcloud')
|
||||
|
||||
workflow_client.action_executions.create.assert_called()
|
||||
workflow_client.executions.create.assert_called()
|
||||
# workflow_client.executions.create.assert_called()
|
||||
|
||||
mock_open_context.assert_has_calls(
|
||||
[mock.call('the-plan-environment.yaml')])
|
||||
|
@ -250,56 +250,44 @@ class TestOvercloudDeployPlan(utils.TestCommand):
|
||||
app_args.verbose_level = 1
|
||||
self.cmd = overcloud_plan.DeployPlan(self.app, app_args)
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine = mock.Mock()
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
self.orch = self.app.client_manager.orchestration = mock.Mock()
|
||||
|
||||
self.websocket = mock.Mock()
|
||||
self.websocket.__enter__ = lambda s: self.websocket
|
||||
self.websocket.__exit__ = lambda s, *exc: None
|
||||
self.tripleoclient = mock.Mock()
|
||||
self.tripleoclient.messaging_websocket.return_value = self.websocket
|
||||
self.app.client_manager.tripleoclient = self.tripleoclient
|
||||
|
||||
sleep_patch = mock.patch('time.sleep')
|
||||
self.addCleanup(sleep_patch.stop)
|
||||
sleep_patch.start()
|
||||
|
||||
@mock.patch("tripleoclient.utils.run_ansible_playbook", autospec=True)
|
||||
@mock.patch('tripleoclient.utils.wait_for_stack_ready', autospec=True)
|
||||
def test_overcloud_deploy_plan(self, mock_for_stack_ready):
|
||||
def test_overcloud_deploy_plan(self, mock_for_stack_ready,
|
||||
mock_run_playbook):
|
||||
|
||||
# Setup
|
||||
arglist = ['--run-validations', 'overcast']
|
||||
verifylist = [
|
||||
('name', 'overcast'),
|
||||
('run_validations', True),
|
||||
('timeout', 240)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.orch = self.app.client_manager.orchestration = mock.Mock()
|
||||
# No existing stack, this is a new deploy.
|
||||
self.orch.stacks.get.return_value = None
|
||||
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
'execution_id': 'IDID',
|
||||
'status': 'SUCCESS'
|
||||
}])
|
||||
|
||||
mock_for_stack_ready.return_value = True
|
||||
|
||||
# Run
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
# Verify
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.deployment.v1.deploy_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'run_validations': True,
|
||||
'skip_deploy_identifier': False,
|
||||
'deployment_options': {},
|
||||
}
|
||||
mock_run_playbook.assert_called_once_with(
|
||||
'cli-deploy-deployment-plan.yaml',
|
||||
'undercloud,',
|
||||
constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
extra_vars={
|
||||
"container": "overcast",
|
||||
"run_validations": True,
|
||||
"skip_deploy_identifier": False,
|
||||
"timeout_mins": 240
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
||||
|
||||
|
@ -150,27 +150,16 @@ class TestDeploymentWorkflows(utils.TestCommand):
|
||||
|
||||
@mock.patch('tripleoclient.utils.run_ansible_playbook',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.base')
|
||||
def test_config_download_already_in_progress_for_diff_stack(
|
||||
self, mock_base, mock_playbook):
|
||||
self, mock_playbook):
|
||||
log = mock.Mock()
|
||||
stack = mock.Mock()
|
||||
stack.stack_name = 'stacktest'
|
||||
stack.output_show.return_value = {'output': {'output_value': []}}
|
||||
clients = mock.Mock()
|
||||
mock_execution = mock.Mock()
|
||||
mock_execution.input = '{"plan_name": "someotherstack"}'
|
||||
mock_return = mock.Mock(return_value=[mock_execution])
|
||||
clients.workflow_engine.executions.find = mock_return
|
||||
mock_exit = mock.Mock()
|
||||
mock_exit.__exit__ = mock.Mock()
|
||||
mock_exit.__enter__ = mock.Mock()
|
||||
clients.tripleoclient.messaging_websocket = mock.Mock(
|
||||
return_value=mock_exit)
|
||||
mock_base.wait_for_messages = mock.Mock(
|
||||
return_value=[dict(status='SUCCESS')])
|
||||
|
||||
deployment.config_download(
|
||||
log, clients, stack, 'templates', 'ssh_user',
|
||||
'ssh_key', 'ssh_networks', 'output_dir', False,
|
||||
'timeout')
|
||||
|
||||
self.assertEqual(2, mock_playbook.call_count)
|
||||
|
@ -146,7 +146,7 @@ class DeployPlan(command.Command):
|
||||
parser = super(DeployPlan, self).get_parser(prog_name)
|
||||
parser.add_argument('name', help=_('The name of the plan to deploy.'))
|
||||
parser.add_argument('--timeout', '-t', metavar='<TIMEOUT>',
|
||||
type=int,
|
||||
type=int, default=240,
|
||||
help=_('Deployment timeout in minutes.'))
|
||||
parser.add_argument('--run-validations', action='store_true',
|
||||
default=False,
|
||||
|
@ -14,7 +14,6 @@ from __future__ import print_function
|
||||
import copy
|
||||
import getpass
|
||||
import os
|
||||
import pprint
|
||||
import time
|
||||
|
||||
import six
|
||||
@ -31,39 +30,25 @@ from tripleoclient.constants import DEFAULT_WORK_DIR
|
||||
from tripleoclient import exceptions
|
||||
from tripleoclient import utils
|
||||
|
||||
from tripleoclient.workflows import base
|
||||
|
||||
|
||||
_WORKFLOW_TIMEOUT = 360 # 6 * 60 seconds
|
||||
|
||||
|
||||
def deploy(log, clients, **workflow_input):
|
||||
utils.run_ansible_playbook(
|
||||
"cli-deploy-deployment-plan.yaml",
|
||||
'undercloud,',
|
||||
ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
extra_vars={
|
||||
"container": workflow_input['container'],
|
||||
"run_validations": workflow_input['run_validations'],
|
||||
"skip_deploy_identifier": workflow_input['skip_deploy_identifier'],
|
||||
"timeout_mins": workflow_input['timeout'],
|
||||
},
|
||||
verbosity=3
|
||||
)
|
||||
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
wf_name = 'tripleo.deployment.v1.deploy_plan'
|
||||
|
||||
with tripleoclients.messaging_websocket() as ws:
|
||||
execution = base.start_workflow(
|
||||
workflow_client,
|
||||
wf_name,
|
||||
workflow_input=workflow_input
|
||||
)
|
||||
|
||||
# The deploy workflow ends once the Heat create/update starts. This
|
||||
# means that is shouldn't take very long. Wait for 10 minutes for
|
||||
# messages from the workflow.
|
||||
for payload in base.wait_for_messages(workflow_client, ws, execution,
|
||||
600):
|
||||
status = payload.get('status', 'RUNNING')
|
||||
message = payload.get('message')
|
||||
if message and status == "RUNNING":
|
||||
print(message)
|
||||
elif payload['status'] != "SUCCESS":
|
||||
log.info(pprint.pformat(payload))
|
||||
print(payload['message'])
|
||||
raise ValueError("Unexpected status %s for %s"
|
||||
% (payload['status'], wf_name))
|
||||
print("Success.")
|
||||
|
||||
|
||||
def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
||||
@ -75,7 +60,7 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
||||
"container": plan_name,
|
||||
"run_validations": run_validations,
|
||||
"skip_deploy_identifier": skip_deploy_identifier,
|
||||
"deployment_options": deployment_options,
|
||||
"timeout": timeout
|
||||
}
|
||||
|
||||
if timeout is not None:
|
||||
@ -83,6 +68,7 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
||||
|
||||
deploy(log, clients, **workflow_input)
|
||||
|
||||
# need to move this to the playbook I guess
|
||||
orchestration_client = clients.orchestration
|
||||
|
||||
if stack is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user