RwYang,
RwVnfdYang,
RwNsdYang,
-)
+ )
import rift.package.store
import rift.package.cloud_init
openmano = {}
openmano["name"] = rift_nsd.name
if rift_vnfd_id is not None:
- openmano["name"] += "scale1"
+ openmano["name"] += "scale1"
openmano["description"] = rift_nsd.description
topology = {}
openmano["topology"] = topology
topology["nodes"][rift_vnfd.name + "__" + str(member_idx)] = {
"type": "VNF",
"vnf_id": openmano_vnfd_id
- }
+ }
else:
topology["nodes"][rift_vnfd.name + "__" + str(member_idx)] = {
"type": "VNF",
"VNF model": rift_vnfd.name
- }
+ }
for vld in rift_nsd.vlds:
# Openmano has both bridge_net and dataplane_net models for network types
if True:
if vld.name not in topology["nodes"]:
topology["nodes"][vld.name] = {
- "type": "external_network",
- "model": vld.name,
- }
+ "type": "external_network",
+ "model": vld.name,
+ }
# Add the external network to the list of connection points
topology["connections"][vld.name]["nodes"].append(
- {vld.name: "0"}
- )
+ {vld.name: "0"}
+ )
elif vld.provider_network.has_field("physical_network"):
# Add the external datacenter network to the topology
# node list if it isn't already added
if ext_net_name not in topology["nodes"]:
topology["nodes"][ext_net_name] = {
- "type": "external_network",
- "model": ext_net_name_with_seg,
- }
+ "type": "external_network",
+ "model": ext_net_name_with_seg,
+ }
# Add the external network to the list of connection points
topology["connections"][vld.name]["nodes"].append(
- {ext_net_name: "0"}
- )
+ {ext_net_name: "0"}
+ )
for vnfd_cp in vld.vnfd_connection_point_ref:
)
return openmano
-def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, rift_vnfd_id):
+def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=None):
+
if rift_vnfd_id not in rift_vnfds:
- print ("IDS", rift_vnfds)
- raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id)
+ print ("IDS", rift_vnfds)
+ raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id)
openmano_vnfd_nsd = {}
- openmano_vnfd_nsd["name"] = rift_vnfd_id+'-'+'scaling_group'
+ openmano_vnfd_nsd["name"] = rift_vnfd_id+'__'+'scaling_group'
openmano_vnfd_nsd["description"] = "Scaling Group"
topology = {}
openmano_vnfd_nsd["topology"] = topology
-
- topology["nodes"] = {}
- openmano_vnfd_nsd["topology"] = topology
topology["connections"] = {}
topology["nodes"] = {}
- topology["nodes"] = {
- "type": "VNF",
- "vnf_id": rift_vnfd_id
- }
+ tst_index = []
+ openmano_vnfd_id = openmano_vnfd_ids.get(rift_vnfd_id,None)
+ logger.debug("CONSTVNF %s", rift_nsd.constituent_vnfds)
+ for rvnfd_id in rift_nsd.constituent_vnfds:
+ if rvnfd_id.vnfd_id_ref == rift_vnfd_id:
+ topology["nodes"][rift_vnfd_id+'__'+str(rvnfd_id.member_vnf_index)] = {
+ "type": "VNF",
+ "vnf_id": openmano_vnfd_id
+ }
for vld in rift_nsd.vlds:
# Create a connections entry for each external VLD
topology["connections"][vld.name] = {}
topology["connections"][vld.name]["nodes"] = []
+ if True:
+ if vld.name not in topology["nodes"]:
+ topology["nodes"][vld.name] = {
+ "type": "external_network",
+ "model": vld.name,
+ }
+ topology["connections"][vld.name]["nodes"].append(
+ {vld.name: "0"}
+ )
+
+
for vnfd_cp in vld.vnfd_connection_point_ref:
- if not rit_vnfd_id in vnfd_cp.vnfd_id_ref:
+ if not rift_vnfd_id in vnfd_cp.vnfd_id_ref:
continue
if rift_vnfd_id in vnfd_cp.vnfd_id_ref:
+
# Get the RIFT VNF for this external VLD connection point
vnfd = rift_vnfds[vnfd_cp.vnfd_id_ref]
+
+
# For each VNF in this connection, use the same interface name
topology["connections"][vld.name]["type"] = "link"
# Vnf ref is the vnf name with the member_vnf_idx appended
)
return openmano_vnfd_nsd
+
def cloud_init(rift_vnfd_id, vdu):
""" Populate cloud_init with script from
either the inline contents or from the file provided
logger.debug("cloud_init script provided inline %s", vdu.cloud_init)
cloud_init_msg = vdu.cloud_init
elif vdu.cloud_init_file is not None:
- # Get cloud-init script contents from the file provided in the cloud_init_file param
+ # Get cloud-init script contents from the file provided in the cloud_init_file param
logger.debug("cloud_init script provided in file %s", vdu.cloud_init_file)
filename = vdu.cloud_init_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)
+ cfg_file_msg = cloud_init_extractor.read_script(stored_package, filename)
except rift.package.cloud_init.CloudInitExtractionError as e:
- raise ValueError(e)
+ raise ValueError(e)
logger.debug("Current config file msg is {}".format(cfg_file_msg))
return cfg_file_msg
"VNFC": vdu.name,
"local_iface_name": ext_if.name,
"description": "%s iface on VDU %s" % (ext_if.name, vdu.name),
- }
+ }
vnf["external-connections"].append(connection)
"description": vld.description,
"type": "bridge",
"elements": [],
- }
+ }
# Add the specific VDU connection points
for int_cp in vld.internal_connection_point:
connection["elements"].append({
"VNFC": vdu.name,
"local_iface_name": int_if.name,
- })
+ })
if "internal-connections" not in vnf:
vnf["internal-connections"] = []
"name": vdu.name,
"description": vdu.name,
"bridge-ifaces": [],
- }
+ }
if vdu.vm_flavor.has_field("storage_gb") and vdu.vm_flavor.storage_gb:
vnfc["disk"] = vdu.vm_flavor.storage_gb
dedicated_int = True
if vdu.guest_epa.has_field("numa_node_policy") or dedicated_int:
vnfc["numas"] = [{
- "memory": max(int(vdu.vm_flavor.memory_mb/1024), 1),
- "interfaces":[],
- }]
+ "memory": max(int(vdu.vm_flavor.memory_mb/1024), 1),
+ "interfaces":[],
+ }]
numa_node_policy = vdu.guest_epa.numa_node_policy
if numa_node_policy.has_field("node"):
numa_node = numa_node_policy.node[0]
if len(numa_node.paired_threads.paired_thread_ids) > 0:
vnfc["numas"][0]["paired-threads-id"] = []
for pair in numa_node.paired_threads.paired_thread_ids:
- vnfc["numas"][0]["paired-threads-id"].append(
- [pair.thread_a, pair.thread_b]
- )
+ vnfc["numas"][0]["paired-threads-id"].append(
+ [pair.thread_a, pair.thread_b]
+ )
else:
if vdu.vm_flavor.has_field("vcpu_count"):
if vdu.has_field("volumes"):
vnfc["devices"] = []
# Sort volumes as device-list is implictly ordered by Openmano
- newvollist = sorted(vdu.volumes, key=lambda k: k.name)
+ newvollist = sorted(vdu.volumes, key=lambda k: k.name)
for iter_num, volume in enumerate(newvollist):
if iter_num == 0:
# Convert the first volume to vnfc.image
device = {}
device["type"] = volume.device_type
device["image"] = volume.image
- vnfc["devices"].append(device)
+ vnfc["devices"].append(device)
vnfc_boot_data_init = False
if vdu.has_field("cloud_init") or vdu.has_field("cloud_init_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):
intf = {
"name": int_if.name,
- }
+ }
if int_if.virtual_interface.has_field("vpci"):
intf["vpci"] = int_if.virtual_interface.vpci
'-o', '--outdir',
default='-',
help="Directory to output converted descriptors. Default is stdout",
- )
+ )
parser.add_argument(
'-n', '--nsd-file-hdl',
metavar="nsd_file",
type=argparse.FileType('r'),
help="Rift NSD Descriptor File",
- )
+ )
parser.add_argument(
'-v', '--vnfd-file-hdls',
action='append',
type=argparse.FileType('r'),
help="Rift VNFD Descriptor File",
- )
+ )
args = parser.parse_args(argv)
def main(argv=sys.argv[1:]):
args = parse_args(argv)
nsd = None
- rift_vnfd_id = 'test_vnfd'
openmano_vnfr_ids = dict()
vnf_dict = None
if args.vnfd_file_hdls is not None:
if __name__ == "__main__":
logging.basicConfig(level=logging.WARNING)
- main()
\ No newline at end of file
+ main()