projects
/
osm
/
osmclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New global option to adapt output format
[osm/osmclient.git]
/
osmclient
/
cli_commands
/
ns.py
diff --git
a/osmclient/cli_commands/ns.py
b/osmclient/cli_commands/ns.py
index
f598e35
..
441ae05
100755
(executable)
--- a/
osmclient/cli_commands/ns.py
+++ b/
osmclient/cli_commands/ns.py
@@
-15,6
+15,7
@@
import click
from osmclient.common.exceptions import ClientException
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
from osmclient.cli_commands import utils
from prettytable import PrettyTable
import yaml
@@
-37,8
+38,15
@@
logger = logging.getLogger("osmclient")
is_flag=True,
help="get more details of the NS (project, vim, deployment status, configuration status.",
)
is_flag=True,
help="get more details of the NS (project, vim, deployment status, configuration status.",
)
+@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
@click.pass_context
-def ns_list(ctx, filter, long):
+def ns_list(ctx, filter, long
, o
):
"""list all NS instances
\b
"""list all NS instances
\b
@@
-295,7
+303,8
@@
def ns_list(ctx, filter, long):
]
)
table.align = "l"
]
)
table.align = "l"
- print(table)
+ # print(table)
+ print_output.print_output(o, table.field_names, table._rows)
print('To get the history of all operations over a NS, run "osm ns-op-list NS_ID"')
print(
'For more details on the current operation, run "osm ns-op-show OPERATION_ID"'
print('To get the history of all operations over a NS, run "osm ns-op-list NS_ID"')
print(
'For more details on the current operation, run "osm ns-op-show OPERATION_ID"'
@@
-310,8
+319,15
@@
def ns_list(ctx, filter, long):
multiple=True,
help="restricts the information to the fields in the filter",
)
multiple=True,
help="restricts the information to the fields in the filter",
)
+@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
@click.pass_context
-def ns_show(ctx, name, literal, filter):
+def ns_show(ctx, name, literal, filter
, o
):
"""shows the info of a NS instance
NAME: name or ID of the NS instance
"""shows the info of a NS instance
NAME: name or ID of the NS instance
@@
-337,7
+353,8
@@
def ns_show(ctx, name, literal, filter):
if not filter or k in filter:
table.add_row([k, utils.wrap_text(json.dumps(v, indent=2), width=100)])
table.align = "l"
if not filter or k in filter:
table.add_row([k, utils.wrap_text(json.dumps(v, indent=2), width=100)])
table.align = "l"
- print(table)
+ print_output.print_output(o, table.field_names, table._rows)
+ # print(table)
@click.command(name="ns-create", short_help="creates a new Network Service instance")
@click.command(name="ns-create", short_help="creates a new Network Service instance")