From 7dc946716e5fc51340e143442ce45bff8c948525 Mon Sep 17 00:00:00 2001 From: lloretgalleg Date: Mon, 8 Feb 2021 11:49:50 +0000 Subject: [PATCH] Fix bug 1432: No support for alternative images for sol006 Change-Id: Icc4a9871c0ae44fc516b6c60fd6e0a641324fcdd Signed-off-by: lloretgalleg --- osm_lcm/ns.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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] = {} -- 2.17.1