X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=models%2Fopenmano%2Fpython%2Frift%2Fopenmano%2Frift2openmano.py;h=80436461962fce1dc3c0efb0084bcab6938200a3;hb=783da8a2e4fe2fc3f11a85eca96ed64177b12d63;hp=37b2f0618c8b7ee5c46e5fb142874e94e594f26c;hpb=97467c2ec5f6ea2a2e64e59a8a4d2a65714c178c;p=osm%2FSO.git diff --git a/models/openmano/python/rift/openmano/rift2openmano.py b/models/openmano/python/rift/openmano/rift2openmano.py index 37b2f061..80436461 100755 --- a/models/openmano/python/rift/openmano/rift2openmano.py +++ b/models/openmano/python/rift/openmano/rift2openmano.py @@ -341,6 +341,25 @@ def cloud_init(rift_vnfd_id, vdu): logger.debug("Current cloud init msg is {}".format(cloud_init_msg)) return cloud_init_msg +def config_file_init(rift_vnfd_id, vdu, cfg_file): + """ Populate config file init with file provided + """ + vnfd_package_store = rift.package.store.VnfdPackageFilesystemStore(logger) + + # Get script contents from the file provided in the cloud_init directory + logger.debug("config file script provided in file {}".format(cfg_file)) + filename = cfg_file + vnfd_package_store.refresh() + stored_package = vnfd_package_store.get_package(rift_vnfd_id) + cloud_init_extractor = rift.package.cloud_init.PackageCloudInitExtractor(logger) + try: + cfg_file_msg = cloud_init_extractor.read_script(stored_package, filename) + except rift.package.cloud_init.CloudInitExtractionError as e: + raise ValueError(e) + + logger.debug("Current config file msg is {}".format(cfg_file_msg)) + return cfg_file_msg + def rift2openmano_vnfd(rift_vnfd, rift_nsd): openmano_vnf = {"vnf":{}} vnf = openmano_vnf["vnf"] @@ -417,7 +436,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd): connection = { "name": vld.name, "description": vld.description, - "type": "data", + "type": "bridge", "elements": [], } @@ -523,7 +542,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd): # Add Openmano devices device = {} device["type"] = volume.device_type - device["image"] = volume.image + device["image name"] = volume.image + if volume.has_field("image_checksum"): + device["image checksum"] = volume.image_checksum vnfc["devices"].append(device) vnfc_boot_data_init = False @@ -540,6 +561,14 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd): vnfc_boot_data_init = True vnfc['boot-data']['boot-data-drive'] = vdu.supplemental_boot_data.boot_data_drive + if vdu.supplemental_boot_data.has_field('config_file'): + om_cfgfile_list = list() + for custom_config_file in vdu.supplemental_boot_data.config_file: + cfg_source = config_file_init(rift_vnfd.id, vdu, custom_config_file.source) + om_cfgfile_list.append({"dest":custom_config_file.dest, "content": cfg_source}) + vnfc['boot-data']['config-files'] = om_cfgfile_list + + vnf["VNFC"].append(vnfc) for int_if in list(vdu.internal_interface) + list(vdu.external_interface): @@ -579,6 +608,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd): if bps/x[1] >= 1: intf["bandwidth"] = "{} {}bps".format(math.ceil(bps/x[1]), x[0]) + # Sort bridge-ifaces-list TODO sort others + newlist = sorted(vnfc["bridge-ifaces"], key=lambda k: k['name']) + vnfc["bridge-ifaces"] = newlist return openmano_vnf