Bug 264 Fix SO-RO translation for multi-disk
[osm/SO.git] / models / openmano / python / rift / openmano / rift2openmano.py
index 276573c..61e195b 100755 (executable)
@@ -488,6 +488,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 +501,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
@@ -611,9 +615,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 +684,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