From e18ba43ea07577aeebb54d4c2b5966f856f3063d Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 12 Oct 2017 10:22:45 +0200 Subject: [PATCH] bug 373 get cp port_security_enable from descriptor instead of pyangbind Change-Id: I86180c9801c6ce0f3aaf06a34fa1a2cb21b5b39a Signed-off-by: tierno --- openmanod | 2 +- osm_ro/nfvo.py | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/openmanod b/openmanod index a9faa325..c319a882 100755 --- 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 diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index e16f7090..f6ec5680 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -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: -- 2.25.1