From: lloretgalleg Date: Mon, 8 Feb 2021 11:49:50 +0000 (+0000) Subject: Fix bug 1432: No support for alternative images for sol006 X-Git-Tag: v9.1.0~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F10368%2F1;p=osm%2FLCM.git Fix bug 1432: No support for alternative images for sol006 Change-Id: Icc4a9871c0ae44fc516b6c60fd6e0a641324fcdd Signed-off-by: lloretgalleg --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 5131f9f..e08e2d6 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -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] = {}