+ nsd_update(ctx, name, content)
+
+
+def vnfd_update(ctx, name, content):
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.vnfd.update(name, content)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='vnfd-update', short_help='updates a new VNFD/VNFpkg')
+@click.argument('name')
+@click.option('--content', default=None,
+ help='filename with the VNFD/VNFpkg replacing the current one')
+@click.pass_context
+def vnfd_update1(ctx, name, content):
+ '''updates a VNFD/VNFpkg
+
+ NAME: name or ID of the VNFD/VNFpkg
+ '''
+ vnfd_update(ctx, name, content)
+
+
+@cli.command(name='vnfpkg-update', short_help='updates a VNFD/VNFpkg')
+@click.argument('name')
+@click.option('--content', default=None,
+ help='filename with the VNFD/VNFpkg replacing the current one')
+@click.pass_context
+def vnfd_update2(ctx, name, content):
+ '''updates a VNFD/VNFpkg
+
+ NAME: VNFD yaml file or VNFpkg tar.gz file
+ '''
+ 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)
+ ctx.obj.nst.update(name, content)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='nst-update', short_help='updates a Network Slice Template (NST)')
+@click.argument('name')
+@click.option('--content', default=None,
+ help='filename with the NST/NSTpkg replacing the current one')
+@click.pass_context
+def nst_update1(ctx, name, content):
+ '''updates a Network Slice Template (NST)
+
+ NAME: name or ID of the NSD/NSpkg
+ '''
+ nst_update(ctx, name, content)
+
+
+@cli.command(name='netslice-template-update', short_help='updates a Network Slice Template (NST)')
+@click.argument('name')
+@click.option('--content', default=None,
+ help='filename with the NST/NSTpkg replacing the current one')
+@click.pass_context
+def nst_update2(ctx, name, content):
+ '''updates a Network Slice Template (NST)
+
+ NAME: name or ID of the NSD/NSpkg
+ '''
+ nst_update(ctx, name, content)
+
+
+####################
+# DELETE operations
+####################
+
+def nsd_delete(ctx, name, force):
+ try:
+ if not force:
+ ctx.obj.nsd.delete(name)
+ else:
+ check_client_version(ctx.obj, '--force')
+ ctx.obj.nsd.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='nsd-delete', short_help='deletes a NSD/NSpkg')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nsd_delete1(ctx, name, force):
+ '''deletes a NSD/NSpkg
+
+ NAME: name or ID of the NSD/NSpkg to be deleted
+ '''
+ nsd_delete(ctx, name, force)
+
+
+@cli.command(name='nspkg-delete', short_help='deletes a NSD/NSpkg')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nsd_delete2(ctx, name, force):
+ '''deletes a NSD/NSpkg
+
+ NAME: name or ID of the NSD/NSpkg to be deleted
+ '''
+ nsd_delete(ctx, name, force)
+
+
+def vnfd_delete(ctx, name, force):
+ try:
+ if not force:
+ ctx.obj.vnfd.delete(name)
+ else:
+ check_client_version(ctx.obj, '--force')
+ ctx.obj.vnfd.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='vnfd-delete', short_help='deletes a VNFD/VNFpkg')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def vnfd_delete1(ctx, name, force):
+ '''deletes a VNFD/VNFpkg
+
+ NAME: name or ID of the VNFD/VNFpkg to be deleted
+ '''
+ vnfd_delete(ctx, name, force)
+
+
+@cli.command(name='vnfpkg-delete', short_help='deletes a VNFD/VNFpkg')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def vnfd_delete2(ctx, name, force):
+ '''deletes a VNFD/VNFpkg
+
+ NAME: name or ID of the VNFD/VNFpkg to be deleted
+ '''
+ 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')
+@click.pass_context
+def ns_delete(ctx, name, force):
+ '''deletes a NS instance
+
+ NAME: name or ID of the NS instance to be deleted
+ '''
+ try:
+ if not force:
+ ctx.obj.ns.delete(name)
+ else:
+ check_client_version(ctx.obj, '--force')
+ ctx.obj.ns.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+def nst_delete(ctx, name, force):
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.nst.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='nst-delete', short_help='deletes a Network Slice Template (NST)')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nst_delete1(ctx, name, force):
+ '''deletes a Network Slice Template (NST)
+
+ NAME: name or ID of the NST/NSTpkg to be deleted
+ '''
+ nst_delete(ctx, name, force)
+
+
+@cli.command(name='netslice-template-delete', short_help='deletes a Network Slice Template (NST)')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nst_delete2(ctx, name, force):
+ '''deletes a Network Slice Template (NST)
+
+ NAME: name or ID of the NST/NSTpkg to be deleted
+ '''
+ nst_delete(ctx, name, force)
+
+
+def nsi_delete(ctx, name, force):
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.nsi.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='nsi-delete', short_help='deletes a Network Slice Instance (NSI)')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nsi_delete1(ctx, name, force):
+ '''deletes a Network Slice Instance (NSI)
+
+ NAME: name or ID of the Network Slice instance to be deleted
+ '''
+ nsi_delete(ctx, name, force)
+
+
+@cli.command(name='netslice-instance-delete', short_help='deletes a Network Slice Instance (NSI)')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def nsi_delete2(ctx, name, force):
+ '''deletes a Network Slice Instance (NSI)
+
+ NAME: name or ID of the Network Slice instance to be deleted
+ '''
+ nsi_delete(ctx, name, force)
+
+
+@cli.command(name='pdu-delete', short_help='deletes a Physical Deployment Unit (PDU)')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def pdu_delete(ctx, name, force):
+ '''deletes a Physical Deployment Unit (PDU)
+
+ NAME: name or ID of the PDU to be deleted
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.pdu.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+####################
+# VIM operations
+####################
+
+@cli.command(name='vim-create')
+@click.option('--name',
+ prompt=True,
+ help='Name to create datacenter')
+@click.option('--user',
+ prompt=True,
+ help='VIM username')
+@click.option('--password',
+ prompt=True,
+ hide_input=True,
+ confirmation_prompt=True,
+ help='VIM password')
+@click.option('--auth_url',
+ prompt=True,
+ help='VIM url')
+@click.option('--tenant',
+ prompt=True,
+ help='VIM tenant name')
+@click.option('--config',
+ default=None,
+ help='VIM specific config parameters')
+@click.option('--account_type',
+ default='openstack',
+ help='VIM type')
+@click.option('--description',
+ default='no description',
+ help='human readable description')
+@click.option('--sdn_controller', default=None, help='Name or id of the SDN controller associated to this VIM account')
+@click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports")
+@click.pass_context
+def vim_create(ctx,
+ name,
+ user,
+ password,
+ auth_url,
+ tenant,
+ config,
+ account_type,
+ description,
+ sdn_controller,
+ sdn_port_mapping):
+ '''creates a new VIM account
+ '''
+ try:
+ if sdn_controller:
+ check_client_version(ctx.obj, '--sdn_controller')
+ if sdn_port_mapping:
+ check_client_version(ctx.obj, '--sdn_port_mapping')
+ vim = {}
+ vim['vim-username'] = user
+ vim['vim-password'] = password
+ vim['vim-url'] = auth_url
+ vim['vim-tenant-name'] = tenant
+ vim['vim-type'] = account_type
+ vim['description'] = description
+ vim['config'] = config
+ if sdn_controller or sdn_port_mapping:
+ ctx.obj.vim.create(name, vim, sdn_controller, sdn_port_mapping)
+ else:
+ ctx.obj.vim.create(name, vim)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='vim-update', short_help='updates a VIM account')
+@click.argument('name')
+@click.option('--newname', help='New name for the VIM account')
+@click.option('--user', help='VIM username')
+@click.option('--password', help='VIM password')
+@click.option('--auth_url', help='VIM url')
+@click.option('--tenant', help='VIM tenant name')
+@click.option('--config', help='VIM specific config parameters')
+@click.option('--account_type', help='VIM type')
+@click.option('--description', help='human readable description')
+@click.option('--sdn_controller', default=None, help='Name or id of the SDN controller associated to this VIM account')
+@click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports")
+@click.pass_context
+def vim_update(ctx,
+ name,
+ newname,
+ user,
+ password,
+ auth_url,
+ tenant,
+ config,
+ account_type,
+ description,
+ sdn_controller,
+ sdn_port_mapping):
+ '''updates a VIM account
+
+ NAME: name or ID of the VIM account
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ vim = {}
+ if newname: vim['name'] = newname
+ if user: vim['vim_user'] = user
+ if password: vim['vim_password'] = password
+ if auth_url: vim['vim_url'] = auth_url
+ if tenant: vim['vim-tenant-name'] = tenant
+ if account_type: vim['vim_type'] = account_type
+ if description: vim['description'] = description
+ if config: vim['config'] = config
+ ctx.obj.vim.update(name, vim, sdn_controller, sdn_port_mapping)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='vim-delete')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def vim_delete(ctx, name, force):
+ '''deletes a VIM account
+
+ NAME: name or ID of the VIM account to be deleted
+ '''
+ try:
+ if not force:
+ ctx.obj.vim.delete(name)
+ else:
+ check_client_version(ctx.obj, '--force')
+ ctx.obj.vim.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='vim-list')
+@click.option('--ro_update/--no_ro_update',
+ default=False,
+ help='update list from RO')
+@click.option('--filter', default=None,
+ help='restricts the list to the VIM accounts matching the filter')
+@click.pass_context
+def vim_list(ctx, ro_update, filter):
+ '''list all VIM accounts'''
+ if filter:
+ check_client_version(ctx.obj, '--filter')
+ if ro_update:
+ check_client_version(ctx.obj, '--ro_update', 'v1')
+ fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
+ if fullclassname == 'osmclient.sol005.client.Client':
+ resp = ctx.obj.vim.list(filter)
+ else:
+ resp = ctx.obj.vim.list(ro_update)
+ table = PrettyTable(['vim name', 'uuid'])
+ for vim in resp:
+ table.add_row([vim['name'], vim['uuid']])
+ table.align = 'l'
+ print(table)
+
+
+@cli.command(name='vim-show')
+@click.argument('name')
+@click.pass_context
+def vim_show(ctx, name):
+ '''shows the details of a VIM account
+
+ NAME: name or ID of the VIM account
+ '''
+ try:
+ resp = ctx.obj.vim.get(name)
+ if 'vim_password' in resp:
+ resp['vim_password']='********'
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+ table = PrettyTable(['key', 'attribute'])
+ for k, v in list(resp.items()):
+ table.add_row([k, json.dumps(v, indent=2)])
+ table.align = 'l'
+ print(table)
+
+
+####################
+# WIM operations
+####################
+
+@cli.command(name='wim-create')
+@click.option('--name',
+ prompt=True,
+ help='Name for the WIM account')
+@click.option('--user',
+ help='WIM username')
+@click.option('--password',
+ help='WIM password')
+@click.option('--url',
+ prompt=True,
+ help='WIM url')
+# @click.option('--tenant',
+# help='wIM tenant name')
+@click.option('--config',
+ default=None,
+ help='WIM specific config parameters')
+@click.option('--wim_type',
+ help='WIM type')
+@click.option('--description',
+ default='no description',
+ help='human readable description')
+@click.option('--wim_port_mapping', default=None, help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge (WAN service endpoint id and info)")
+@click.pass_context
+def wim_create(ctx,
+ name,
+ user,
+ password,
+ url,
+ # tenant,
+ config,
+ wim_type,
+ description,
+ wim_port_mapping):
+ '''creates a new WIM account
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ # if sdn_controller:
+ # check_client_version(ctx.obj, '--sdn_controller')
+ # if sdn_port_mapping:
+ # check_client_version(ctx.obj, '--sdn_port_mapping')
+ wim = {}
+ if user: wim['user'] = user
+ if password: wim['password'] = password
+ if url: wim['wim_url'] = url
+ # if tenant: wim['tenant'] = tenant
+ wim['wim_type'] = wim_type
+ if description: wim['description'] = description
+ if config: wim['config'] = config
+ ctx.obj.wim.create(name, wim, wim_port_mapping)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='wim-update', short_help='updates a WIM account')
+@click.argument('name')
+@click.option('--newname', help='New name for the WIM account')
+@click.option('--user', help='WIM username')
+@click.option('--password', help='WIM password')
+@click.option('--url', help='WIM url')
+@click.option('--config', help='WIM specific config parameters')
+@click.option('--wim_type', help='WIM type')
+@click.option('--description', help='human readable description')
+@click.option('--wim_port_mapping', default=None, help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge (WAN service endpoint id and info)")
+@click.pass_context
+def wim_update(ctx,
+ name,
+ newname,
+ user,
+ password,
+ url,
+ config,
+ wim_type,
+ description,
+ wim_port_mapping):
+ '''updates a WIM account
+
+ NAME: name or ID of the WIM account
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ wim = {}
+ if newname: wim['name'] = newname
+ if user: wim['user'] = user
+ if password: wim['password'] = password
+ if url: wim['url'] = url
+ # if tenant: wim['tenant'] = tenant
+ if wim_type: wim['wim_type'] = wim_type
+ if description: wim['description'] = description
+ if config: wim['config'] = config
+ ctx.obj.wim.update(name, wim, wim_port_mapping)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='wim-delete')
+@click.argument('name')
+@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
+@click.pass_context
+def wim_delete(ctx, name, force):
+ '''deletes a WIM account
+
+ NAME: name or ID of the WIM account to be deleted
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.wim.delete(name, force)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='wim-list')
+@click.option('--filter', default=None,
+ help='restricts the list to the WIM accounts matching the filter')
+@click.pass_context
+def wim_list(ctx, filter):
+ '''list all WIM accounts'''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ resp = ctx.obj.wim.list(filter)
+ table = PrettyTable(['wim name', 'uuid'])
+ for wim in resp:
+ table.add_row([wim['name'], wim['uuid']])
+ table.align = 'l'
+ print(table)
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+
+@cli.command(name='wim-show')
+@click.argument('name')
+@click.pass_context
+def wim_show(ctx, name):
+ '''shows the details of a WIM account
+
+ NAME: name or ID of the WIM account
+ '''
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ resp = ctx.obj.wim.get(name)
+ if 'password' in resp:
+ resp['wim_password']='********'
+ except ClientException as inst:
+ print((inst.message))
+ exit(1)
+
+ table = PrettyTable(['key', 'attribute'])
+ for k, v in list(resp.items()):
+ table.add_row([k, json.dumps(v, indent=2)])
+ table.align = 'l'
+ print(table)
+
+
+####################
+# SDN controller operations
+####################
+
+@cli.command(name='sdnc-create')
+@click.option('--name',
+ prompt=True,
+ help='Name to create sdn controller')
+@click.option('--type',
+ prompt=True,
+ help='SDN controller type')
+@click.option('--sdn_controller_version',
+ help='SDN controller username')
+@click.option('--ip_address',
+ prompt=True,
+ help='SDN controller IP address')
+@click.option('--port',
+ prompt=True,
+ help='SDN controller port')
+@click.option('--switch_dpid',
+ prompt=True,
+ help='Switch DPID (Openflow Datapath ID)')
+@click.option('--user',
+ help='SDN controller username')
+@click.option('--password',
+ hide_input=True,
+ confirmation_prompt=True,
+ help='SDN controller password')
+#@click.option('--description',
+# default='no description',
+# help='human readable description')
+@click.pass_context
+def sdnc_create(ctx,
+ name,
+ type,
+ sdn_controller_version,
+ ip_address,
+ port,
+ switch_dpid,
+ user,
+ password):
+ '''creates a new SDN controller
+ '''
+ sdncontroller = {}
+ sdncontroller['name'] = name
+ sdncontroller['type'] = type
+ sdncontroller['ip'] = ip_address
+ sdncontroller['port'] = int(port)
+ sdncontroller['dpid'] = switch_dpid
+ if sdn_controller_version:
+ sdncontroller['version'] = sdn_controller_version
+ if user:
+ sdncontroller['user'] = user
+ if password:
+ sdncontroller['password'] = password
+# sdncontroller['description'] = description