Fix bug 1432: No support for alternative images for sol006 68/10368/1
authorlloretgalleg <illoret@indra.es>
Mon, 8 Feb 2021 11:49:50 +0000 (11:49 +0000)
committerlloretgalleg <illoret@indra.es>
Mon, 22 Feb 2021 10:09:49 +0000 (10:09 +0000)
Change-Id: Icc4a9871c0ae44fc516b6c60fd6e0a641324fcdd
Signed-off-by: lloretgalleg <illoret@indra.es>
osm_lcm/ns.py

index 5131f9f..e08e2d6 100644 (file)
@@ -783,8 +783,23 @@ class NsLcm(LcmBase):
                 ns_flavor = target["flavor"][int(vdur["ns-flavor-id"])]
                 if target_vim not in ns_flavor["vim_info"]:
                     ns_flavor["vim_info"][target_vim] = {}
-                # image
-                ns_image = target["image"][int(vdur["ns-image-id"])]
+
+                # deal with images
+                # in case alternative images are provided we must check if they should be applied
+                # for the vim_type, modify the vim_type taking into account
+                ns_image_id = int(vdur["ns-image-id"])
+                if vdur.get("alt-image-ids"):
+                    db_vim = get_vim_account(vnfr["vim-account-id"])
+                    vim_type = db_vim["vim_type"]
+                    for alt_image_id in vdur.get("alt-image-ids"):
+                        ns_alt_image = target["image"][int(alt_image_id)]
+                        if vim_type == ns_alt_image.get("vim-type"):
+                            # must use alternative image
+                            self.logger.debug("use alternative image id: {}".format(alt_image_id))
+                            ns_image_id = alt_image_id
+                            vdur["ns-image-id"] = ns_image_id
+                            break
+                ns_image = target["image"][int(ns_image_id)]
                 if target_vim not in ns_image["vim_info"]:
                     ns_image["vim_info"][target_vim] = {}