Repository: ambari Updated Branches: refs/heads/trunk f42404055 -> fbb6e7e4c
AMBARI-5899. Running upgradestack should require 3 args (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fbb6e7e4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fbb6e7e4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fbb6e7e4 Branch: refs/heads/trunk Commit: fbb6e7e4c89068f84e15ac3699459a7b72b001c4 Parents: f424040 Author: Andrew Onishuk <[email protected]> Authored: Tue May 27 18:30:31 2014 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Tue May 27 18:30:31 2014 +0300 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fbb6e7e4/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index 81dadbd..aa183e8 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -4011,7 +4011,7 @@ def setup_security(args): # Main. # def main(): - parser = optparse.OptionParser(usage="usage: %prog [options] action [stack_id]",) + parser = optparse.OptionParser(usage="usage: %prog [options] action [stack_id os]",) parser.add_option('-f', '--init-script-file', default='/var/lib/ambari-server/' @@ -4134,13 +4134,18 @@ def main(): action = args[0] if action == UPGRADE_STACK_ACTION: - args_number_required = 2 + possible_args_numbers = [2,4] # OR else: - args_number_required = 1 + possible_args_numbers = [1] - if len(args) < args_number_required: + matches = 0 + for args_number_required in possible_args_numbers: + matches += int(len(args) == args_number_required) + + if matches == 0: print parser.print_help() - parser.error("Invalid number of arguments. Entered: " + str(len(args)) + ", required: " + str(args_number_required)) + possible_args = ' or '.join(str(x) for x in possible_args_numbers) + parser.error("Invalid number of arguments. Entered: " + str(len(args)) + ", required: " + possible_args) options.exit_message = "Ambari Server '%s' completed successfully." % action need_restart = True
