def set_module_var(self): """ set module variables from the config file """ self.vnf_config["sdnc_vnf_type"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + self.vnf_config["vnf_type"] + ".metadata.vfModuleModelName") vnf_param = self.vnf_config["vnf"] + ".vnf_parameters" self.vnf_config["vnf_parameters"] = onap_utils.get_config(vnf_param) self.vnf_config["module_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + self.vnf_config["vnf_type"] + ".metadata.vfModuleModelInvariantUUID") self.vnf_config["module_name_version_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + self.vnf_config["vnf_type"] + ".metadata.vfModuleModelUUID")) self.vnf_config["module_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + self.vnf_config["vnf_type"] + ".metadata.vfModuleModelCustomizationUUID")) self.vnf_config["module_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + self.vnf_config["vnf_type"] + ".metadata.vfModuleModelUUID")
def set_vnf_var(self): """ set vnf variables from the config file """ for i, elt in enumerate(self.vnf_infos['list']): vnf_config = {} self.__logger.info("get VNF %s info", elt) vnf_config["vnf_customization_name"] = elt vnf_config["vnf_model_name"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.name") vnf_config["vnf_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.invariantUUID") vnf_config["vnf_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.UUID") vnf_config["vnf_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.customizationUUID")) vnf_config["vnf_type"] = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.groups"))[i] vnf_config["vnf_generic_name"] = (self.vnf_config["vnf_name"] + "-service-instance-" + self.vnf_config["random_string"]) vnf_config["vnf_generic_type"] = ( self.vnf_config["vnf_name"] + "/" + vnf_config["vnf_customization_name"]) self.vnf_config[elt] = vnf_config
def set_service_instance_var(self): """ set service instance variables from the config file """ self.vnf_config["vnf_name"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.name") self.vnf_config["invariant_uuid"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.invariantUUID") self.vnf_config["uuid"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.UUID")
def set_vnf_var(self): """ set vnf variables from the config file Add the VNFs versions read from tosca file """ for i, elt in enumerate(self.vnf_infos['list']): vnf_config = {} self.__logger.info("get VNF %s info", elt) vnf_config["vnf_customization_name"] = elt vnf_config["vnf_model_name"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.name") vnf_config["vnf_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.invariantUUID") vnf_config["vnf_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.UUID") vnf_config["vnf_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.customizationUUID")) # Fix: The index used to get the VF is not the same as the VNF index! (it works if only template contains 1 VNF with 1 VF) # => Moved to set_module_var in a VF specific context #vnf_config["vnf_type"] = list(onap_utils.get_template_param( # self.vnf_config["vnf"], "topology_template.groups"))[i] vnf_config["vnf_generic_name"] = (self.vnf_config["vnf_name"] + "-service-instance-" + self.vnf_config["random_string"]) vnf_config["vnf_generic_type"] = ( self.vnf_config["vnf_name"] + "/" + vnf_config["vnf_customization_name"]) # Get the VNF version from the tosca file vnf_config["vnf_version"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + vnf_config["vnf_customization_name"] + ".metadata.version") self.vnf_config[elt] = vnf_config
def set_vnf_var(self): """ set vnf variables from the config file """ self.vnf_config["vnf_customization_name"] = list( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates"))[0] self.vnf_config["vnf_model_name"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + self.vnf_config["vnf_customization_name"] + ".metadata.name") self.vnf_config["vnf_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + self.vnf_config["vnf_customization_name"] + ".metadata.invariantUUID") self.vnf_config["vnf_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + self.vnf_config["vnf_customization_name"] + ".metadata.UUID") self.vnf_config["vnf_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.node_templates." + self.vnf_config["vnf_customization_name"] + ".metadata.customizationUUID")) self.vnf_config["vnf_type"] = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.groups"))[0] self.vnf_config["vnf_generic_name"] = ( self.vnf_config["vnf_name"] + "-service-instance-" + self.vnf_config["random_string"]) self.vnf_config["vnf_generic_type"] = ( self.vnf_config["vnf_name"] + "/" + self.vnf_config["vnf_customization_name"])
def __init__(self, **kwargs): """Initialize Solution object.""" super(Solution, self).__init__() self.vnf_config = {} self.components = {} if "case" not in kwargs: # by convention is VNF is not precised we set mrf kwargs["case"] = "mrf" self.vnf_config["vnf"] = kwargs["case"] if "nbi" in kwargs: self.vnf_config["nbi"] = kwargs["nbi"] # can be useful to destroy resources, sdnc module name shall be given if "sdnc_vnf_name" in kwargs: self.vnf_config["sdnc_vnf_name"] = kwargs["sdnc_vnf_name"] # Random part = 6 last char of the the vnf name self.vnf_config["random_string"] = kwargs["sdnc_vnf_name"][-6:] else: self.vnf_config["random_string"] = ( onap_utils.random_string_generator()) self.vnf_config["sdnc_vnf_name"] = ( onap_utils.get_config("onap.service.name") + "_" + kwargs["case"] + "_" + self.vnf_config["random_string"]) vnf_list = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.node_templates")) vf_module_list = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.groups")) # Class attributes for instance, vnf and module VF self.service_infos = {} self.vnf_infos = {'list': vnf_list} self.module_infos = {'list': vf_module_list} # retrieve infos from the configuration files self.set_service_instance_var() self.set_vnf_var() self.set_module_var() self.set_onap_components()
def set_service_instance_var(self): """ set service instance variables from the config file Fix: Service version is not in the Tosca but in the Instantiation input file """ self.vnf_config["vnf_name"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.name") self.vnf_config["invariant_uuid"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.invariantUUID") self.vnf_config["uuid"] = onap_utils.get_template_param( self.vnf_config["vnf"], "metadata.UUID") # Catch exception For backward compatibility with previous file format that does not contain any service_version try: self.vnf_config["version"] = onap_utils.get_config( self.vnf_config["vnf"] + ".service_version") except ValueError: # the default hardcoded version self.vnf_config["version"] = "1.0" self.__logger.info( "No service_version in config file, using default %s", self.vnf_config["version"])
def set_module_var(self): """ set module variables from the config file """ for elt in self.vnf_infos['list']: vf_config = {} # we cannot be sure that the modules are in teh same order # than the vnf vf_index = onap_utils.get_vf_module_index( self.module_infos['list'], elt) vnf_type = list( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups"))[vf_index] self.__logger.info("Complete Module info for VNF %s", elt) vf_config["sdnc_vnf_type"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelName") vnf_param = (self.vnf_config["vnf"] + "." + str(elt) + ".vnf_parameters") vf_config["vnf_parameters"] = onap_utils.get_config(vnf_param) vf_config["module_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelInvariantUUID") vf_config["module_name_version_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelUUID")) vf_config["module_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelCustomizationUUID")) vf_config["module_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelUUID") self.vnf_config[elt].update(vf_config)
def __init__(self, **kwargs): """Initialize Solution object.""" super(Solution, self).__init__() #Check if Os_* vars are set if not self.check_env_vars(): self.__logger.error( "No OS_* environment variables detected : Exiting...") sys.exit(1) self.vnf_config = {} self.components = {} if "case" not in kwargs: # by convention is VNF is not precised we set mrf kwargs["case"] = "mrf" self.vnf_config["vnf"] = kwargs["case"] if "nbi" in kwargs: self.vnf_config["nbi"] = kwargs["nbi"] # can be useful to destroy resources, sdnc module name shall be given if "sdnc_vnf_name" in kwargs: self.vnf_config["sdnc_vnf_name"] = kwargs["sdnc_vnf_name"] # Random part = 6 last char of the the vnf name self.vnf_config["random_string"] = kwargs["sdnc_vnf_name"][-6:] else: self.vnf_config["random_string"] = ( onap_utils.random_string_generator()) self.vnf_config["sdnc_vnf_name"] = ( onap_utils.get_config("onap.service.name") + "_" + kwargs["case"] + "_" + self.vnf_config["random_string"]) LOG_LEVEL = onap_utils.get_config("general.log.log_level") if LOG_LEVEL == "DEBUG": self.__logger.info("DEBUG: Activated!") self.DebugActivated = True else: self.__logger.info("DEBUG: Not activated") self.DebugActivated = True vnf_list = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.node_templates")) vf_module_list = list( onap_utils.get_template_param(self.vnf_config["vnf"], "topology_template.groups")) # Class attributes for instance, vnf and module VF self.service_infos = {} self.service_subscription_type = onap_utils.get_config( self.vnf_config["vnf"] + ".subscription_type") self.vnf_infos = {'list': vnf_list} self.module_infos = {'list': vf_module_list} # List of parameters of the preload to add a random key to self.parameters_random_addlist = onap_utils.get_config( self.vnf_config["vnf"] + ".add_random_to_parameters") # retrieve infos from the configuration files self.set_service_instance_var() self.set_vnf_var() self.set_module_var() self.set_onap_components()
def set_module_var(self): """ set module variables from the config file Fix: a VNF can have multiple VF so we need to iterate also on VF modules to find matching VNFs they belong to Get modules versions from tosca groups """ for elt in self.vnf_infos['list']: vf_config = {} # we cannot be sure that the modules are in the same order # than the vnf # iterate as long as some modules are found for the current VNF mod_index = 0 vf_index = 0 while vf_index >= 0: # If no more module are found for current VNF, index returned is -1 vf_index = onap_utils.get_vf_module_index( self.module_infos['list'], elt, mod_index=mod_index) if vf_index == -1: break module_name = "module-%s" % mod_index vnf_type = list( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups"))[vf_index] # Move this item to the module layer of the context (to avoid beeing overwritten when multiple VF in the VNF!) #vf_config["sdnc_vnf_type"] = onap_utils.get_template_param( # self.vnf_config["vnf"], "topology_template.groups." + # vnf_type + # ".metadata.vfModuleModelName") module_name = "module-%s" % mod_index vf_config[module_name] = {} vf_config[module_name][ "sdnc_vnf_type"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelName") self.__logger.info("get Module %s:%s info for VNF %s", module_name, vf_config[module_name]["sdnc_vnf_type"], elt) vnf_param = (self.vnf_config["vnf"] + "." + str(elt) + ".vnf_parameters") # For backward compatibility: If there is only one VF module in the VNF, the yaml file is VNF.vnf_parameters # if multiple VF: VNF.<VF_module>.vnf_parameters # vf_config["vnf_parameters"] = onap_utils.get_config(vnf_param) try: vnf_vf_params = onap_utils.get_config( vnf_param ) # exception if not found (new format with module-x except ValueError: # We look with the VF level in the yaml file vnf_param = (self.vnf_config["vnf"] + "." + str(elt) + "." + module_name + ".vnf_parameters") vnf_vf_params = onap_utils.get_config(vnf_param) # Add entry with the VNF.<module-x>.vnf_parameters vf_config[module_name]["vnf_parameters"] = vnf_vf_params # Every field below the groups is related to a specific vf and shold be in the vf context (not the VNF context!) vf_config[module_name][ "module_invariant_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelInvariantUUID") vf_config[module_name]["module_name_version_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelUUID")) vf_config[module_name]["module_customization_id"] = ( onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelCustomizationUUID")) vf_config[module_name][ "module_version_id"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelUUID") # Keep the initial_count to identify how many instances of a module have to be instantiated at startup vf_config[module_name][ "initial_count"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".properties.initial_count") # Module version (& trailing '.0') vf_config[module_name][ "module_version"] = onap_utils.get_template_param( self.vnf_config["vnf"], "topology_template.groups." + vnf_type + ".metadata.vfModuleModelVersion") + ".0" # Update the VNF Context with integrated VFs self.vnf_config[elt].update(vf_config) # prepare index for next loop mod_index += 1 # Keep Nb of VF_Module for this VNF self.vnf_config[elt]['vf_modules_count'] = mod_index