bug 373 get cp port_security_enable from descriptor instead of pyangbind 69/5569/3
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 12 Oct 2017 08:22:45 +0000 (10:22 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 12 Oct 2017 08:34:58 +0000 (10:34 +0200)
Change-Id: I86180c9801c6ce0f3aaf06a34fa1a2cb21b5b39a
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
openmanod
osm_ro/nfvo.py

index a9faa32..c319a88 100755 (executable)
--- a/openmanod
+++ b/openmanod
@@ -48,7 +48,7 @@ import osm_ro
 
 __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
 __date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.33-r543"
+__version__ = "0.5.34-r544"
 version_date = "Oct 2017"
 database_version = 27      # expected database schema version
 
index e16f709..f6ec568 100644 (file)
@@ -803,6 +803,12 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
         db_flavors = []
         uuid_list = []
         vnfd_uuid_list = []
+        vnfd_catalog_descriptor = vnf_descriptor.get("vnfd:vnfd-catalog")
+        if not vnfd_catalog_descriptor:
+            vnfd_catalog_descriptor = vnf_descriptor.get("vnfd-catalog")
+        vnfd_descriptor_list = vnfd_catalog_descriptor.get("vnfd")
+        if not vnfd_descriptor_list:
+            vnfd_descriptor_list = vnfd_catalog_descriptor.get("vnfd:vnfd")
         for vnfd_yang in myvnfd.vnfd_catalog.vnfd.itervalues():
             vnfd = vnfd_yang.get()
 
@@ -821,6 +827,10 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
                 "descriptor": str(vnf_descriptor)[:60000]
             }
 
+            for vnfd_descriptor in vnfd_descriptor_list:
+                if vnfd_descriptor["id"] == str(vnfd["id"]):
+                    break
+
             # table nets (internal-vld)
             net_id2uuid = {}  # for mapping interface with network
             for vld in vnfd.get("internal-vld").itervalues():
@@ -1025,9 +1035,12 @@ 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
-                            if cp.get("port-security-enabled") == False:
+                            for cp_descriptor in vnfd_descriptor["connection-point"]:
+                                if cp_descriptor["name"] == db_interface["external_name"]:
+                                    break
+                            if str(cp_descriptor.get("port-security-enabled")).lower() == "false":
                                 db_interface["port_security"] = 0
-                            elif cp.get("port-security-enabled") == True:
+                            elif str(cp_descriptor.get("port-security-enabled")).lower() == "true":
                                 db_interface["port_security"] = 1
                         except KeyError:
                             raise NfvoException("Error. Invalid VNF descriptor at 'vnfd[{vnf}]':'vdu[{vdu}]':"
@@ -1042,9 +1055,12 @@ 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:
+                                        for cp_descriptor in vnfd_descriptor["connection-point"]:
+                                            if cp_descriptor["name"] == db_interface["external_name"]:
+                                                break
+                                        if str(cp_descriptor.get("port-security-enabled")).lower() == "false":
                                             db_interface["port_security"] = 0
-                                        elif cp.get("port-security-enabled") == True:
+                                        elif str(cp_descriptor.get("port-security-enabled")).lower() == "true":
                                             db_interface["port_security"] = 1
                                         break
                         except KeyError: