Provide an option to disable password generation on deployment
Operators may choose to use the passwords provided by them and does not intend to generate during the deployment. Provided an option to disable password generation if requested by user explicity. It will be helpful to identify if there are any new passwords added which has to be added during the deployment update by the operator. By default, the password generation will be enabled. Partial-Bug: #1611704 Depends-On: I141a0727db9f19f80712e2c40069622ecc22d969 Change-Id: Iedfd7fd1456ed61cb9208532d15bdb63fbc01de9
This commit is contained in:
parent
0509d02bf6
commit
26b3ac7af1
|
@ -888,11 +888,13 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
arglist = ['--answers-file', test_answerfile,
|
||||
'--environment-file', test_env2,
|
||||
'--block-storage-scale', '3']
|
||||
'--block-storage-scale', '3',
|
||||
'--disable-password-generation']
|
||||
verifylist = [
|
||||
('answers_file', test_answerfile),
|
||||
('environment_files', [test_env2]),
|
||||
('block_storage_scale', 3)]
|
||||
('block_storage_scale', 3),
|
||||
('disable_password_generation', True)]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
|
|
@ -134,7 +134,8 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
'tripleo.plan_management.v1.create_default_deployment_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'queue_name': 'UUID4'
|
||||
'queue_name': 'UUID4',
|
||||
'generate_passwords': True
|
||||
})
|
||||
|
||||
def test_create_default_plan_failed(self):
|
||||
|
@ -160,7 +161,8 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
'tripleo.plan_management.v1.create_default_deployment_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'queue_name': 'UUID4'
|
||||
'queue_name': 'UUID4',
|
||||
'generate_passwords': True
|
||||
})
|
||||
|
||||
@mock.patch("tripleoclient.workflows.plan_management.tarball")
|
||||
|
@ -193,7 +195,8 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
'tripleo.plan_management.v1.create_deployment_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'queue_name': 'UUID4'
|
||||
'queue_name': 'UUID4',
|
||||
'generate_passwords': True
|
||||
})
|
||||
|
||||
@mock.patch("tripleoclient.workflows.plan_management.tarball")
|
||||
|
@ -227,7 +230,35 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
'tripleo.plan_management.v1.create_deployment_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'queue_name': 'UUID4'
|
||||
'queue_name': 'UUID4',
|
||||
'generate_passwords': True
|
||||
})
|
||||
|
||||
def test_create_default_plan_with_password_gen_disabled(self):
|
||||
|
||||
# Setup
|
||||
arglist = ['overcast', '--disable-password-generation']
|
||||
verifylist = [
|
||||
('name', 'overcast'),
|
||||
('templates', None),
|
||||
('disable_password_generation', True)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.websocket.wait_for_message.return_value = {
|
||||
"status": "SUCCESS"
|
||||
}
|
||||
|
||||
# Run
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
# Verify
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.create_default_deployment_plan',
|
||||
workflow_input={
|
||||
'container': 'overcast',
|
||||
'queue_name': 'UUID4',
|
||||
'generate_passwords': False
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,8 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.create_deployment_plan',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'test-overcloud'})
|
||||
'container': 'test-overcloud',
|
||||
'generate_passwords': True})
|
||||
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
autospec=True)
|
||||
|
@ -105,7 +106,8 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.create_deployment_plan',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'test-overcloud'})
|
||||
'container': 'test-overcloud',
|
||||
'generate_passwords': True})
|
||||
|
||||
mock_open_context.assert_has_calls(
|
||||
[mock.call('the_roles_file.yaml')])
|
||||
|
@ -125,3 +127,29 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
'tripleo.plan.delete',
|
||||
{'container': 'overcloud'},
|
||||
run_sync=True, save_result=True)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
autospec=True)
|
||||
def test_create_plan_with_password_gen_disabled(self, mock_tarball):
|
||||
output = mock.Mock(output='{"result": ""}')
|
||||
self.workflow.action_executions.create.return_value = output
|
||||
self.websocket.wait_for_message.return_value = {
|
||||
"status": "SUCCESS",
|
||||
}
|
||||
|
||||
plan_management.create_plan_from_templates(
|
||||
self.app.client_manager,
|
||||
'test-overcloud',
|
||||
'/tht-root/',
|
||||
generate_passwords=False)
|
||||
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.plan.create_container',
|
||||
{'container': 'test-overcloud'},
|
||||
run_sync=True, save_result=True)
|
||||
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.create_deployment_plan',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'test-overcloud',
|
||||
'generate_passwords': False})
|
||||
|
|
|
@ -403,6 +403,7 @@ class DeployOvercloud(command.Command):
|
|||
parsed_args, network_client, stack)
|
||||
|
||||
plans = plan_management.list_deployment_plans(workflow_client)
|
||||
generate_passwords = not parsed_args.disable_password_generation
|
||||
|
||||
# TODO(d0ugal): We need to put a more robust strategy in place here to
|
||||
# handle updating plans.
|
||||
|
@ -410,10 +411,12 @@ class DeployOvercloud(command.Command):
|
|||
# Upload the new plan templates to swift to replace the existing
|
||||
# templates.
|
||||
plan_management.update_plan_from_templates(
|
||||
clients, parsed_args.stack, tht_root, parsed_args.roles_file)
|
||||
clients, parsed_args.stack, tht_root, parsed_args.roles_file,
|
||||
generate_passwords)
|
||||
else:
|
||||
plan_management.create_plan_from_templates(
|
||||
clients, parsed_args.stack, tht_root, parsed_args.roles_file)
|
||||
clients, parsed_args.stack, tht_root, parsed_args.roles_file,
|
||||
generate_passwords)
|
||||
|
||||
# Get any missing (e.g j2 rendered) files from the plan to tht_root
|
||||
added_files = self._download_missing_files_from_plan(
|
||||
|
@ -1021,6 +1024,12 @@ class DeployOvercloud(command.Command):
|
|||
'--answers-file',
|
||||
help=_('Path to a YAML file with arguments and parameters.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-password-generation',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable password generation.')
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
|
|
@ -90,6 +90,12 @@ class CreatePlan(command.Command):
|
|||
'If this isn\'t provided, the templates packaged on the '
|
||||
'Undercloud will be used.'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-password-generation',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable password generation.')
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
@ -98,13 +104,16 @@ class CreatePlan(command.Command):
|
|||
clients = self.app.client_manager
|
||||
|
||||
name = parsed_args.name
|
||||
generate_passwords = not parsed_args.disable_password_generation
|
||||
|
||||
if parsed_args.templates:
|
||||
plan_management.create_plan_from_templates(
|
||||
clients, name, parsed_args.templates)
|
||||
clients, name, parsed_args.templates,
|
||||
generate_passwords=generate_passwords)
|
||||
else:
|
||||
plan_management.create_default_plan(
|
||||
clients, container=name, queue_name=str(uuid.uuid4()))
|
||||
clients, container=name, queue_name=str(uuid.uuid4()),
|
||||
generate_passwords=generate_passwords)
|
||||
|
||||
|
||||
class DeployPlan(command.Command):
|
||||
|
|
|
@ -124,7 +124,8 @@ def create_container(workflow_client, **input_):
|
|||
**input_)
|
||||
|
||||
|
||||
def create_plan_from_templates(clients, name, tht_root, roles_file=None):
|
||||
def create_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
generate_passwords=True):
|
||||
workflow_client = clients.workflow_engine
|
||||
swift_client = clients.tripleoclient.object_store
|
||||
|
||||
|
@ -139,10 +140,12 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None):
|
|||
print("Creating plan from template files in: {}".format(tht_root))
|
||||
_upload_templates(swift_client, name, tht_root, roles_file)
|
||||
create_deployment_plan(clients, container=name,
|
||||
queue_name=str(uuid.uuid4()))
|
||||
queue_name=str(uuid.uuid4()),
|
||||
generate_passwords=generate_passwords)
|
||||
|
||||
|
||||
def update_plan_from_templates(clients, name, tht_root, roles_file=None):
|
||||
def update_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
generate_passwords=True):
|
||||
swift_client = clients.tripleoclient.object_store
|
||||
|
||||
# TODO(dmatthews): Removing the existing plan files should probably be
|
||||
|
@ -168,4 +171,5 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None):
|
|||
print("Uploading new plan files")
|
||||
_upload_templates(swift_client, name, tht_root, roles_file)
|
||||
update_deployment_plan(clients, container=name,
|
||||
queue_name=str(uuid.uuid4()))
|
||||
queue_name=str(uuid.uuid4()),
|
||||
generate_passwords=generate_passwords)
|
||||
|
|
Loading…
Reference in New Issue