Fix Bug 2028 Multi-site VNF creation fails 99/12199/4
authoraticig <gulsum.atici@canonical.com>
Tue, 14 Jun 2022 00:01:36 +0000 (03:01 +0300)
committeraticig <gulsum.atici@canonical.com>
Tue, 21 Jun 2022 18:39:09 +0000 (21:39 +0300)
This fix will provide to use  the vim_network_name from instantiation parameters if it exists,
if not, network which is given in NSD will be used for the NS which is instantiated on multi-site VIMs.

Change-Id: Ie39e3444428474c8db01d59ef1a1995644ea6a81
Signed-off-by: aticig <gulsum.atici@canonical.com>
osm_lcm/ns.py

index 2e9c1bc..33e1d18 100644 (file)
@@ -897,18 +897,55 @@ class NsLcm(LcmBase):
                             get_iterable(vdur, "interfaces"),
                             lambda iface: iface.get("ns-vld-id") == a_vld["name"],
                         )
+
+                        vld_params = find_in_list(
+                            get_iterable(ns_params, "vld"),
+                            lambda v_vld: v_vld["name"] in (a_vld["name"], a_vld["id"]),
+                        )
                         if target_vld:
+
                             if vnf_params.get("vimAccountId") not in a_vld.get(
                                 "vim_info", {}
                             ):
+                                target_vim_network_list = [
+                                    v for _, v in a_vld.get("vim_info").items()
+                                ]
+                                target_vim_network_name = next(
+                                    (
+                                        item.get("vim_network_name", "")
+                                        for item in target_vim_network_list
+                                    ),
+                                    "",
+                                )
+
                                 target["ns"]["vld"][a_index].get("vim_info").update(
                                     {
                                         "vim:{}".format(vnf_params["vimAccountId"]): {
-                                            "vim_network_name": ""
+                                            "vim_network_name": target_vim_network_name,
                                         }
                                     }
                                 )
 
+                                if vld_params:
+                                    for param in ("vim-network-name", "vim-network-id"):
+                                        if vld_params.get(param) and isinstance(
+                                            vld_params[param], dict
+                                        ):
+                                            for vim, vim_net in vld_params[
+                                                param
+                                            ].items():
+                                                other_target_vim = "vim:" + vim
+                                                populate_dict(
+                                                    target["ns"]["vld"][a_index].get(
+                                                        "vim_info"
+                                                    ),
+                                                    (
+                                                        other_target_vim,
+                                                        param.replace("-", "_"),
+                                                    ),
+                                                    vim_net,
+                                                )
+
         nslcmop_id = db_nslcmop["_id"]
         target = {
             "name": db_nsr["name"],