Update plan creation command

This patch updates the create plan command to use the latest
changes to the workflows in tripleo-common that allow a
deployment plan to be created or updated from a git
repository.

Partially-Implements: blueprint git-deployment-plan
Change-Id: I71c1f5d58abcf0a55598f02fbd21fdffedcf5291
This commit is contained in:
Ryan Brady 2017-02-07 13:00:12 -05:00
parent 846f087ea4
commit 4edcc395c5
4 changed files with 44 additions and 13 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Added argument for --source_url to overcloud create_plan workflow call.
The --source_url argument expects the url of a git repository containing
the Heat templates to deploy.

View File

@ -133,11 +133,13 @@ class TestOvercloudCreatePlan(utils.TestCommand):
# Verify # Verify
self.workflow.executions.create.assert_called_once_with( self.workflow.executions.create.assert_called_once_with(
'tripleo.plan_management.v1.create_default_deployment_plan', 'tripleo.plan_management.v1.create_deployment_plan',
workflow_input={ workflow_input={
'container': 'overcast', 'container': 'overcast',
'queue_name': 'UUID4', 'queue_name': 'UUID4',
'generate_passwords': True 'generate_passwords': True,
'use_default_templates': True,
'source_url': None
}) })
def test_create_default_plan_failed(self): def test_create_default_plan_failed(self):
@ -161,11 +163,13 @@ class TestOvercloudCreatePlan(utils.TestCommand):
# Verify # Verify
self.workflow.executions.create.assert_called_once_with( self.workflow.executions.create.assert_called_once_with(
'tripleo.plan_management.v1.create_default_deployment_plan', 'tripleo.plan_management.v1.create_deployment_plan',
workflow_input={ workflow_input={
'container': 'overcast', 'container': 'overcast',
'queue_name': 'UUID4', 'queue_name': 'UUID4',
'generate_passwords': True 'generate_passwords': True,
'use_default_templates': True,
'source_url': None
}) })
@mock.patch("tripleoclient.workflows.plan_management.tarball") @mock.patch("tripleoclient.workflows.plan_management.tarball")
@ -290,11 +294,13 @@ class TestOvercloudCreatePlan(utils.TestCommand):
# Verify # Verify
self.workflow.executions.create.assert_called_once_with( self.workflow.executions.create.assert_called_once_with(
'tripleo.plan_management.v1.create_default_deployment_plan', 'tripleo.plan_management.v1.create_deployment_plan',
workflow_input={ workflow_input={
'container': 'overcast', 'container': 'overcast',
'queue_name': 'UUID4', 'queue_name': 'UUID4',
'generate_passwords': False 'use_default_templates': True,
'generate_passwords': False,
'source_url': None
}) })

View File

@ -82,16 +82,17 @@ class CreatePlan(command.Command):
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(CreatePlan, self).get_parser(prog_name) parser = super(CreatePlan, self).get_parser(prog_name)
source_group = parser.add_mutually_exclusive_group()
parser.add_argument( parser.add_argument(
'name', 'name',
help=_('The name of the plan, which is used for the object ' help=_('The name of the plan, which is used for the object '
'storage container, workflow environment and orchestration ' 'storage container, workflow environment and orchestration '
'stack names.')) 'stack names.'))
parser.add_argument( source_group.add_argument(
'--templates', '--templates',
help=_('The directory containing the Heat templates to deploy. ' help=_('The directory containing the Heat templates to deploy. '
'If this isn\'t provided, the templates packaged on the ' 'If this or --source_url isn\'t provided, the templates '
'Undercloud will be used.'), 'packaged on the Undercloud will be used.'),
) )
parser.add_argument( parser.add_argument(
'--disable-password-generation', '--disable-password-generation',
@ -99,6 +100,12 @@ class CreatePlan(command.Command):
default=False, default=False,
help=_('Disable password generation.') help=_('Disable password generation.')
) )
source_group.add_argument(
'--source-url',
help=_('The url of a git repository containing the Heat templates '
'to deploy. If this or --templates isn\'t provided, the '
'templates packaged on the Undercloud will be used.')
)
return parser return parser
@ -107,16 +114,23 @@ class CreatePlan(command.Command):
clients = self.app.client_manager clients = self.app.client_manager
name = parsed_args.name name = parsed_args.name
use_default_templates = False
generate_passwords = not parsed_args.disable_password_generation generate_passwords = not parsed_args.disable_password_generation
source_url = parsed_args.source_url
# if the templates and source_url params are not used, then
# use the default templates
if not parsed_args.templates and not parsed_args.source_url:
use_default_templates = True
if parsed_args.templates: if parsed_args.templates:
plan_management.create_plan_from_templates( plan_management.create_plan_from_templates(
clients, name, parsed_args.templates, clients, name, parsed_args.templates,
generate_passwords=generate_passwords) generate_passwords=generate_passwords)
else: else:
plan_management.create_default_plan( plan_management.create_deployment_plan(
clients, container=name, queue_name=str(uuid.uuid4()), clients, container=name, queue_name=str(uuid.uuid4()),
generate_passwords=generate_passwords) generate_passwords=generate_passwords, source_url=source_url,
use_default_templates=use_default_templates)
class DeployPlan(command.Command): class DeployPlan(command.Command):

View File

@ -44,6 +44,7 @@ def _upload_templates(swift_client, container_name, tht_root, roles_file=None):
def create_default_plan(clients, **workflow_input): def create_default_plan(clients, **workflow_input):
workflow_client = clients.workflow_engine workflow_client = clients.workflow_engine
tripleoclients = clients.tripleoclient tripleoclients = clients.tripleoclient
queue_name = workflow_input['queue_name'] queue_name = workflow_input['queue_name']
@ -92,7 +93,10 @@ def create_deployment_plan(clients, **workflow_input):
**workflow_input) **workflow_input)
if payload['status'] == 'SUCCESS': if payload['status'] == 'SUCCESS':
print("Plan created") if 'use_default_templates' in workflow_input:
print("Default plan created")
else:
print("Plan created")
else: else:
raise exceptions.WorkflowServiceError( raise exceptions.WorkflowServiceError(
'Exception creating plan: {}'.format(payload['message'])) 'Exception creating plan: {}'.format(payload['message']))
@ -182,7 +186,8 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None,
_upload_templates(swift_client, name, tht_root, roles_file) _upload_templates(swift_client, name, tht_root, roles_file)
update_deployment_plan(clients, container=name, update_deployment_plan(clients, container=name,
queue_name=str(uuid.uuid4()), queue_name=str(uuid.uuid4()),
generate_passwords=generate_passwords) generate_passwords=generate_passwords,
source_url=None)
def export_deployment_plan(clients, **workflow_input): def export_deployment_plan(clients, **workflow_input):