####################
@cli_osm.command(name='ns-list', short_help='list all NS instances')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NS instances matching the filter.')
@click.option('--long', is_flag=True,
help='get more details of the NS (project, vim, deployment status, configuration status.')
if ee['elementType'] not in status_ee:
status_ee[ee['elementType']] = {}
status_ee[ee['elementType']][ee['status']] = 1
- continue;
+ continue
if ee['status'] in status_ee[ee['elementType']]:
status_ee[ee['elementType']][ee['status']] += 1
else:
logger.debug("")
if filter:
check_client_version(ctx.obj, '--filter')
+ filter='&'.join(filter)
resp = ctx.obj.ns.list(filter)
else:
resp = ctx.obj.ns.list()
else:
current_operation = "{} ({})".format(nsr['_admin'].get('current-operation','-'), nsr['_admin']['nslcmop'])
error_details = "N/A"
- if ns_state == "BROKEN" or ns_state == "DEGRADED" or nsr.get('errorDescription'):
+ if ns_state == "BROKEN" or ns_state == "DEGRADED" or \
+ ('currentOperation' not in nsr and nsr.get('errorDescription')):
error_details = "{}\nDetail: {}".format(nsr['errorDescription'], nsr['errorDetail'])
else:
nsopdata = ctx.obj.ns.get_opdata(ns['id'])
logger.debug("")
if filter:
check_client_version(ctx.obj, '--filter')
+ filter='&'.join(filter)
resp = ctx.obj.nsd.list(filter)
else:
resp = ctx.obj.nsd.list()
@cli_osm.command(name='nsd-list', short_help='list all NS packages')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NSD/NSpkg matching the filter')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
@cli_osm.command(name='nspkg-list', short_help='list all NS packages')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NSD/NSpkg matching the filter')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
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'])
check_client_version(ctx.obj, '--nf_type')
elif filter:
check_client_version(ctx.obj, '--filter')
+ if filter:
+ filter='&'.join(filter)
if nf_type:
if nf_type == "vnf":
nf_filter = "_admin.type=vnfd"
@cli_osm.command(name='vnfd-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,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NF pkg matching the filter')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
@cli_osm.command(name='vnfpkg-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,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NFpkg matching the filter')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
logger.debug("")
vnfd_list(ctx, nf_type, filter, long)
-@cli_osm.command(name='vnfpkg-repo-list', short_help='list all xNF from OSM repositories')
-@click.option('--filter', default=None,
- help='restricts the list to the NFpkg 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 vnfd_list3(ctx, filter, repo, long):
- """list xNF packages from OSM repositories"""
- pkgtype = 'vnf'
- pkg_repo_list(ctx, pkgtype, filter, repo, 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,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NFpkg matching the filter')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
# print(str(e))
# exit(1)
+@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')
+@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 nfpkg_repo_list1(ctx, filter, repo, long):
+ """list xNF packages from OSM repositories"""
+ 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,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NFpkg 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 vnfd_list4(ctx, filter, repo, long):
+def nfpkg_repo_list2(ctx, filter, repo, long):
"""list xNF packages from OSM repositories"""
pkgtype = 'vnf'
pkg_repo_list(ctx, pkgtype, filter, repo, long)
if ns:
check_client_version(ctx.obj, '--ns')
if filter:
+ filter='&'.join(filter)
check_client_version(ctx.obj, '--filter')
resp = ctx.obj.vnf.list(ns, filter)
else:
@cli_osm.command(name='vnf-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,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NF instances matching the filter.')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
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,
+@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 nsd_list3(ctx, filter, repo, long):
+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,
+@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_list(ctx, filter, repo, long):
+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')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NF instances matching the filter.')
@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
if op['lcmOperationType']=='action':
action_name = op['operationParams']['primitive']
detail = "-"
- if op['operationState']=='PROCESSING':
- if op['lcmOperationType'] in ('instantiate', 'terminate'):
+ if op['operationState'] == 'PROCESSING':
+ if op['queuePosition'] is not None and op['queuePosition'] > 0:
+ detail = "In queue. Current position: {}".format(op['queuePosition'])
+ elif op['lcmOperationType'] in ('instantiate', 'terminate'):
if op['stage']:
detail = op['stage']
- else:
- detail = "In queue. Current position: {}".format(op['queuePosition'])
elif op['operationState'] in ('FAILED', 'FAILED_TEMP'):
detail = op.get('errorMessage','-')
date = datetime.fromtimestamp(op['startTime']).strftime("%Y-%m-%dT%H:%M:%S")
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.nsi.list(filter)
# except ClientException as e:
# print(str(e))
@cli_osm.command(name='nsi-list', short_help='list all Network Slice Instances (NSI)')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the Network Slice Instances matching the filter')
@click.pass_context
def nsi_list1(ctx, filter):
@cli_osm.command(name='netslice-instance-list', short_help='list all Network Slice Instances (NSI)')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the Network Slice Instances matching the filter')
@click.pass_context
def nsi_list2(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.nst.list(filter)
# except ClientException as e:
# print(str(e))
@cli_osm.command(name='nst-list', short_help='list all Network Slice Templates (NST)')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NST matching the filter')
@click.pass_context
def nst_list1(ctx, filter):
@cli_osm.command(name='netslice-template-list', short_help='list all Network Slice Templates (NST)')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the NST matching the filter')
@click.pass_context
def nst_list2(ctx, filter):
@cli_osm.command(name='pdu-list', short_help='list all Physical Deployment Units (PDU)')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the Physical Deployment Units matching the filter')
@click.pass_context
def pdu_list(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.pdu.list(filter)
# except ClientException as e:
# print(str(e))
# exit(1)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
print(table)
-@cli_osm.command(name='nsd-show', short_help='shows the content of a NSD')
+@cli_osm.command(name='nsd-show', short_help='shows the details of a NS package')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.argument('name')
nsd_show(ctx, name, literal)
-@cli_osm.command(name='nspkg-show', short_help='shows the content of a NSD')
+@cli_osm.command(name='nspkg-show', short_help='shows the details of a NS package')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.argument('name')
# exit(1)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
def pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal):
logger.debug("")
+ if filter:
+ filter='&'.join(filter)
# try:
resp = ctx.obj.osmrepo.pkg_get(pkgtype, name, repo, version, filter)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
pkgtype += 'd'
catalog = pkgtype + '-catalog'
table.align = 'l'
print(table)
-@cli_osm.command(name='vnfd-show', short_help='shows the content of a VNFD')
+
+@cli_osm.command(name='vnfd-show', short_help='shows the details of a NF package')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.argument('name')
vnfd_show(ctx, name, literal)
-@cli_osm.command(name='vnfpkg-show', short_help='shows the content of a VNFD')
+@cli_osm.command(name='vnfpkg-show', short_help='shows the details of a NF package')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.argument('name')
logger.debug("")
vnfd_show(ctx, name, literal)
-@cli_osm.command(name='vnfpkg-repo-show', short_help='shows the content of a VNFD')
+
+@cli_osm.command(name='vnfpkg-repo-show', short_help='shows the details of a NF package in an OSM repository')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.option('--repo',
required=True,
help='Repository name')
@click.argument('name')
-@click.option('--filter',
+@click.option('--filter', default=None, multiple=True,
help='filter by fields')
@click.option('--version',
default='latest',
pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal)
-@cli_osm.command(name='nsd-repo-show', short_help='shows the content of a NSD')
+@cli_osm.command(name='nsd-repo-show', short_help='shows the details of a NS package in an OSM repository')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.option('--repo',
required=True,
help='Repository name')
@click.argument('name')
-@click.option('--filter',
+@click.option('--filter', default=None, multiple=True,
help='filter by fields')
@click.option('--version',
default='latest',
pkgtype = 'ns'
pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal)
-@cli_osm.command(name='nspkg-repo-show', short_help='shows the content of a NSD')
+
+@cli_osm.command(name='nspkg-repo-show', short_help='shows the details of a NS package in an OSM repository')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.option('--repo',
required=True,
help='Repository name')
@click.argument('name')
-@click.option('--filter',
+@click.option('--filter', default=None, multiple=True,
help='filter by fields')
@click.option('--version',
default='latest',
pkgtype = 'ns'
pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal)
-@cli_osm.command(name='nfpkg-show', short_help='shows the content of a NF Descriptor')
+
+@cli_osm.command(name='nfpkg-show', short_help='shows the details of a NF package')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.argument('name')
vnfd_show(ctx, name, literal)
-@cli_osm.command(name='nfpkg-repo-show', short_help='shows the content of a VNFD')
+@cli_osm.command(name='nfpkg-repo-show', short_help='shows the details of a NF package in an OSM repository')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.option('--repo',
required=True,
help='Repository name')
@click.argument('name')
-@click.option('--filter',
+@click.option('--filter', default=None, multiple=True,
help='filter by fields')
@click.option('--version',
default='latest',
@click.argument('name')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def ns_show(ctx, name, literal, filter):
"""shows the info of a NS instance
# exit(1)
if literal:
- print(yaml.safe_dump(ns))
+ print(yaml.safe_dump(ns, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
for k, v in list(ns.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)])
fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
nsopdata = ctx.obj.ns.get_opdata(ns['id'])
nsr_optdata = nsopdata['nsr:nsr']
for k, v in list(nsr_optdata.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, wrap_text(json.dumps(v, indent=2),width=100)])
table.align = 'l'
print(table)
@click.argument('name')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
-@click.option('--filter', default=None, help='restricts the information to the fields in the filter')
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.option('--kdu', default=None, help='KDU name (whose status will be shown)')
@click.pass_context
def vnf_show(ctx, name, literal, filter, kdu):
time.sleep(5)
t += 5
print ("Could not determine KDU status")
+ return
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
for k, v in list(resp.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, wrap_text(text=json.dumps(v,indent=2),width=100)])
table.align = 'l'
print(table)
@cli_osm.command(name='ns-op-show', short_help='shows the info of a NS operation')
@click.argument('id')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
@click.pass_context
# exit(1)
if literal:
- print(yaml.safe_dump(op_info))
+ print(yaml.safe_dump(op_info, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
for k, v in list(op_info.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, wrap_text(json.dumps(v, indent=2), 100)])
table.align = 'l'
print(table)
# exit(1)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
# exit(1)
if literal:
- print(yaml.safe_dump(nsi))
+ print(yaml.safe_dump(nsi, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
for k, v in list(nsi.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, json.dumps(v, indent=2)])
table.align = 'l'
@click.argument('name')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def nsi_show1(ctx, name, literal, filter):
"""shows the content of a Network Slice Instance (NSI)
@click.argument('name')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def nsi_show2(ctx, name, literal, filter):
"""shows the content of a Network Slice Instance (NSI)
table = PrettyTable(['field', 'value'])
for k, v in list(op_info.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, json.dumps(v, indent=2)])
table.align = 'l'
print(table)
@cli_osm.command(name='nsi-op-show', short_help='shows the info of an operation over a Network Slice Instance(NSI)')
@click.argument('id')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def nsi_op_show1(ctx, id, filter):
"""shows the info of an operation over a Network Slice Instance(NSI)
@cli_osm.command(name='netslice-instance-op-show', short_help='shows the info of an operation over a Network Slice Instance(NSI)')
@click.argument('id')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def nsi_op_show2(ctx, id, filter):
"""shows the info of an operation over a Network Slice Instance(NSI)
@click.argument('name')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
-@click.option('--filter', default=None)
+@click.option('--filter', multiple=True,
+ help='restricts the information to the fields in the filter')
@click.pass_context
def pdu_show(ctx, name, literal, filter):
"""shows the content of a Physical Deployment Unit (PDU)
# exit(1)
if literal:
- print(yaml.safe_dump(pdu))
+ print(yaml.safe_dump(pdu, indent=4, default_flow_style=False))
return
table = PrettyTable(['field', 'value'])
for k, v in list(pdu.items()):
- if filter is None or filter in k:
+ if not filter or k in filter:
table.add_row([k, json.dumps(v, indent=2)])
table.align = 'l'
#@click.option('--ro_update/--no_ro_update',
# default=False,
# help='update list from RO')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the VIM accounts matching the filter')
@click.option('--long', is_flag=True,
help='get more details of the NS (project, vim, deployment status, configuration status.')
"""list all VIM accounts"""
logger.debug("")
if filter:
+ filter='&'.join(filter)
check_client_version(ctx.obj, '--filter')
# if ro_update:
# check_client_version(ctx.obj, '--ro_update', 'v1')
if long:
table = PrettyTable(['vim name', 'uuid', 'project', 'operational state', 'error details'])
else:
- table = PrettyTable(['vim name', 'uuid'])
+ table = PrettyTable(['vim name', 'uuid', 'operational state'])
for vim in resp:
if long:
vim_details = ctx.obj.vim.get(vim['uuid'])
table.add_row([vim['name'], vim['uuid'], '{} ({})'.format(project_name, project_id),
vim_state, wrap_text(text=error_details, width=80)])
else:
- table.add_row([vim['name'], vim['uuid']])
+ table.add_row([vim['name'], vim['uuid'], vim['_admin'].get('operationalState', '-')])
table.align = 'l'
print(table)
@cli_osm.command(name='wim-list', short_help='list all WIM accounts')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the WIM accounts matching the filter')
@click.pass_context
def wim_list(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.wim.list(filter)
table = PrettyTable(['wim name', 'uuid'])
for wim in resp:
@cli_osm.command(name='sdnc-list', short_help='list all SDN controllers')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help="restricts the list to the SDN controllers matching the filter with format: 'k[.k..]=v[&k[.k]=v2]'")
@click.pass_context
def sdnc_list(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.sdnc.list(filter)
# except ClientException as e:
# print(str(e))
@cli_osm.command(name='k8scluster-list')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the K8s clusters matching the filter')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
"""list all K8s clusters"""
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.k8scluster.list(filter)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['Name', 'Id', 'Version', 'VIM', 'K8s-nets', 'Operational State', 'Description'])
for cluster in resp:
# try:
resp = ctx.obj.k8scluster.get(name)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['key', 'attribute'])
for k, v in list(resp.items()):
@cli_osm.command(name='repo-list')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the repos matching the filter')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
# try:
# K8s Repositories
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.repo.list(filter)
resp += ctx.obj.osmrepo.list(filter)
if literal:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['Name', 'Id', 'Type', 'URI', 'Description'])
for repo in resp:
if literal:
if resp:
- print(yaml.safe_dump(resp))
+ print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
table = PrettyTable(['key', 'attribute'])
if resp:
@click.option('--domain-name', 'domain_name',
default=None,
help='assign to a domain')
+@click.option('--quotas', 'quotas', multiple=True, default=None,
+ help="provide quotas. Can be used several times: 'quota1=number[,quota2=number,...]'. Quotas can be one "
+ "of vnfds, nsds, nsts, pdus, nsrs, nsis, vim_accounts, wim_accounts, sdns, k8sclusters, k8srepos")
@click.pass_context
-def project_create(ctx, name, domain_name):
+def project_create(ctx, name, domain_name, quotas):
"""Creates a new project
NAME: name of the project
DOMAIN_NAME: optional domain name for the project when keystone authentication is used
+ QUOTAS: set quotas for the project
"""
logger.debug("")
- project = {}
- project['name'] = name
+ project = {'name': name}
if domain_name:
project['domain_name'] = domain_name
+ quotas_dict = _process_project_quotas(quotas)
+ if quotas_dict:
+ project['quotas'] = quotas_dict
+
# try:
check_client_version(ctx.obj, ctx.command.name)
ctx.obj.project.create(name, project)
# exit(1)
+def _process_project_quotas(quota_list):
+ quotas_dict = {}
+ if not quota_list:
+ return quotas_dict
+ try:
+ for quota in quota_list:
+ for single_quota in quota.split(","):
+ k, v = single_quota.split("=")
+ quotas_dict[k] = None if v in ('None', 'null', '') else int(v)
+ except (ValueError, TypeError):
+ raise ClientException("invalid format for 'quotas'. Use 'k1=v1,v1=v2'. v must be a integer or null")
+ return quotas_dict
+
+
@cli_osm.command(name='project-delete', short_help='deletes a project')
@click.argument('name')
#@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
@cli_osm.command(name='project-list', short_help='list all projects')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the projects matching the filter')
@click.pass_context
def project_list(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.project.list(filter)
# except ClientException as e:
# print(str(e))
@cli_osm.command(name='project-update', short_help='updates a project (only the name can be updated)')
@click.argument('project')
-@click.option('--name',
- prompt=True,
+@click.option('--name', default=None,
help='new name for the project')
-
+@click.option('--quotas', 'quotas', multiple=True, default=None,
+ help="change quotas. Can be used several times: 'quota1=number|empty[,quota2=...]' "
+ "(use empty to reset quota to default")
@click.pass_context
-def project_update(ctx, project, name):
+def project_update(ctx, project, name, quotas):
"""
Update a project name
:param ctx:
:param project: id or name of the project to modify
:param name: new name for the project
+ :param quotas: change quotas of the project
:return:
"""
logger.debug("")
project_changes = {}
- project_changes['name'] = name
+ if name:
+ project_changes['name'] = name
+ quotas_dict = _process_project_quotas(quotas)
+ if quotas_dict:
+ project_changes['quotas'] = quotas_dict
# try:
check_client_version(ctx.obj, ctx.command.name)
@cli_osm.command(name='user-list', short_help='list all users')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the users matching the filter')
@click.pass_context
def user_list(ctx, filter):
"""list all users"""
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.user.list(filter)
# except ClientException as e:
# print(str(e))
@click.option('--vnf_name', default=None, help='member-vnf-index if the target is a vnf instead of a ns)')
@click.option('--kdu_name', default=None, help='kdu-name if the target is a kdu)')
@click.option('--vdu_id', default=None, help='vdu-id if the target is a vdu')
-@click.option('--vdu_count', default=None, help='number of vdu instance of this vdu_id')
+@click.option('--vdu_count', default=None, type=int, help='number of vdu instance of this vdu_id')
@click.option('--action_name', prompt=True, help='action name')
@click.option('--params', default=None, help='action params in YAML/JSON inline string')
@click.option('--params_file', default=None, help='YAML/JSON file with action params')
op_data['kdu_name'] = kdu_name
if vdu_id:
op_data['vdu_id'] = vdu_id
- if vdu_count:
+ if vdu_count is not None:
op_data['vdu_count_index'] = vdu_count
if timeout:
op_data['timeout_ns_action'] = timeout
@cli_osm.command(name='role-list', short_help='list all roles')
-@click.option('--filter', default=None,
+@click.option('--filter', default=None, multiple=True,
help='restricts the list to the projects matching the filter')
@click.pass_context
def role_list(ctx, filter):
logger.debug("")
# try:
check_client_version(ctx.obj, ctx.command.name)
+ if filter:
+ filter='&'.join(filter)
resp = ctx.obj.role.list(filter)
# except ClientException as e:
# print(str(e))