+def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=None):
+
+ if rift_vnfd_id not in rift_vnfds:
+ raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id)
+
+ openmano_vnfd_nsd = {}
+ for groups in rift_nsd.scaling_group_descriptor:
+ openmano_vnfd_nsd["name"] = rift_vnfd_id+'__'+'scaling_group'+'__'+groups.name
+ openmano_vnfd_nsd["description"] = "Scaling Group"
+ topology = {}
+ openmano_vnfd_nsd["topology"] = topology
+ topology["connections"] = {}
+ topology["nodes"] = {}
+ tst_index = []
+ openmano_vnfd_id = openmano_vnfd_ids.get(rift_vnfd_id,None)
+ 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 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
+ member_idx = vnfd_cp.member_vnf_index_ref
+ vnf_ref = rift_vnfd_id + "__" + str(member_idx)
+ topology["connections"][vld.name]["nodes"].append(
+ {
+ vnf_ref: vnfd_cp.vnfd_connection_point_ref
+ }
+ )
+ return openmano_vnfd_nsd
+
+