From 0b430f6b3690b78474aca98d2112f20a9f56c8a4 Mon Sep 17 00:00:00 2001 From: Gulsum Atici Date: Tue, 10 Jan 2023 14:10:42 +0300 Subject: [PATCH] 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 --- osm_lcm/ns.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 5d960c5..20e813f 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -1014,16 +1014,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: -- 2.25.1