+def ns_delete(ctx, name):
+ '''deletes a NS instance
+
+ NAME: name or ID of the NS instance to be deleted
+ '''
+ try:
+ ctx.obj.ns.delete(name)
+ 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.pass_context
+def vim_create(ctx,
+ name,
+ user,
+ password,
+ auth_url,
+ tenant,
+ config,
+ account_type,
+ description):
+ '''creates a new VIM account
+ '''
+ vim = {}
+ vim['vim-username'] = user
+ vim['vim-password'] = password
+ vim['vim-url'] = auth_url
+ vim['vim-tenant-name'] = tenant
+ vim['config'] = config
+ vim['vim-type'] = account_type
+ vim['description'] = description
+ try:
+ 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', default=None, help='New name for the VIM account')
+@click.option('--user', default=None, help='VIM username')
+@click.option('--password', default=None, help='VIM password')
+@click.option('--auth_url', default=None, help='VIM url')
+@click.option('--tenant', default=None, help='VIM tenant name')
+@click.option('--config', default=None, help='VIM specific config parameters')
+@click.option('--account_type', default=None, help='VIM type')
+@click.option('--description', default=None, help='human readable description')
+@click.pass_context
+def vim_update(ctx,
+ name,
+ newname,
+ user,
+ password,
+ auth_url,
+ tenant,
+ config,
+ account_type,
+ description):
+ '''updates a VIM account
+
+ NAME: name or ID of the VIM account
+ '''
+ vim = {}
+ if newname:
+ vim['name'] = newname
+ vim['vim_user'] = user
+ vim['vim_password'] = password
+ vim['vim_url'] = auth_url
+ vim['vim-tenant-name'] = tenant
+ vim['config'] = config
+ vim['vim_type'] = account_type
+ vim['description'] = description
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.vim.update(name, vim)
+ except ClientException as inst:
+ print(inst.message)
+ exit(1)
+
+
+@cli.command(name='vim-delete')
+@click.argument('name')
+@click.pass_context
+def vim_delete(ctx, name):
+ '''deletes a VIM account
+
+ NAME: name or ID of the VIM account to be deleted
+ '''
+ try:
+ ctx.obj.vim.delete(name)
+ 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'