X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=78dd2329ed811205c3fd427b6e19b1b28f80e75c;hb=da765d5ec750a9de0e4123d60ff211ca86a2ad61;hp=570ad8c9f9e5544a998422946792724a8fb7f9a6;hpb=6d10e04620f3985e23dcce03d366f5734ba72a7c;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 570ad8c..78dd232 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -217,29 +217,52 @@ def vnfd_list2(ctx, filter): @cli.command(name='vnf-list') +@click.option('--ns', default=None, help='NS instance id or name to restrict the VNF list') @click.pass_context -def vnf_list(ctx): +def vnf_list(ctx, ns): ''' list all VNF instances''' try: - check_client_version(ctx.obj, ctx.command.name, 'v1') - resp = ctx.obj.vnf.list() + if ns: + check_client_version(ctx.obj, '--ns') + resp = ctx.obj.vnf.list(ns) + else: + resp = ctx.obj.vnf.list() except ClientException as inst: print(inst.message) exit(1) - table = PrettyTable( - ['vnf name', - 'id', - 'operational status', - 'config status']) - for vnfr in resp: - if 'mgmt-interface' not in vnfr: - vnfr['mgmt-interface'] = {} - vnfr['mgmt-interface']['ip-address'] = None - table.add_row( - [vnfr['name'], - vnfr['id'], - vnfr['operational-status'], - vnfr['config-status']]) + fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ + if fullclassname == 'osmclient.sol005.client.Client': + table = PrettyTable( + ['vnf id', + 'name', + 'ns id', + 'vnf member index', + 'vnfd name', + 'ip address']) + for vnfr in resp: + name = vnfr['name'] if 'name' in vnfr else '-' + table.add_row( + [vnfr['_id'], + name, + vnfr['nsr-id-ref'], + vnfr['member-vnf-index-ref'], + vnfr['vnfd-ref'], + vnfr['ip-address']]) + else: + table = PrettyTable( + ['vnf name', + 'id', + 'operational status', + 'config status']) + for vnfr in resp: + if 'mgmt-interface' not in vnfr: + vnfr['mgmt-interface'] = {} + vnfr['mgmt-interface']['ip-address'] = None + table.add_row( + [vnfr['name'], + vnfr['id'], + vnfr['operational-status'], + vnfr['config-status']]) table.align = 'l' print(table) @@ -409,7 +432,7 @@ def vnf_show(ctx, name, literal, filter): NAME: name or ID of the VNF instance ''' try: - check_client_version(ctx.obj, ctx.command.name, 'v1') + check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.vnf.get(name) except ClientException as inst: print(inst.message) @@ -810,6 +833,8 @@ def ns_delete(ctx, name, force): @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, @@ -819,19 +844,28 @@ def vim_create(ctx, tenant, config, account_type, - description): + description, + sdn_controller, + sdn_port_mapping): '''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) + 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) @@ -839,14 +873,16 @@ def vim_create(ctx, @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.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, @@ -857,24 +893,25 @@ def vim_update(ctx, tenant, config, account_type, - description): + description, + sdn_controller, + sdn_port_mapping): '''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) + 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)