X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=5c6d3badf53c0b1b8a1413219cf527467708dc80;hb=refs%2Fchanges%2F09%2F8609%2F2;hp=d922ce50e0a9217dc370c47a6bed99237813b33a;hpb=26795d187e2555865ac0daf9fe8834e5d21db31a;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index d922ce5..5c6d3ba 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -526,7 +526,7 @@ def nfpkg_list(ctx, nf_type, filter, long): # exit(1) -def vnf_list(ctx, ns, filter): +def vnf_list(ctx, ns, filter, long): # try: if ns or filter: if ns: @@ -541,24 +541,23 @@ def vnf_list(ctx, ns, filter): # exit(1) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ if fullclassname == 'osmclient.sol005.client.Client': - table = PrettyTable( - ['vnf id', - 'name', - 'ns id', - 'vnf member index', - 'vnfd name', - 'vim account id', - 'ip address']) + field_names = ['vnf id', 'name', 'ns id', 'vnf member index', + 'vnfd name', 'vim account id', '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 '-' - table.add_row( - [vnfr['_id'], - name, - vnfr['nsr-id-ref'], - vnfr['member-vnf-index-ref'], - vnfr['vnfd-ref'], - vnfr['vim-account-id'], - vnfr['ip-address']]) + 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', @@ -582,19 +581,21 @@ def vnf_list(ctx, ns, filter): @click.option('--ns', default=None, help='NS instance id or name to restrict the NF list') @click.option('--filter', default=None, help='restricts the list to the NF instances matching the filter.') +@click.option('--long', is_flag=True, help='get more details') @click.pass_context -def vnf_list1(ctx, ns, filter): +def vnf_list1(ctx, ns, filter, long): """list all NF instances""" logger.debug("") - vnf_list(ctx, ns, filter) + vnf_list(ctx, ns, filter, long) @cli_osm.command(name='nf-list', short_help='list all NF instances') @click.option('--ns', default=None, help='NS instance id or name to restrict the NF list') @click.option('--filter', default=None, help='restricts the list to the NF instances matching the filter.') +@click.option('--long', is_flag=True, help='get more details') @click.pass_context -def nf_list(ctx, ns, filter): +def nf_list(ctx, ns, filter, long): """list all NF instances \b @@ -1413,13 +1414,13 @@ def nsd_create1(ctx, filename, overwrite, skip_charm_build): @click.option('--skip-charm-build', default=False, is_flag=True, help='The charm will not be compiled, it is assumed to already exist') @click.pass_context -def nsd_create2(ctx, charm_folder, overwrite, skip_charm_build): +def nsd_create2(ctx, filename, overwrite, skip_charm_build): """creates a new NSD/NSpkg FILENAME: NSD folder, NSD yaml file or NSpkg tar.gz file """ logger.debug("") - nsd_create(ctx, charm_folder, overwrite=overwrite, skip_charm_build=skip_charm_build) + nsd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build) def vnfd_create(ctx, filename, overwrite, skip_charm_build):