diff --git a/lib/cli.py b/lib/cli.py index 798f866fd15ddaf466aa95d856c68c6ac5ec8f24..67b3fcc17b06c72ff633635a471ee4eae16883eb 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -54,6 +54,7 @@ __all__ = [ "DISKIDX_OPT", "DISK_OPT", "DISK_TEMPLATE_OPT", + "DRAINED_OPT", "FIELDS_OPT", "FILESTORE_DIR_OPT", "FILESTORE_DRIVER_OPT", @@ -65,6 +66,7 @@ __all__ = [ "IGNORE_FAILURES_OPT", "IGNORE_SIZE_OPT", "FORCE_OPT", + "MC_OPT", "NET_OPT", "NEW_SECONDARY_OPT", "NODE_LIST_OPT", @@ -78,6 +80,7 @@ __all__ = [ "NWSYNC_OPT", "ON_PRIMARY_OPT", "ON_SECONDARY_OPT", + "OFFLINE_OPT", "OS_OPT", "OS_SIZE_OPT", "READD_OPT", @@ -453,6 +456,9 @@ class CliOption(Option): cli_option = CliOption +_YESNO = ("yes", "no") +_YORNO = "yes|no" + DEBUG_OPT = cli_option("-d", "--debug", default=False, action="store_true", help="Turn debugging on") @@ -692,6 +698,19 @@ NOSSH_KEYCHECK_OPT = cli_option("--no-ssh-key-check", dest="ssh_key_check", help="Disable SSH key fingerprint checking") +MC_OPT = cli_option("-C", "--master-candidate", dest="master_candidate", + choices=_YESNO, default=None, metavar=_YORNO, + help="Set the master_candidate flag on the node") + +OFFLINE_OPT = cli_option("-O", "--offline", dest="offline", metavar=_YORNO, + choices=_YESNO, default=None, + help="Set the offline flag on the node") + +DRAINED_OPT = cli_option("-D", "--drained", dest="drained", metavar=_YORNO, + choices=_YESNO, default=None, + help="Set the drained flag on the node") + + def _ParseArgs(argv, commands, aliases): """Parser for the command line arguments. diff --git a/scripts/gnt-node b/scripts/gnt-node index ffaf8af84a1980b5040ef737611544f22fd9c353..941b356aadcf4198eddeeff0d5b3522101901d82 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -656,18 +656,7 @@ commands = { (", ".join(_LIST_HEADERS), ", ".join(_LIST_DEF_FIELDS))), 'modify': (SetNodeParams, ARGS_ONE_NODE, [DEBUG_OPT, FORCE_OPT, - SUBMIT_OPT, - cli_option("-C", "--master-candidate", dest="master_candidate", - choices=('yes', 'no'), default=None, - metavar="yes|no", - help="Set the master_candidate flag on the node"), - cli_option("-O", "--offline", dest="offline", metavar="yes|no", - choices=('yes', 'no'), default=None, - help="Set the offline flag on the node"), - cli_option("-D", "--drained", dest="drained", metavar="yes|no", - choices=('yes', 'no'), default=None, - help="Set the drained flag on the node"), - ], + SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT], "<node_name>", "Alters the parameters of a node"), 'powercycle': (PowercycleNode, ARGS_ONE_NODE, [DEBUG_OPT, FORCE_OPT, CONFIRM_OPT],