Commit 771734c9 authored by Iustin Pop's avatar Iustin Pop

Move the node flags options to cli.py

This also unifies a little the parameters to the respective options.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent fcdde7f2
......@@ -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.
......
......@@ -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],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment