X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=b2caff0dd7d85288371535ffd262fda4a7828d6b;hb=refs%2Fchanges%2F49%2F8549%2F13;hp=d922ce50e0a9217dc370c47a6bed99237813b33a;hpb=26795d187e2555865ac0daf9fe8834e5d21db31a;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index d922ce5..b2caff0 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -97,6 +97,12 @@ def check_client_version(obj, what, version='sol005'): 'Also can set OSM_PROJECT in environment') @click.option('-v', '--verbose', count=True, help='increase verbosity (-v INFO, -vv VERBOSE, -vvv DEBUG)') +@click.option('--all-projects', + default=False, + is_flag=True, + help='include all projects') +@click.option('--public/--no-public', default=None, + help='flag for public items (packages, instances, VIM accounts, etc.)') #@click.option('--so-port', # default=None, # envvar='OSM_SO_PORT', @@ -118,7 +124,7 @@ def check_client_version(obj, what, version='sol005'): # help='hostname of RO server. ' + # 'Also can set OSM_RO_PORT in environment') @click.pass_context -def cli_osm(ctx, hostname, user, password, project, verbose): +def cli_osm(ctx, hostname, user, password, project, verbose, all_projects, public): global logger if hostname is None: print(( @@ -141,6 +147,10 @@ def cli_osm(ctx, hostname, user, password, project, verbose): kwargs['password']=password if project is not None: kwargs['project']=project + if all_projects: + kwargs['all_projects']=all_projects + if public is not None: + kwargs['public']=public ctx.obj = client.Client(host=hostname, sol005=sol005, **kwargs) logger = logging.getLogger('osmclient') @@ -526,7 +536,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 +551,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 +591,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 +1424,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):