nsd_list(ctx,filter)
-def vnfd_list(ctx, filter):
- if filter:
+def vnfd_list(ctx, nf_type, filter):
+ if nf_type:
+ check_client_version(ctx.obj, '--nf_type')
+ elif filter:
check_client_version(ctx.obj, '--filter')
+ if nf_type:
+ if nf_type == "vnf":
+ nf_filter = "_admin.type=vnfd"
+ elif nf_type == "pnf":
+ nf_filter = "_admin.type=pnfd"
+ elif nf_type == "hnf":
+ nf_filter = "_admin.type=hnfd"
+ else:
+ raise ClientException('wrong value for "--nf_type" option, allowed values: vnf, pnf, hnf')
+ if filter:
+ filter = '{}&{}'.format(nf_filter, filter)
+ else:
+ filter = nf_filter
+ if filter:
resp = ctx.obj.vnfd.list(filter)
else:
resp = ctx.obj.vnfd.list()
@cli.command(name='vnfd-list')
+@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
@click.option('--filter', default=None,
- help='restricts the list to the VNFD/VNFpkg matching the filter')
+ help='restricts the list to the NFpkg matching the filter')
@click.pass_context
-def vnfd_list1(ctx, filter):
+def vnfd_list1(ctx, nf_type, filter):
'''list all VNFD/VNFpkg in the system'''
- vnfd_list(ctx,filter)
+ vnfd_list(ctx, nf_type, filter)
@cli.command(name='vnfpkg-list')
+@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
@click.option('--filter', default=None,
- help='restricts the list to the VNFD/VNFpkg matching the filter')
+ help='restricts the list to the NFpkg matching the filter')
@click.pass_context
-def vnfd_list2(ctx, filter):
+def vnfd_list2(ctx, nf_type, filter):
'''list all VNFD/VNFpkg in the system'''
- vnfd_list(ctx,filter)
+ vnfd_list(ctx, nf_type, filter)
-@cli.command(name='vnf-list')
-@click.option('--ns', default=None, help='NS instance id or name to restrict the VNF list')
+@cli.command(name='nfpkg-list')
+@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
@click.option('--filter', default=None,
- help='restricts the list to the VNF instances matching the filter.')
+ help='restricts the list to the NFpkg matching the filter')
@click.pass_context
+def nfpkg_list(ctx, nf_type, filter):
+ '''list all NFpkg (VNFpkg, PNFpkg, HNFpkg) in the system'''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ vnfd_list(ctx,nf_type,filter)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
def vnf_list(ctx, ns, filter):
'''list all VNF instances
table.align = 'l'
print(table)
+
+@cli.command(name='vnf-list')
+@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.pass_context
+def vnf_list1(ctx, ns, filter):
+ vnf_list(ctx, ns, filter)
+
+
+@cli.command(name='nf-list')
+@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.pass_context
+def nf_list(ctx, ns, filter):
+ vnf_list(ctx, ns, filter)
+
+
@cli.command(name='ns-op-list')
@click.argument('name')
@click.pass_context
['pdu name',
'id',
'type',
- 'shared',
'mgmt ip address'])
for pdu in resp:
pdu_name = pdu['name']
pdu_id = pdu['_id']
pdu_type = pdu['type']
- pdu_shared = pdu['shared']
pdu_ipaddress = "None"
for iface in pdu['interfaces']:
if iface['mgmt']:
[pdu_name,
pdu_id,
pdu_type,
- pdu_shared,
pdu_ipaddress])
table.align = 'l'
print(table)
vnfd_show(ctx, name, literal)
+@cli.command(name='nfpkg-show', short_help='shows the content of a NF Descriptor')
+@click.option('--literal', is_flag=True,
+ help='print literally, no pretty table')
+@click.argument('name')
+@click.pass_context
+def nfpkg_show(ctx, name, literal):
+ '''shows the content of a NF Descriptor
+
+ NAME: name or ID of the NFpkg
+ '''
+ vnfd_show(ctx, name, literal)
+
+
@cli.command(name='ns-show', short_help='shows the info of a NS instance')
@click.argument('name')
@click.option('--literal', is_flag=True,
vnfd_create(ctx, filename, overwrite)
+@cli.command(name='nfpkg-create', short_help='creates a new NFpkg')
+@click.argument('filename')
+@click.option('--overwrite', default=None,
+ help='overwrites some fields in NFD')
+@click.pass_context
+def nfpkg_create(ctx, filename, overwrite):
+ '''creates a new NFpkg
+
+ FILENAME: NF Descriptor yaml file or NFpkg tar.gz file
+ '''
+ vnfd_create(ctx, filename, overwrite)
+
+
@cli.command(name='ns-create', short_help='creates a new Network Service instance')
@click.option('--ns_name',
prompt=True, help='name of the NS instance')
'[,type=<overlay|underlay>][,mac-address=<MAC_ADDRESS>][,vim-network-name=<VIM_NET_NAME>]',
multiple=True)
@click.option('--description', help='human readable description')
-@click.option('--shared', is_flag=True, help='flag to indicate if the PDU is shared')
-@click.option('--vimAccounts', help='list of VIM accounts where this PDU is physically connected')
+@click.option('--vim_account', help='list of VIM accounts (in the same VIM) that can reach this PDU', multiple=True)
@click.option('--descriptor_file', default=None, help='PDU descriptor file (as an alternative to using the other arguments')
@click.pass_context
-#TODO
-def pdu_create(ctx, name, pdu_type, interface, description, shared, vimAccounts, descriptor_file):
+def pdu_create(ctx, name, pdu_type, interface, description, vim_account, descriptor_file):
'''creates a new Physical Deployment Unit (PDU)'''
try:
check_client_version(ctx.obj, ctx.command.name)
raise ClientException('in absence of descriptor file, option "--pdu_type" is mandatory')
if not interface:
raise ClientException('in absence of descriptor file, option "--interface" is mandatory (at least once)')
+ if not vim_account:
+ raise ClientException('in absence of descriptor file, option "--vim_account" is mandatory (at least once)')
else:
with open(descriptor_file, 'r') as df:
pdu = yaml.load(df.read())
if name: pdu["name"] = name
if pdu_type: pdu["type"] = pdu_type
if description: pdu["description"] = description
- if shared: pdu["shared"] = shared
- if vimAccounts: pdu["vim_accounts"] = yaml.load(vimAccounts)
+ if vim_account: pdu["vim_accounts"] = vim_account
if interface:
ifaces_list = []
for iface in interface:
- ifaces_list.append({k:v for k,v in [i.split('=') for i in iface.split(',')]})
+ new_iface={k:v for k,v in [i.split('=') for i in iface.split(',')]}
+ new_iface["mgmt"] = (new_iface.get("mgmt","false").lower() == "true")
+ ifaces_list.append(new_iface)
pdu["interfaces"] = ifaces_list
ctx.obj.pdu.create(pdu)
except ClientException as inst:
vnfd_update(ctx, name, content)
+@cli.command(name='nfpkg-update', short_help='updates a NFpkg')
+@click.argument('name')
+@click.option('--content', default=None,
+ help='filename with the NFpkg replacing the current one')
+@click.pass_context
+def nfpkg_update(ctx, name, content):
+ '''updates a NFpkg
+
+ NAME: NF Descriptor yaml file or NFpkg tar.gz file
+ '''
+ vnfd_update(ctx, name, content)
+
+
def nst_update(ctx, name, content):
try:
check_client_version(ctx.obj, ctx.command.name)
vnfd_delete(ctx, name, force)
+@cli.command(name='nfpkg-delete', short_help='deletes a NFpkg')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nfpkg_delete(ctx, name, force):
+ '''deletes a NFpkg
+
+ NAME: name or ID of the NFpkg to be deleted
+ '''
+ vnfd_delete(ctx, name, force)
+
+
@cli.command(name='ns-delete', short_help='deletes a NS instance')
@click.argument('name')
@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')