X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=fd92477d3750faa587eec24a1f884d0aeaf3ebda;hb=9c79a482e22b9004d7a86fca1781ad4bf7bd32fc;hp=76daaa42d9bb193b81146c87c12dcadead063f2b;hpb=e26c422590219f865d958a8537b8f6c0973ac703;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 76daaa4..fd92477 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -814,6 +814,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, @@ -823,19 +825,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) @@ -850,9 +861,9 @@ def vim_create(ctx, @click.option('--tenant', help='VIM tenant name') @click.option('--config', help='VIM specific config parameters') @click.option('--account_type', help='VIM type') -@click.option('--sdn_controller', 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.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, @@ -863,36 +874,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 - 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 - config_dict = {} - if config is not None: - if config=="" and (sdncontroller or sdn_port_mapping): - raise ClientException("clearing config is incompatible with updating SDN info") - if config=="": - vim['config'] = None - else: - config_dict = yaml.safe_load(config) - if sdn_controller: config_dict['sdn_controller'] = sdn_controller - if sdn_port_mapping: - with open(sdn_port_mapping, 'r') as f: - config_dict['sdn_port_mapping'] = yaml.safe_load(f.read()) - if 'config' not in vim and config_dict: - vim['config'] = yaml.safe_dump(config_dict) 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)