From d6110c71181959f37bc77e4328effecea955daa4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 4 Sep 2018 09:56:51 -0400 Subject: [PATCH] Add -p to nodegroupattrib Also modify the man pages to reflect the updates. --- confluent_client/bin/nodegroupattrib | 16 +++++++++++++++- confluent_client/doc/man/nodeattrib.ronn | 3 +++ confluent_client/doc/man/nodegroupattrib.ronn | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodegroupattrib b/confluent_client/bin/nodegroupattrib index 29d95752..b066b284 100755 --- a/confluent_client/bin/nodegroupattrib +++ b/confluent_client/bin/nodegroupattrib @@ -47,6 +47,8 @@ argparser.add_option('-e', '--environment', action='store_true', 'same name') argparser.add_option('-c', '--clear', action='store_true', help='Clear variables') +argparser.add_option('-p', '--prompt', action='store_true', + help='Prompt for attribute values interactively') (options, args) = argparser.parse_args() @@ -72,7 +74,19 @@ if len(args) > 1: print("Can not clear and set at the same time!") argparser.print_help() sys.exit(1) - exitcode=client.updateattrib(session,args,nodetype, nodegroups, options) + argassign = None + if options.prompt: + argassign = {} + for arg in args[1:]: + oneval = 1 + twoval = 2 + while oneval != twoval: + oneval = getpass('Enter value for {0}: '.format(arg)) + twoval = getpass('Confirm value for {0}: '.format(arg)) + if oneval != twoval: + print('Values did not match.') + argassign[arg] = twoval + exitcode=client.updateattrib(session,args,nodetype, nodegroups, options, argassign) try: # setting user output to what the user inputs if args[1] == 'all': diff --git a/confluent_client/doc/man/nodeattrib.ronn b/confluent_client/doc/man/nodeattrib.ronn index 9e974e76..67606ced 100644 --- a/confluent_client/doc/man/nodeattrib.ronn +++ b/confluent_client/doc/man/nodeattrib.ronn @@ -7,6 +7,7 @@ nodeattrib(8) -- List or change confluent nodes attributes `nodeattrib [ ...]` `nodeattrib -c ...` `nodeattrib -e ...` +`nodeattrib -p ...` ## DESCRIPTION @@ -40,6 +41,8 @@ See nodegroupattrib(8) command on how to manage attributes on a group level. Clear specified nodeattributes * `-e`, `--environment`: Set specified attributes based on exported environment variable of matching name. Environment variable names may be lower case or all upper case. Replace . with _ as needed (e.g. info.note may be specified as either $info_note or $INFO_NOTE +* `-p`, `--prompt`: + Request interactive prompting to provide values rather than the command line or environment variables. ## EXAMPLES * Listing matching nodes of a simple noderange: diff --git a/confluent_client/doc/man/nodegroupattrib.ronn b/confluent_client/doc/man/nodegroupattrib.ronn index 57ada27c..6a16ef93 100644 --- a/confluent_client/doc/man/nodegroupattrib.ronn +++ b/confluent_client/doc/man/nodegroupattrib.ronn @@ -7,6 +7,7 @@ nodegroupattrib(8) -- List or change confluent nodegroup attributes `nodegroupattrib [...]` `nodegroupattrib [ ...]` `nodegroupattrib [-c] [ ...]` +`nodeattrib -p ...` ## DESCRIPTION