X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fvim.py;h=2f7bbfc75adf37229e55a3f4e05402366bccf31e;hb=5b988dbe705784bf927915aa32d3a4aca0c1f308;hp=ff1bcc639de0557883b75a7f1d9e2c9f6dcd9679;hpb=e6e9ebfa7cc4d9c3d0bda4a2dcab7f337af63baf;p=osm%2Fosmclient.git diff --git a/osmclient/cli_commands/vim.py b/osmclient/cli_commands/vim.py index ff1bcc6..2f7bbfc 100755 --- a/osmclient/cli_commands/vim.py +++ b/osmclient/cli_commands/vim.py @@ -14,6 +14,7 @@ # under the License. import click +from osmclient.common import print_output from osmclient.cli_commands import utils from prettytable import PrettyTable import yaml @@ -303,16 +304,15 @@ def vim_delete(ctx, name, force, wait): is_flag=True, help="get more details of the NS (project, vim, deployment status, configuration status.", ) +@print_output.output_option @click.pass_context -def vim_list(ctx, filter, long): +def vim_list(ctx, filter, long, output): """list all VIM accounts""" logger.debug("") if filter: filter = "&".join(filter) utils.check_client_version(ctx.obj, "--filter") - fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == "osmclient.sol005.client.Client": - resp = ctx.obj.vim.list(filter) + resp = ctx.obj.vim.list(filter) if long: table = PrettyTable( ["vim name", "uuid", "project", "operational state", "error details"] @@ -347,8 +347,7 @@ def vim_list(ctx, filter, long): table.add_row( [vim["name"], vim["uuid"], vim["_admin"].get("operationalState", "-")] ) - table.align = "l" - print(table) + print_output.print_output(output, table.field_names, table._rows) @click.command(name="vim-show", short_help="shows the details of a VIM account") @@ -359,8 +358,9 @@ def vim_list(ctx, filter, long): help="restricts the information to the fields in the filter", ) @click.option("--literal", is_flag=True, help="print literally, no pretty table") +@print_output.output_option @click.pass_context -def vim_show(ctx, name, filter, literal): +def vim_show(ctx, name, filter, literal, output): """shows the details of a VIM account NAME: name or ID of the VIM account @@ -379,5 +379,4 @@ def vim_show(ctx, name, filter, literal): for k, v in list(resp.items()): 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_output.print_output(output, table.field_names, table._rows)