def constituent_vnfds(self):
return self._nsd.constituent_vnfd
+ @property
+ def scaling_group_descriptor(self):
+ return self._nsd.scaling_group_descriptor
+
@property
def vlds(self):
return self._nsd.vld
return vnfd_name + "__" + str(member_idx)
-def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids):
- for vnfd_id in rift_nsd.vnfd_ids:
- if vnfd_id not in rift_vnfds:
- raise VNFNotFoundError("VNF id %s not provided" % vnfd_id)
+def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None):
+ if rift_vnfd_id is None:
+ for vnfd_id in rift_nsd.vnfd_ids:
+ if vnfd_id not in rift_vnfds:
+ raise VNFNotFoundError("VNF id %s not provided" % vnfd_id)
openmano = {}
openmano["name"] = rift_nsd.name
+ if rift_vnfd_id is not None:
+ for scaling_groups in rift_nsd.scaling_group_descriptor:
+ openmano["name"] += scaling_groups.name
openmano["description"] = rift_nsd.description
topology = {}
openmano["topology"] = topology
topology["nodes"] = {}
for vnfd in rift_nsd.constituent_vnfds:
vnfd_id = vnfd.vnfd_id_ref
+ if rift_vnfd_id is not None and rift_vnfd_id != vnfd_id:
+ continue
rift_vnfd = rift_vnfds[vnfd_id]
member_idx = vnfd.member_vnf_index
openmano_vnfd_id = openmano_vnfd_ids.get(vnfd_id,None)
vnf_ref: vnfd_cp.vnfd_connection_point_ref
}
)
-
return openmano
+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
+
+
def cloud_init(rift_vnfd_id, vdu):
""" Populate cloud_init with script from
either the inline contents or from the file provided
raise ValueError("VDU Virtual Interface type {} not supported".format(rift_type))
# Add all external connections
+ cp_to_port_security_map = {}
+
for cp in rift_vnfd.cps:
# Find the VDU and and external interface for this connection point
vdu, ext_if = find_vdu_and_ext_if_by_cp_ref(cp.name)
"description": "%s iface on VDU %s" % (ext_if.name, vdu.name),
}
+ if cp.has_field('port_security_enabled'):
+ cp_to_port_security_map[cp.name] = cp.port_security_enabled
vnf["external-connections"].append(connection)
# Add all internal networks
# Add Openmano devices
device = {}
device["type"] = volume.device_type
- device["image name"] = volume.image
- if volume.has_field("image_checksum"):
- device["image checksum"] = volume.image_checksum
+ if volume.has_field("size"):
+ device["size"] = volume.size
+ if volume.has_field("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
if bps/x[1] >= 1:
intf["bandwidth"] = "{} {}bps".format(math.ceil(bps/x[1]), x[0])
+ for bridge_iface in vnfc["bridge-ifaces"]:
+ if bridge_iface['name'] in cp_to_port_security_map:
+ bridge_iface['port-security'] = cp_to_port_security_map[bridge_iface['name']]
# Sort bridge-ifaces-list TODO sort others
newlist = sorted(vnfc["bridge-ifaces"], key=lambda k: k['name'])
vnfc["bridge-ifaces"] = newlist
def main(argv=sys.argv[1:]):
args = parse_args(argv)
-
nsd = None
openmano_vnfr_ids = dict()
vnf_dict = None
nsd = create_nsd_from_file(args.nsd_file_hdl)
openmano_nsd = rift2openmano_nsd(nsd, vnf_dict, openmano_vnfr_ids)
-
+ vnfd_nsd = rift2openmano_vnfd_nsd(nsd, vnf_dict, openmano_vnfr_ids)
write_yaml_to_file(openmano_nsd["name"], args.outdir, openmano_nsd)
-
+ write_yaml_to_file(vnfd_nsd["name"], args.outdir, vnfd_nsd)
for vnf in vnf_dict.values():
openmano_vnf = rift2openmano_vnfd(vnf, nsd)
write_yaml_to_file(openmano_vnf["vnf"]["name"], args.outdir, openmano_vnf)