X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=45ae5e71eb67a19c6b8e477b46e3d57c89b470da;hb=refs%2Fchanges%2F49%2F7349%2F1;hp=0a1f7c3cd5ae70164ab7548a15e10790a5096f8e;hpb=9cd835db3dad5cb8e374b2c6b265201c71246318;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 0a1f7c3..45ae5e7 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -270,7 +270,7 @@ def vnfd_list(ctx, nf_type, filter): else: resp = ctx.obj.vnfd.list() #print yaml.safe_dump(resp) - table = PrettyTable(['vnfd name', 'id']) + table = PrettyTable(['nfpkg name', 'id']) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ if fullclassname == 'osmclient.sol005.client.Client': for vnfd in resp: @@ -1122,6 +1122,8 @@ def nfpkg_create(ctx, filename, overwrite): prompt=True, help='name of the NS descriptor') @click.option('--vim_account', prompt=True, help='default VIM account id or name for the deployment') +@click.option('--wim_account', + default=None, help='default WIM account for intersite connectivity. False to not use a WIM') @click.option('--admin_status', default='ENABLED', help='administration status') @@ -1139,6 +1141,7 @@ def ns_create(ctx, nsd_name, ns_name, vim_account, + wim_account, admin_status, ssh_keys, config, @@ -1156,7 +1159,8 @@ def ns_create(ctx, ns_name, config=config, ssh_keys=ssh_keys, - account=vim_account) + account=vim_account, + wim_account=wim_account) except ClientException as inst: print((inst.message)) exit(1) @@ -1207,9 +1211,9 @@ def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_fi with open(config_file, 'r') as cf: config=cf.read() ctx.obj.nsi.create(nst_name, nsi_name, config=config, ssh_keys=ssh_keys, - account=vim_account) + account=vim_account) except ClientException as inst: - print((inst.message)) + print(inst.message) exit(1) @@ -1224,7 +1228,9 @@ def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_fi 'netslice_subnet: [\n' 'id: TEXT, vim_account: TEXT,\n' 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n' - 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' + 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]\n' + 'additionalParamsForNsi: {param: value, ...}\n' + 'additionalParamsForsubnet: [{id: SUBNET_ID, additionalParamsForNs: {}, additionalParamsForVnf: {}}]\n' '],\n' 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' ) @@ -1802,6 +1808,167 @@ def vim_show(ctx, name): 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 #################### @@ -2073,7 +2240,9 @@ def project_show(ctx, name): confirmation_prompt=True, help='user password') @click.option('--projects', - default=None, + prompt="Comma separate list of projects", + multiple=True, + callback=lambda ctx, param, value: ''.join(value).split(',') if all(len(x)==1 for x in value) else value, help='list of project ids that the user belongs to') #@click.option('--description', # default='no description', @@ -2126,7 +2295,7 @@ def user_list(ctx, filter): exit(1) table = PrettyTable(['name', 'id']) for user in resp: - table.add_row([user['name'], user['_id']]) + table.add_row([user['username'], user['_id']]) table.align = 'l' print(table)