X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fvnf.py;h=59c8df4a06331aac95f9e42b23bda3f2df41806e;hb=refs%2Fheads%2Fv14.0;hp=974a421e811354cab31a8abed2a7fee3394ed1a9;hpb=cd7cd5eba8cfbb5f1941744ff90cf45e0ebcf422;p=osm%2Fosmclient.git diff --git a/osmclient/cli_commands/vnf.py b/osmclient/cli_commands/vnf.py index 974a421..59c8df4 100755 --- a/osmclient/cli_commands/vnf.py +++ b/osmclient/cli_commands/vnf.py @@ -38,8 +38,16 @@ def vnf_list(ctx, ns, filter, long, output): resp = ctx.obj.vnf.list(ns, filter) else: resp = ctx.obj.vnf.list() - fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == "osmclient.sol005.client.Client": + field_names = [ + "vnf id", + "name", + "ns id", + "vnf member index", + "vnfd name", + "vim account id", + "ip address", + ] + if long: field_names = [ "vnf id", "name", @@ -48,54 +56,30 @@ def vnf_list(ctx, ns, filter, long, output): "vnfd name", "vim account id", "ip address", + "date", + "last update", + ] + table = PrettyTable(field_names) + for vnfr in resp: + name = vnfr["name"] if "name" in vnfr else "-" + new_row = [ + vnfr["_id"], + name, + vnfr["nsr-id-ref"], + vnfr["member-vnf-index-ref"], + vnfr["vnfd-ref"], + vnfr["vim-account-id"], + vnfr["ip-address"], ] if long: - field_names = [ - "vnf id", - "name", - "ns id", - "vnf member index", - "vnfd name", - "vim account id", - "ip address", - "date", - "last update", - ] - table = PrettyTable(field_names) - for vnfr in resp: - name = vnfr["name"] if "name" in vnfr else "-" - new_row = [ - vnfr["_id"], - name, - vnfr["nsr-id-ref"], - vnfr["member-vnf-index-ref"], - vnfr["vnfd-ref"], - vnfr["vim-account-id"], - vnfr["ip-address"], - ] - if long: - date = datetime.fromtimestamp(vnfr["_admin"]["created"]).strftime( - "%Y-%m-%dT%H:%M:%S" - ) - last_update = datetime.fromtimestamp( - vnfr["_admin"]["modified"] - ).strftime("%Y-%m-%dT%H:%M:%S") - new_row.extend([date, last_update]) - table.add_row(new_row) - else: - table = PrettyTable(["vnf name", "id", "operational status", "config status"]) - for vnfr in resp: - if "mgmt-interface" not in vnfr: - vnfr["mgmt-interface"] = {} - vnfr["mgmt-interface"]["ip-address"] = None - table.add_row( - [ - vnfr["name"], - vnfr["id"], - vnfr["operational-status"], - vnfr["config-status"], - ] + date = datetime.fromtimestamp(vnfr["_admin"]["created"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + last_update = datetime.fromtimestamp(vnfr["_admin"]["modified"]).strftime( + "%Y-%m-%dT%H:%M:%S" ) + new_row.extend([date, last_update]) + table.add_row(new_row) print_output.print_output(output, table.field_names, table._rows)