Fix Bug 2208 KeyError while checking SDN assists requirement 44/12844/1 v10.1.5
authorGulsum Atici <gulsum.atici@canonical.com>
Tue, 10 Jan 2023 11:10:42 +0000 (14:10 +0300)
committercubag <gcuba@whitestack.com>
Wed, 18 Jan 2023 05:32:49 +0000 (06:32 +0100)
VIM config is optional so code is fixed by checking the existence of VIM config.

Change-Id: I1aca37cf169a766219630c90968df9d729ffd621
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
(cherry picked from commit 0b430f6b3690b78474aca98d2112f20a9f56c8a4)

osm_lcm/ns.py

index 2694f76..0c934ed 100644 (file)
@@ -909,16 +909,16 @@ class NsLcm(LcmBase):
             # check if this network needs SDN assist
             if vld.get("pci-interfaces"):
                 db_vim = get_vim_account(ns_params["vimAccountId"])
-                sdnc_id = db_vim["config"].get("sdn-controller")
-                if sdnc_id:
-                    sdn_vld = "nsrs:{}:vld.{}".format(nsr_id, vld["id"])
-                    target_sdn = "sdn:{}".format(sdnc_id)
-                    target_vld["vim_info"][target_sdn] = {
-                        "sdn": True,
-                        "target_vim": target_vim,
-                        "vlds": [sdn_vld],
-                        "type": vld.get("type"),
-                    }
+                if vim_config := db_vim.get("config"):
+                    if sdnc_id := vim_config.get("sdn-controller"):
+                        sdn_vld = "nsrs:{}:vld.{}".format(nsr_id, vld["id"])
+                        target_sdn = "sdn:{}".format(sdnc_id)
+                        target_vld["vim_info"][target_sdn] = {
+                            "sdn": True,
+                            "target_vim": target_vim,
+                            "vlds": [sdn_vld],
+                            "type": vld.get("type"),
+                        }
 
             nsd_vnf_profiles = get_vnf_profiles(nsd)
             for nsd_vnf_profile in nsd_vnf_profiles: