From: garciadeblas Date: Wed, 23 Sep 2020 11:08:19 +0000 (+0000) Subject: osm.py: reorganized commands related to pkg_repo_list to be together X-Git-Tag: release-v9.0-start~15 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=18f1fed0d116ffc4fd87296a358ab70d027305da;p=osm%2Fosmclient.git osm.py: reorganized commands related to pkg_repo_list to be together Fixes bug 1228 Change-Id: I2592465149c3135afa3a8b33935ced6016597bd5 Signed-off-by: garciadeblas --- diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index d71eaaa..0ff195f 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -469,28 +469,6 @@ def nsd_list2(ctx, filter, long): nsd_list(ctx, filter, long) -def pkg_repo_list(ctx, pkgtype, filter, repo, long): - if filter: - filter='&'.join(filter) - resp = ctx.obj.osmrepo.pkg_list(pkgtype, filter, repo) - if long: - table = PrettyTable(['nfpkg name', 'vendor', 'version', 'latest', 'description', 'repository']) - else: - table = PrettyTable(['nfpkg name', 'repository']) - for vnfd in resp: - name = vnfd.get('name', '-') - repository = vnfd.get('repository') - if long: - vendor = vnfd.get('vendor') - version = vnfd.get('version') - description = vnfd.get('description') - latest = vnfd.get('latest') - table.add_row([name, vendor, version, latest, description, repository]) - else: - table.add_row([name, repository]) - table.align = 'l' - print(table) - def vnfd_list(ctx, nf_type, filter, long): logger.debug("") if nf_type: @@ -568,6 +546,7 @@ def vnfd_list2(ctx, nf_type, filter, long): logger.debug("") vnfd_list(ctx, nf_type, filter, long) + @cli_osm.command(name='nfpkg-list', short_help='list all xNF packages (VNF, HNF, PNF)') @click.option('--nf_type', help='type of NF (vnf, pnf, hnf)') @click.option('--filter', default=None, multiple=True, @@ -584,6 +563,30 @@ def nfpkg_list(ctx, nf_type, filter, long): # print(str(e)) # exit(1) + +def pkg_repo_list(ctx, pkgtype, filter, repo, long): + if filter: + filter='&'.join(filter) + resp = ctx.obj.osmrepo.pkg_list(pkgtype, filter, repo) + if long: + table = PrettyTable(['nfpkg name', 'vendor', 'version', 'latest', 'description', 'repository']) + else: + table = PrettyTable(['nfpkg name', 'repository']) + for vnfd in resp: + name = vnfd.get('name', '-') + repository = vnfd.get('repository') + if long: + vendor = vnfd.get('vendor') + version = vnfd.get('version') + description = vnfd.get('description') + latest = vnfd.get('latest') + table.add_row([name, vendor, version, latest, description, repository]) + else: + table.add_row([name, repository]) + table.align = 'l' + print(table) + + @cli_osm.command(name='vnfpkg-repo-list', short_help='list all xNF from OSM repositories') @click.option('--filter', default=None, multiple=True, help='restricts the list to the NFpkg matching the filter') @@ -596,6 +599,7 @@ def nfpkg_repo_list1(ctx, filter, repo, long): pkgtype = 'vnf' pkg_repo_list(ctx, pkgtype, filter, repo, long) + @cli_osm.command(name='nfpkg-repo-list', short_help='list all xNF from OSM repositories') @click.option('--filter', default=None, multiple=True, help='restricts the list to the NFpkg matching the filter') @@ -608,6 +612,33 @@ def nfpkg_repo_list2(ctx, filter, repo, long): pkgtype = 'vnf' pkg_repo_list(ctx, pkgtype, filter, repo, long) + +@cli_osm.command(name='nsd-repo-list', short_help='list all NS from OSM repositories') +@click.option('--filter', default=None, multiple=True, + help='restricts the list to the NS matching the filter') +@click.option('--repo', default=None, + help='restricts the list to a particular OSM repository') +@click.option('--long', is_flag=True, help='get more details') +@click.pass_context +def nspkg_repo_list(ctx, filter, repo, long): + """list xNF packages from OSM repositories""" + pkgtype = 'ns' + pkg_repo_list(ctx, pkgtype, filter, repo, long) + + +@cli_osm.command(name='nspkg-repo-list', short_help='list all NS from OSM repositories') +@click.option('--filter', default=None, multiple=True, + help='restricts the list to the NS matching the filter') +@click.option('--repo', default=None, + help='restricts the list to a particular OSM repository') +@click.option('--long', is_flag=True, help='get more details') +@click.pass_context +def nspkg_repo_list2(ctx, filter, repo, long): + """list xNF packages from OSM repositories""" + pkgtype = 'ns' + pkg_repo_list(ctx, pkgtype, filter, repo, long) + + def vnf_list(ctx, ns, filter, long): # try: if ns or filter: @@ -671,29 +702,6 @@ def vnf_list1(ctx, ns, filter, long): logger.debug("") vnf_list(ctx, ns, filter, long) -@cli_osm.command(name='nsd-repo-list', short_help='list all NS from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NS matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') -@click.pass_context -def nspkg_repo_list(ctx, filter, repo, long): - """list xNF packages from OSM repositories""" - pkgtype = 'ns' - pkg_repo_list(ctx, pkgtype, filter, repo, long) - -@cli_osm.command(name='nspkg-repo-list', short_help='list all NS from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NS matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') -@click.pass_context -def nspkg_repo_list2(ctx, filter, repo, long): - """list xNF packages from OSM repositories""" - pkgtype = 'ns' - pkg_repo_list(ctx, pkgtype, filter, repo, 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')