Revision a0724772 lib/client/gnt_node.py
b/lib/client/gnt_node.py | ||
---|---|---|
523 | 523 |
return constants.EXIT_SUCCESS |
524 | 524 |
|
525 | 525 |
|
526 |
def Health(opts, args): |
|
527 |
"""Show health of a node using OOB. |
|
528 |
|
|
529 |
@param opts: the command line options selected by the user |
|
530 |
@type args: list |
|
531 |
@param args: should contain only one element, the name of |
|
532 |
the node to be removed |
|
533 |
@rtype: int |
|
534 |
@return: the desired exit code |
|
535 |
|
|
536 |
""" |
|
537 |
op = opcodes.OpOobCommand(node_names=args, command=constants.OOB_HEALTH) |
|
538 |
result = SubmitOpCode(op, opts=opts) |
|
539 |
|
|
540 |
if opts.no_headers: |
|
541 |
headers = None |
|
542 |
else: |
|
543 |
headers = {"node": "Node", "status": "Status"} |
|
544 |
|
|
545 |
errs = 0 |
|
546 |
data = [] |
|
547 |
for node_result in result: |
|
548 |
(node_tuple, data_tuple) = node_result |
|
549 |
(_, node_name) = node_tuple |
|
550 |
(data_status, data_node) = data_tuple |
|
551 |
if data_status == constants.RS_NORMAL: |
|
552 |
data.append([node_name, "%s=%s" % tuple(data_node[0])]) |
|
553 |
for item, status in data_node[1:]: |
|
554 |
data.append(["", "%s=%s" % (item, status)]) |
|
555 |
else: |
|
556 |
errs += 1 |
|
557 |
data.append([node_name, cli.FormatResultError(data_status)]) |
|
558 |
|
|
559 |
data = GenerateTable(separator=opts.separator, headers=headers, |
|
560 |
fields=["node", "status"], data=data) |
|
561 |
|
|
562 |
for line in data: |
|
563 |
ToStdout(line) |
|
564 |
|
|
565 |
if errs: |
|
566 |
return constants.EXIT_FAILURE |
|
567 |
else: |
|
568 |
return constants.EXIT_SUCCESS |
|
569 |
|
|
570 |
|
|
526 | 571 |
def ListVolumes(opts, args): |
527 | 572 |
"""List logical volumes on node(s). |
528 | 573 |
|
... | ... | |
812 | 857 |
RemoveTags, [ArgNode(min=1, max=1), ArgUnknown()], |
813 | 858 |
[TAG_SRC_OPT, PRIORITY_OPT], |
814 | 859 |
"<node_name> tag...", "Remove tags from the given node"), |
860 |
"health": ( |
|
861 |
Health, ARGS_MANY_NODES, |
|
862 |
[NOHDR_OPT, SEP_OPT, SUBMIT_OPT, PRIORITY_OPT], |
|
863 |
"[<node_name>...]", "List health of node(s) using out-of-band"), |
|
815 | 864 |
} |
816 | 865 |
|
817 | 866 |
|
Also available in: Unified diff