From 145c6e23900e382494ead9d50f90e6b5665d679a Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Tue, 28 Oct 2014 11:43:25 +0100 Subject: [PATCH] Allow --default-password with --gen-answer-file Previously, it was not possible to specify a default password when creating an answer file. This patch fixes that by allowing to run "packstack --gen-answer-file= --default-password= / packstack --answer-file= +- packstack --gen-answer-file= [--default-password=] / packstack --answer-file= -The third option allows the user to generate a default answer file, edit the default options and finally run Packstack a second time using this answer file. This is the easiest way to run Packstack and the one that will be documented here. When is created, it will contain the OPTIONS below, which can then be edited by the user. +The third option allows the user to generate a default answer file, edit the default options and finally run Packstack a second time using this answer file. This is the easiest way to run Packstack and the one that will be documented here. Optionally, it is possible to specify a default password when generating the answer file, and this default password will be used for all accounts. + +When is created, it will contain the OPTIONS below, which can then be edited by the user. OPTIONS ======= diff --git a/packstack/installer/run_setup.py b/packstack/installer/run_setup.py index e1058aa6c..22102483e 100644 --- a/packstack/installer/run_setup.py +++ b/packstack/installer/run_setup.py @@ -857,7 +857,7 @@ def countCmdLineFlags(options, flag): counter = 0 # make sure only flag was supplied for key, value in options.__dict__.items(): - if key in (flag, 'debug', 'timeout', 'dry_run'): + if key in (flag, 'debug', 'timeout', 'dry_run', 'default_password'): next # If anything but flag was called, increment elif value: @@ -924,7 +924,12 @@ def main(): if not answerfilepath: _printAdditionalMessages() return - generateAnswerFile(answerfilepath) + # We can also override defaults with command line options + overrides = {} + _set_command_line_values(options) + for key,value in commandLineValues.items(): + overrides[key] = value + generateAnswerFile(answerfilepath,overrides) _handleParams(answerfilepath) generateAnswerFile(options.gen_answer_file) # Are we installing an all in one @@ -942,6 +947,12 @@ def main(): # Make sure only --answer-file was supplied if options.answer_file: validateSingleFlag(options, "answer_file") + # If using an answer file, setting a default password + # does not really make sense + if getattr(options,'default_password',None): + msg = ('Please do not set --default-password ' + 'when specifying an answer file.') + raise FlagValidationError(msg) confFile = os.path.expanduser(options.answer_file) if not os.path.exists(confFile): raise Exception(output_messages.ERR_NO_ANSWER_FILE % confFile)