Bug 299 fixed
[osm/SO.git] / models / openmano / python / rift / openmano / rift2openmano.py
index 276573c..44e80b6 100755 (executable)
@@ -339,7 +339,8 @@ def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=
     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)] = {
+            rift_vnfd = rift_vnfds[rift_vnfd_id]
+            topology["nodes"][rift_vnfd.name +'__'+str(rvnfd_id.member_vnf_index)] = {
                 "type": "VNF",
                 "vnf_id": openmano_vnfd_id
             }
@@ -374,7 +375,7 @@ def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=
             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)
+            vnf_ref = vnfd.name + "__" + str(member_idx)
             topology["connections"][vld.name]["nodes"].append(
                 {
                     vnf_ref: vnfd_cp.vnfd_connection_point_ref
@@ -488,6 +489,8 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             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)
@@ -499,6 +502,8 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             "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
@@ -555,6 +560,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             if numa_node_policy.has_field("node"):
                 numa_node = numa_node_policy.node[0]
 
+                if numa_node.has_field("num_cores"):
+                    vnfc["numas"][0]["cores"] = numa_node.num_cores
+
                 if numa_node.has_field("paired_threads"):
                     if numa_node.paired_threads.has_field("num_paired_threads"):
                         vnfc["numas"][0]["paired-threads"] = numa_node.paired_threads.num_paired_threads
@@ -565,6 +573,8 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                                      [pair.thread_a, pair.thread_b]
                                      )
 
+                if numa_node.has_field("num_threads"):
+                    vnfc["numas"][0]["threads"] = numa_node.num_threads
             else:
                 if vdu.vm_flavor.has_field("vcpu_count"):
                     vnfc["numas"][0]["cores"] = max(vdu.vm_flavor.vcpu_count, 1)
@@ -611,9 +621,12 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                     # 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
@@ -677,6 +690,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                         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