diff --git a/releasenotes/notes/git-support-for-plans-883d622d2275ba3b.yaml b/releasenotes/notes/git-support-for-plans-883d622d2275ba3b.yaml new file mode 100644 index 000000000..b3d750f7f --- /dev/null +++ b/releasenotes/notes/git-support-for-plans-883d622d2275ba3b.yaml @@ -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. diff --git a/tripleoclient/tests/v1/test_overcloud_plan.py b/tripleoclient/tests/v1/test_overcloud_plan.py index 38b00f742..305c52cbe 100644 --- a/tripleoclient/tests/v1/test_overcloud_plan.py +++ b/tripleoclient/tests/v1/test_overcloud_plan.py @@ -133,11 +133,13 @@ class TestOvercloudCreatePlan(utils.TestCommand): # Verify 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={ 'container': 'overcast', 'queue_name': 'UUID4', - 'generate_passwords': True + 'generate_passwords': True, + 'use_default_templates': True, + 'source_url': None }) def test_create_default_plan_failed(self): @@ -161,11 +163,13 @@ class TestOvercloudCreatePlan(utils.TestCommand): # Verify 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={ 'container': 'overcast', 'queue_name': 'UUID4', - 'generate_passwords': True + 'generate_passwords': True, + 'use_default_templates': True, + 'source_url': None }) @mock.patch("tripleoclient.workflows.plan_management.tarball") @@ -290,11 +294,13 @@ class TestOvercloudCreatePlan(utils.TestCommand): # Verify 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={ 'container': 'overcast', 'queue_name': 'UUID4', - 'generate_passwords': False + 'use_default_templates': True, + 'generate_passwords': False, + 'source_url': None }) diff --git a/tripleoclient/v1/overcloud_plan.py b/tripleoclient/v1/overcloud_plan.py index a6a5373c6..86b2c45c5 100644 --- a/tripleoclient/v1/overcloud_plan.py +++ b/tripleoclient/v1/overcloud_plan.py @@ -82,16 +82,17 @@ class CreatePlan(command.Command): def get_parser(self, prog_name): parser = super(CreatePlan, self).get_parser(prog_name) + source_group = parser.add_mutually_exclusive_group() parser.add_argument( 'name', help=_('The name of the plan, which is used for the object ' 'storage container, workflow environment and orchestration ' 'stack names.')) - parser.add_argument( + source_group.add_argument( '--templates', help=_('The directory containing the Heat templates to deploy. ' - 'If this isn\'t provided, the templates packaged on the ' - 'Undercloud will be used.'), + 'If this or --source_url isn\'t provided, the templates ' + 'packaged on the Undercloud will be used.'), ) parser.add_argument( '--disable-password-generation', @@ -99,6 +100,12 @@ class CreatePlan(command.Command): default=False, 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 @@ -107,16 +114,23 @@ class CreatePlan(command.Command): clients = self.app.client_manager name = parsed_args.name + use_default_templates = False 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: plan_management.create_plan_from_templates( clients, name, parsed_args.templates, generate_passwords=generate_passwords) else: - plan_management.create_default_plan( + plan_management.create_deployment_plan( 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): diff --git a/tripleoclient/workflows/plan_management.py b/tripleoclient/workflows/plan_management.py index fda4dc8f0..77b14a06e 100644 --- a/tripleoclient/workflows/plan_management.py +++ b/tripleoclient/workflows/plan_management.py @@ -44,6 +44,7 @@ def _upload_templates(swift_client, container_name, tht_root, roles_file=None): def create_default_plan(clients, **workflow_input): + workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] @@ -92,7 +93,10 @@ def create_deployment_plan(clients, **workflow_input): **workflow_input) if payload['status'] == 'SUCCESS': - print("Plan created") + if 'use_default_templates' in workflow_input: + print("Default plan created") + else: + print("Plan created") else: raise exceptions.WorkflowServiceError( '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) update_deployment_plan(clients, container=name, queue_name=str(uuid.uuid4()), - generate_passwords=generate_passwords) + generate_passwords=generate_passwords, + source_url=None) def export_deployment_plan(clients, **workflow_input):