diff --git a/confluent_client/bin/nodebmcpassword b/confluent_client/bin/nodebmcpassword index ccaebac4..f76b076c 100755 --- a/confluent_client/bin/nodebmcpassword +++ b/confluent_client/bin/nodebmcpassword @@ -17,6 +17,7 @@ __author__ = 'tkucherera' +from getpass import getpass import optparse import os import signal @@ -36,25 +37,49 @@ import confluent.client as client argparser = optparse.OptionParser(usage="Usage: %prog ") argparser.add_option('-m', '--maxnodes', type='int', help='Number of nodes to affect before prompting for confirmation') +argparser.add_option('-p', '--prompt', action='store_true', + help='Prompt for password values interactively') +argparser.add_option('-e', '--environment', action='store_true', + help='Set passwod, but from environment variable of ' + 'same name') (options, args) = argparser.parse_args() + + try: noderange = args[0] username = args[1] - new_password = args[2] except IndexError: argparser.print_help() sys.exit(1) + client.check_globbing(noderange) session = client.Command() exitcode = 0 +if options.prompt: + oneval = 1 + twoval = 2 + while oneval != twoval: + oneval = getpass('Enter pass for {0}: '.format(username)) + twoval = getpass('Confirm pass for {0}: '.format(username)) + if oneval != twoval: + print('Values did not match.') + new_password = twoval - +elif len(args) == 3: + if options.environment: + key = args[2] + new_password = os.environ.get(key, os.environ[key.upper()]) + else: + new_password = args[2] +else: + argparser.print_help() + sys.exit(1) + errorNodes = set([]) - uid_dict = {} session.stop_if_noderange_over(noderange, options.maxnodes)