Add JSON output format for node info
This commit is contained in:
parent
1093ca6264
commit
f2d2537e1c
|
@ -697,15 +697,29 @@ def node_log(node, lines, follow):
|
|||
default=False,
|
||||
help="Display more detailed information.",
|
||||
)
|
||||
@click.option(
|
||||
"-f",
|
||||
"--format",
|
||||
"oformat",
|
||||
default="plain",
|
||||
show_default=True,
|
||||
type=click.Choice(["plain", "json", "json-pretty"]),
|
||||
help="Output format of node status information.",
|
||||
)
|
||||
@cluster_req
|
||||
def node_info(node, long_output):
|
||||
def node_info(node, long_output, oformat):
|
||||
"""
|
||||
Show information about node NODE. If unspecified, defaults to this host.
|
||||
"""
|
||||
|
||||
retcode, retdata = pvc_node.node_info(config, node)
|
||||
if retcode:
|
||||
retdata = pvc_node.format_info(retdata, long_output)
|
||||
if oformat == "json":
|
||||
retdata = json.dumps(retdata)
|
||||
elif oformat == "json-pretty":
|
||||
retdata = json.dumps(retdata, indent=4)
|
||||
else:
|
||||
retdata = pvc_node.format_info(retdata, long_output)
|
||||
cleanup(retcode, retdata)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue