Merge "Add --yes to overcloud node provision for output file overwrite" into stable/wallaby
This commit is contained in:
commit
8b8cda5bd8
@ -337,10 +337,12 @@ class TestProvisionNode(fakes.TestOvercloudNode):
|
||||
|
||||
argslist = ['--output', outp.name,
|
||||
'--overcloud-ssh-key', keyf.name,
|
||||
'--yes',
|
||||
inp.name]
|
||||
verifylist = [('input', inp.name),
|
||||
('output', outp.name),
|
||||
('overcloud_ssh_key', keyf.name)]
|
||||
('overcloud_ssh_key', keyf.name),
|
||||
('yes', True)]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd,
|
||||
argslist, verifylist)
|
||||
@ -363,6 +365,7 @@ class TestProvisionNode(fakes.TestOvercloudNode):
|
||||
'configure_networking': False,
|
||||
'working_dir': mock.ANY,
|
||||
'templates': constants.TRIPLEO_HEAT_TEMPLATES,
|
||||
'overwrite': True,
|
||||
},
|
||||
inventory='localhost,',
|
||||
playbook='cli-overcloud-node-provision.yaml',
|
||||
|
@ -235,6 +235,9 @@ class ProvisionNode(command.Command):
|
||||
parser.add_argument('-o', '--output',
|
||||
default='baremetal_environment.yaml',
|
||||
help=_('The output environment file path'))
|
||||
parser.add_argument('-y', '--yes', default=False, action='store_true',
|
||||
help=_('Skip yes/no prompt for existing files '
|
||||
'(assume yes).'))
|
||||
parser.add_argument('--stack', dest='stack',
|
||||
help=_('Name or ID of heat stack '
|
||||
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||
@ -289,6 +292,18 @@ class ProvisionNode(command.Command):
|
||||
'This option is no longer used, network ports '
|
||||
'are always managed.')
|
||||
|
||||
output_path = os.path.abspath(parsed_args.output)
|
||||
|
||||
overwrite = parsed_args.yes
|
||||
if (os.path.exists(output_path) and not overwrite
|
||||
and not oooutils.prompt_user_for_confirmation(
|
||||
'Overwrite existing file %s [y/N]?' % parsed_args.output,
|
||||
self.log)):
|
||||
raise oscexc.CommandError("Will not overwrite existing file:"
|
||||
" %s" % parsed_args.output)
|
||||
else:
|
||||
overwrite = True
|
||||
|
||||
if not parsed_args.working_dir:
|
||||
working_dir = oooutils.get_default_working_dir(
|
||||
parsed_args.stack)
|
||||
@ -307,8 +322,6 @@ class ProvisionNode(command.Command):
|
||||
with open('{}.pub'.format(key), 'rt') as fp:
|
||||
ssh_key = fp.read()
|
||||
|
||||
output_path = os.path.abspath(parsed_args.output)
|
||||
|
||||
extra_vars = {
|
||||
"stack_name": parsed_args.stack,
|
||||
"baremetal_deployment": roles,
|
||||
@ -322,6 +335,7 @@ class ProvisionNode(command.Command):
|
||||
"configure_networking": parsed_args.network_config,
|
||||
"working_dir": working_dir,
|
||||
"templates": parsed_args.templates,
|
||||
"overwrite": overwrite,
|
||||
}
|
||||
|
||||
with oooutils.TempDirs() as tmp:
|
||||
|
Loading…
Reference in New Issue
Block a user