Merge "Update plan creation command"
This commit is contained in:
commit
604cc6ebc4
@ -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.
|
@ -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
|
||||
})
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user