From: Gulsum Atici Date: Tue, 10 Jan 2023 11:10:42 +0000 (+0300) Subject: Fix Bug 2208 KeyError while checking SDN assists requirement X-Git-Tag: v12.0.6~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F12843%2F1;p=osm%2FLCM.git Fix Bug 2208 KeyError while checking SDN assists requirement VIM config is optional so code is fixed by checking the existence of VIM config. Change-Id: I1aca37cf169a766219630c90968df9d729ffd621 Signed-off-by: Gulsum Atici (cherry picked from commit 0b430f6b3690b78474aca98d2112f20a9f56c8a4) --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index f5fcb64..aee532f 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -1005,16 +1005,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: