fix port security false at new IM
[osm/RO.git] / osm_ro / nfvo.py
index d5de61f..049cb50 100644 (file)
@@ -904,22 +904,22 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
                     if vdu["guest-epa"].get("numa-node-policy"):  # TODO or dedicated_int:
                         numa_node_policy = vdu["guest-epa"].get("numa-node-policy")
                         if numa_node_policy.get("node"):
-                            numa_node = numa_node_policy.node[0]
+                            numa_node = numa_node_policy["node"]['0']
                             if numa_node.get("num-cores"):
                                 numa["cores"] = numa_node["num-cores"]
                                 epa_vcpu_set = True
                             if numa_node.get("paired-threads"):
                                 if numa_node["paired-threads"].get("num-paired-threads"):
-                                    numa["paired-threads"] = numa_node["paired-threads"]["num-paired-threads"]
+                                    numa["paired-threads"] = int(numa_node["paired-threads"]["num-paired-threads"])
                                     epa_vcpu_set = True
-                                if len(numa_node["paired-threads"].get("paired-thread-ids")) > 0:
+                                if len(numa_node["paired-threads"].get("paired-thread-ids")):
                                     numa["paired-threads-id"] = []
-                                    for pair in numa_node["paired-threads"]["paired-thread-ids"].itervalues:
+                                    for pair in numa_node["paired-threads"]["paired-thread-ids"].itervalues():
                                         numa["paired-threads-id"].append(
                                             (str(pair["thread-a"]), str(pair["thread-b"]))
                                         )
                             if numa_node.get("num-threads"):
-                                numa["threads"] = numa_node["num-threads"]
+                                numa["threads"] = int(numa_node["num-threads"])
                                 epa_vcpu_set = True
                             if numa_node.get("memory-mb"):
                                 numa["memory"] = max(int(numa_node["memory-mb"] / 1024), 1)
@@ -1021,9 +1021,10 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
                             db_interface["external_name"] = get_str(cp, "name", 255)
                             cp_name2iface_uuid[db_interface["external_name"]] = iface_uuid
                             cp_name2vm_uuid[db_interface["external_name"]] = vm_uuid
-                            # TODO add port-security-enable
-                            # if cp.get("port-security-enabled") == False:
-                            # elif cp.get("port-security-enabled") == True:
+                            if cp.get("port-security-enabled") == False:
+                                db_interface["port_security"] = 0
+                            elif cp.get("port-security-enabled") == True:
+                                db_interface["port_security"] = 1
                         except KeyError:
                             raise NfvoException("Error. Invalid VNF descriptor at 'vnfd[{vnf}]':'vdu[{vdu}]':"
                                                 "'interface[{iface}]':'vnfd-connection-point-ref':'{cp}' is not present"
@@ -1037,6 +1038,10 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
                                 for cp in vld.get("internal-connection-point").itervalues():
                                     if cp.get("id-ref") == iface.get("internal-connection-point-ref"):
                                         db_interface["net_id"] = net_id2uuid[vld.get("id")]
+                                        if cp.get("port-security-enabled") == False:
+                                            db_interface["port_security"] = 0
+                                        elif cp.get("port-security-enabled") == True:
+                                            db_interface["port_security"] = 1
                                         break
                         except KeyError:
                             raise NfvoException("Error. Invalid VNF descriptor at 'vnfd[{vnf}]':'vdu[{vdu}]':"