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] = {}