def args2body(self, parsed_args): args = {'attributes': {}} body = {self.resource: args} # config arg passed as data overrides config yaml when both args passed config = None if parsed_args.config_file: with open(parsed_args.config_file) as f: config_yaml = f.read() config = yaml.load(config_yaml, Loader=yaml.SafeLoader) if parsed_args.config: # TODO(sridhar_ram): Only file based input supported starting # Ocata, remove all direct inputs in Pike utils.deprecate_warning(what="Direct config YAML input", as_of="O", remove_in=1) config = parsed_args.config if isinstance(config, str) or isinstance(config, unicode): config_str = parsed_args.config.decode('unicode_escape') config = yaml.load(config_str, Loader=yaml.SafeLoader) if config: args['attributes']['config'] = config if parsed_args.vim_region_name: args.setdefault('placement_attr', {})['region_name'] = \ parsed_args.vim_region_name tacker_client = self.get_client() tacker_client.format = parsed_args.request_format if parsed_args.vim_name: _id = tackerV10.find_resourceid_by_name_or_id( tacker_client, 'vim', parsed_args.vim_name) parsed_args.vim_id = _id if parsed_args.vnfd_name: _id = tackerV10.find_resourceid_by_name_or_id( tacker_client, 'vnfd', parsed_args.vnfd_name) parsed_args.vnfd_id = _id elif parsed_args.vnfd_template: with open(parsed_args.vnfd_template) as f: template = f.read() args['vnfd_template'] = yaml.load(template, Loader=yaml.SafeLoader) if parsed_args.param_file: with open(parsed_args.param_file) as f: param_yaml = f.read() args['attributes']['param_values'] = yaml.load( param_yaml, Loader=yaml.SafeLoader) tackerV10.update_dict( parsed_args, body[self.resource], ['tenant_id', 'name', 'description', 'vnfd_id', 'vim_id']) return body
def args2body(self, parsed_args): body = {self.resource: {}} if parsed_args.vnffgd_file: with open(parsed_args.vnffgd_file) as f: vnffgd = yaml.safe_load(f.read()) body[self.resource]['template'] = {'vnffgd': vnffgd} if parsed_args.vnffgd: # TODO(sridhar_ram): Only file based input supported starting # Ocata, remove all direct inputs in Pike utils.deprecate_warning(what="Direct VNFFGD template input", as_of="O", remove_in=1) body[self.resource]['template'] = { 'vnffgd': yaml.safe_load(parsed_args.vnffgd) } tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id', 'name', 'description']) return body
def args2body(self, parsed_args): args = {'attributes': {}} body = {self.resource: args} # config arg passed as data overrides config yaml when both args passed config = None if parsed_args.config_file: with open(parsed_args.config_file) as f: config_yaml = f.read() config = yaml.load(config_yaml, Loader=yaml.SafeLoader) if parsed_args.config: config = parsed_args.config if isinstance(config, str): config_str = parsed_args.config.decode('unicode_escape') config = yaml.load(config_str, Loader=yaml.SafeLoader) utils.deprecate_warning(what='yaml as string', as_of='N', in_favor_of='yaml as dictionary') if config: args['attributes']['config'] = config if parsed_args.vim_region_name: args.setdefault('placement_attr', {})['region_name'] = \ parsed_args.vim_region_name tacker_client = self.get_client() tacker_client.format = parsed_args.request_format if parsed_args.vim_name: _id = tackerV10.find_resourceid_by_name_or_id( tacker_client, 'vim', parsed_args.vim_name) parsed_args.vim_id = _id if parsed_args.vnfd_name: _id = tackerV10.find_resourceid_by_name_or_id( tacker_client, 'vnfd', parsed_args.vnfd_name) parsed_args.vnfd_id = _id if parsed_args.param_file: with open(parsed_args.param_file) as f: param_yaml = f.read() args['attributes']['param_values'] = yaml.load( param_yaml, Loader=yaml.SafeLoader) tackerV10.update_dict( parsed_args, body[self.resource], ['tenant_id', 'name', 'description', 'vnfd_id', 'vim_id']) return body
def args2body(self, parsed_args): body = {self.resource: {}} # config arg passed as data overrides config yaml when both args passed config = None if parsed_args.config_file: with open(parsed_args.config_file) as f: config_yaml = f.read() config = yaml.load(config_yaml, Loader=yaml.SafeLoader) if parsed_args.config: config = parsed_args.config if isinstance(parsed_args.config, str): config_str = parsed_args.config.decode('unicode_escape') config = yaml.load(config_str, Loader=yaml.SafeLoader) utils.deprecate_warning(what='yaml as string', as_of='N', in_favor_of='yaml as dictionary') if config: body[self.resource]['attributes'] = {'config': config} tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id']) return body
def args2body(self, parsed_args): body = {self.resource: {}} vnfd = None if parsed_args.vnfd_file: with open(parsed_args.vnfd_file) as f: vnfd = f.read() if "tosca_definitions_version" in vnfd: vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) if parsed_args.vnfd: vnfd = parsed_args.vnfd if isinstance(vnfd, str): vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) utils.deprecate_warning(what='yaml as string', as_of='N', in_favor_of='yaml as dictionary') if vnfd: body[self.resource]['attributes'] = {'vnfd': vnfd} tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id', 'name', 'description']) return body
def args2body(self, parsed_args): body = {self.resource: {}} vnfd = None if parsed_args.vnfd_file: with open(parsed_args.vnfd_file) as f: vnfd = f.read() vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) if parsed_args.vnfd: # TODO(sridhar_ram): Only file based input supported starting # Ocata, remove all direct inputs in Pike utils.deprecate_warning(what="Direct VNFD template input", as_of="O", remove_in=1) vnfd = parsed_args.vnfd if isinstance(vnfd, str) or isinstance(vnfd, unicode): vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) if vnfd: body[self.resource]['attributes'] = {'vnfd': vnfd} tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id', 'name', 'description']) return body