Revision fed67843 lib/client/gnt_node.py
b/lib/client/gnt_node.py | ||
---|---|---|
114 | 114 |
help=("Ignore the Node(s) offline status" |
115 | 115 |
" (potentially DANGEROUS)")) |
116 | 116 |
|
117 |
FORCE_MASTER_OPT = cli_option("--force-master", default=False, |
|
118 |
action="store_true", dest="force_master", |
|
119 |
help=("Operate on the master node too" |
|
120 |
" (potentially DANGEROUS)")) |
|
121 |
|
|
122 | 117 |
OOB_TIMEOUT_OPT = cli_option("--oob-timeout", dest="oob_timeout", type="int", |
123 | 118 |
default=constants.OOB_TIMEOUT, |
124 | 119 |
help="Maximum time to wait for out-of-band helper") |
125 | 120 |
|
126 |
|
|
127 | 121 |
def ConvertStorageType(user_storage_type): |
128 | 122 |
"""Converts a user storage type to its internal name. |
129 | 123 |
|
... | ... | |
495 | 489 |
@return: the desired exit code |
496 | 490 |
|
497 | 491 |
""" |
498 |
client = GetClient() |
|
499 | 492 |
command = args.pop(0) |
500 | 493 |
|
501 | 494 |
if opts.no_headers: |
... | ... | |
507 | 500 |
ToStderr("power subcommand %s not supported." % command) |
508 | 501 |
return constants.EXIT_FAILURE |
509 | 502 |
|
510 |
nodes = [node for (node, ) in client.QueryNodes(args, ["name"], False)] |
|
511 | 503 |
oob_command = "power-%s" % command |
512 | 504 |
|
513 | 505 |
if oob_command in _OOB_COMMAND_ASK: |
514 |
if not args and not opts.show_all: |
|
515 |
ToStderr("Please provide at least one node or use --all for this command" |
|
516 |
" as this is a potentially harmful command") |
|
517 |
return constants.EXIT_FAILURE |
|
518 |
elif args and opts.show_all: |
|
519 |
ToStderr("Please provide either nodes or use --all, can not use both at" |
|
520 |
" the same time") |
|
506 |
if not args: |
|
507 |
ToStderr("Please provide at least one node for this command") |
|
521 | 508 |
return constants.EXIT_FAILURE |
522 |
elif not opts.force and not ConfirmOperation(nodes, "nodes",
|
|
509 |
elif not opts.force and not ConfirmOperation(args, "nodes",
|
|
523 | 510 |
"power %s" % command): |
524 | 511 |
return constants.EXIT_FAILURE |
512 |
assert len(args) > 0 |
|
525 | 513 |
|
526 | 514 |
opcodelist = [] |
527 | 515 |
if not opts.ignore_status and oob_command == constants.OOB_POWER_OFF: |
528 | 516 |
# TODO: This is a little ugly as we can't catch and revert |
529 |
for node in nodes:
|
|
517 |
for node in args:
|
|
530 | 518 |
opcodelist.append(opcodes.OpNodeSetParams(node_name=node, offline=True, |
531 | 519 |
auto_promote=opts.auto_promote)) |
532 | 520 |
|
533 |
opcodelist.append(opcodes.OpOobCommand(node_names=nodes,
|
|
521 |
opcodelist.append(opcodes.OpOobCommand(node_names=args,
|
|
534 | 522 |
command=oob_command, |
535 | 523 |
ignore_status=opts.ignore_status, |
536 |
force_master=opts.force_master, |
|
537 | 524 |
timeout=opts.oob_timeout)) |
538 | 525 |
|
539 | 526 |
cli.SetGenericOpcodeOpts(opcodelist, opts) |
... | ... | |
870 | 857 |
[ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS), |
871 | 858 |
ArgNode()], |
872 | 859 |
[SUBMIT_OPT, AUTO_PROMOTE_OPT, PRIORITY_OPT, IGNORE_STATUS_OPT, |
873 |
FORCE_MASTER_OPT, FORCE_OPT, NOHDR_OPT, SEP_OPT, ALL_OPT, |
|
874 |
OOB_TIMEOUT_OPT], |
|
860 |
FORCE_OPT, NOHDR_OPT, SEP_OPT, OOB_TIMEOUT_OPT], |
|
875 | 861 |
"on|off|cycle|status [nodes...]", |
876 | 862 |
"Change power state of node by calling out-of-band helper."), |
877 | 863 |
'remove': ( |
Also available in: Unified diff