- set_opt_val(param, "availabilityZone",
- ignore_case_get(vm["properties"]["location_info"], "availability_zone"))
+ # set boot param
+ if "image_file" in vm and vm["image_file"]:
+ param["boot"]["type"] = BOOT_FROM_IMAGE
+ img_name = ""
+ for img in ignore_case_get(data, "image_files"):
+ if vm["image_file"] == img["image_file_id"]:
+ img_name = img["properties"]["name"]
+ break
+ if not img_name:
+ raise VimException("Undefined image(%s)" % vm["image_file"], ERR_CODE)
+ images = api.list_image(vim_id, tenant_id)
+ for image in images["imageList"]:
+ if img_name == image["name"]:
+ param["boot"]["imageId"] = image["id"]
+ break
+ if "imageId" not in param["boot"]:
+ raise VimException("Image(%s) not found in Vim(%s)" % (img_name, vim_id), ERR_CODE)
+ elif vm["volume_storages"]:
+ param["boot"]["type"] = BOOT_FROM_VOLUME
+ vol_id = vm["volume_storages"][0]["volume_storage_id"]
+ param["boot"]["volumeId"] = get_res_id(res_cache, RES_VOLUME, vol_id)
+ else:
+ raise VimException("No image and volume defined", ERR_CODE)
+
+ for cp_id in ignore_case_get(vm, "cps"):
+ param["nicArray"].append({
+ "portId": get_res_id(res_cache, RES_PORT, cp_id)
+ })