Fix bug 2154 to select correct WIM connector class and prevent exceptions with missin...
[osm/RO.git] / NG-RO / osm_ng_ro / ns_thread.py
index cb52d77..80d4aa7 100644 (file)
@@ -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,14 +1834,17 @@ 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)
                 wim = deepcopy(vim)
                 wim_config = wim.pop("config", {}) or {}
                 wim["uuid"] = wim["_id"]
-                wim["wim_url"] = wim["url"]
+                if "url" in wim and "wim_url" not in wim:
+                    wim["wim_url"] = wim["url"]
+                elif "url" not in wim and "wim_url" in wim:
+                    wim["url"] = wim["wim_url"]
 
                 if wim.get("dpid"):
                     wim_config["dpid"] = wim.pop("dpid")