X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fosmclient.git;a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fvnf.py;fp=osmclient%2Fcli_commands%2Fvnf.py;h=6c86ff7b60856a8df9479b10e4ba9260d020e755;hp=6e108345b07bc4a408657eea966c01d3fa0d6980;hb=9ba58bde6883dee6e6e6034232af0ff57772b70b;hpb=0046a316387d86e5df191b0aece617fcedeabb26 diff --git a/osmclient/cli_commands/vnf.py b/osmclient/cli_commands/vnf.py index 6e10834..6c86ff7 100755 --- a/osmclient/cli_commands/vnf.py +++ b/osmclient/cli_commands/vnf.py @@ -15,6 +15,7 @@ import click from osmclient.common.exceptions import ClientException +from osmclient.common import print_output from osmclient.cli_commands import utils from prettytable import PrettyTable import yaml @@ -26,7 +27,7 @@ import logging logger = logging.getLogger("osmclient") -def vnf_list(ctx, ns, filter, long): +def vnf_list(ctx, ns, filter, long, o): logger.debug("") if ns or filter: if ns: @@ -96,7 +97,8 @@ def vnf_list(ctx, ns, filter, long): ] ) table.align = "l" - print(table) + # print(table) + print_output.print_output(o, table.field_names, table._rows) @click.command(name="vnf-list", short_help="list all NF instances") @@ -110,11 +112,18 @@ def vnf_list(ctx, ns, filter, long): help="restricts the list to the NF instances matching the filter.", ) @click.option("--long", is_flag=True, help="get more details") +@click.option( + "-o", + default="table", + is_eager=True, + callback=print_output.validate_command_output, + help="adapt the output as table, yaml, csv, json, jsonpath", +) @click.pass_context -def vnf_list1(ctx, ns, filter, long): +def vnf_list1(ctx, ns, filter, long, o): """list all NF instances""" logger.debug("") - vnf_list(ctx, ns, filter, long) + vnf_list(ctx, ns, filter, long, o) @click.command(name="nf-list", short_help="list all NF instances") @@ -128,8 +137,15 @@ def vnf_list1(ctx, ns, filter, long): help="restricts the list to the NF instances matching the filter.", ) @click.option("--long", is_flag=True, help="get more details") +@click.option( + "-o", + default="table", + # is_eager=True, + # callback=print_output.validate_command_output, + help="adapt the output as table, yaml, csv, json, jsonpath", +) @click.pass_context -def nf_list(ctx, ns, filter, long): +def nf_list(ctx, ns, filter, long, o): """list all NF instances \b @@ -178,7 +194,7 @@ def nf_list(ctx, ns, filter, long): --filter vnfd-ref=,vdur.ip-address= """ logger.debug("") - vnf_list(ctx, ns, filter, long) + vnf_list(ctx, ns, filter, long, o) @click.command(name="vnf-show", short_help="shows the info of a VNF instance") @@ -190,8 +206,15 @@ def nf_list(ctx, ns, filter, long): help="restricts the information to the fields in the filter", ) @click.option("--kdu", default=None, help="KDU name (whose status will be shown)") +@click.option( + "-o", + default="table", + is_eager=True, + callback=print_output.validate_command_output, + help="adapt the output as table, yaml, csv, json, jsonpath", +) @click.pass_context -def vnf_show(ctx, name, literal, filter, kdu): +def vnf_show(ctx, name, literal, filter, kdu, o): """shows the info of a VNF instance NAME: name or ID of the VNF instance @@ -272,4 +295,5 @@ def vnf_show(ctx, name, literal, filter, kdu): if not filter or k in filter: table.add_row([k, utils.wrap_text(text=json.dumps(v, indent=2), width=100)]) table.align = "l" - print(table) + # print(table) + print_output.print_output(o, table.field_names, table._rows)