From bf3e9a819a7c0153fa58b5140d1898147740977a Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Mon, 7 Mar 2022 17:55:20 +0000 Subject: [PATCH] Fix bug 2156 to select correct WIM connector class and prevent exceptions with missing parameters. Change-Id: I6f67b8a0fccc5a2ebf3f839899d748c41fac169a Signed-off-by: gifrerenom --- NG-RO/osm_ng_ro/ns.py | 4 ++-- NG-RO/osm_ng_ro/ns_thread.py | 12 +++++++---- .../notes/fix_bug_1899-0f326b896bd3a7ac.yaml | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/fix_bug_1899-0f326b896bd3a7ac.yaml diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 501ef03b..9a16241d 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -1653,7 +1653,7 @@ class Ns(object): target_record_id = "{}.{}".format(db_record, existing_item["id"]) item_ = item - if target_vim.startswith("sdn"): + if target_vim.startswith("sdn") or target_vim.startswith("wim"): # item must be sdn-net instead of net if target_vim is a sdn item_ = "sdn_net" target_record_id += ".sdn" @@ -1701,7 +1701,7 @@ class Ns(object): target_record_id = "{}.{}".format(db_record, target_item["id"]) item_ = item - if target_vim.startswith("sdn"): + if target_vim.startswith("sdn") or target_vim.startswith("wim"): # item must be sdn-net instead of net if target_vim is a sdn item_ = "sdn_net" target_record_id += ".sdn" diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index d1db698e..d2b00d65 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -1055,11 +1055,15 @@ class VimInteractionSdnNet(VimInteractionBase): try: # CREATE params = task["params"] - vlds_to_connect = params["vlds"] - associated_vim = params["target_vim"] + vlds_to_connect = params.get("vlds", []) + associated_vim = params.get("target_vim") # external additional ports additional_ports = params.get("sdn-ports") or () - _, _, vim_account_id = associated_vim.partition(":") + _, _, vim_account_id = ( + (None, None, None) + if associated_vim is None + else associated_vim.partition(":") + ) if associated_vim: # get associated VIM @@ -1830,7 +1834,7 @@ class NsWorker(threading.Thread): persistent_info={}, ) else: # sdn - plugin_name = "rosdn_" + vim["type"] + plugin_name = "rosdn_" + (vim.get("type") or vim.get("wim_type")) step = "Loading plugin '{}'".format(plugin_name) vim_module_conn = self._load_plugin(plugin_name, "sdn") step = "Loading {}'".format(target_id) diff --git a/releasenotes/notes/fix_bug_1899-0f326b896bd3a7ac.yaml b/releasenotes/notes/fix_bug_1899-0f326b896bd3a7ac.yaml new file mode 100644 index 00000000..975dcff5 --- /dev/null +++ b/releasenotes/notes/fix_bug_1899-0f326b896bd3a7ac.yaml @@ -0,0 +1,21 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fixing bug 1899 - to select correct WIM connector class and prevent exceptions with + missing parameters. -- 2.17.1