def preprocess_image(test, params, image_name): """ Preprocess a single QEMU image according to the instructions in params. @param test: Autotest test object. @param params: A dict containing image preprocessing parameters. @note: Currently this function just creates an image if requested. """ if params.get("storage_type") == "iscsi": iscsidev = kvm_storage.Iscsidev(params, test.bindir, image_name) params["image_name"] = iscsidev.setup() else: image_filename = storage.get_image_filename(params, test.bindir) create_image = False if params.get("force_create_image") == "yes": create_image = True elif (params.get("create_image") == "yes" and not os.path.exists(image_filename)): create_image = True if create_image: image = kvm_storage.QemuImg(params, test.bindir, image_name) if not image.create(params): raise error.TestError("Could not create image")
def postprocess_image(test, params, image_name): """ Postprocess a single QEMU image according to the instructions in params. @param test: An Autotest test object. @param params: A dict containing image postprocessing parameters. """ clone_master = params.get("clone_master", None) base_dir = data_dir.get_data_dir() if params.get("storage_type") == "iscsi": iscsidev = kvm_storage.Iscsidev(params, base_dir, image_name) iscsidev.cleanup() else: image = kvm_storage.QemuImg(params, base_dir, image_name) if params.get("check_image") == "yes": try: if clone_master is None: image.check_image(params, base_dir) elif clone_master == "yes": if image_name in params.get("master_images_clone").split(): image.check_image(params, base_dir) except Exception, e: if params.get("restore_image_on_check_error", "no") == "yes": image.backup_image(params, base_dir, "restore", True) if params.get("remove_image_on_check_error", "no") == "yes": cl_images = params.get("master_images_clone", "") if image_name in cl_images.split(): image.remove() raise e if params.get("remove_image") == "yes": if clone_master is None: image.remove() elif clone_master == "yes": if image_name in params.get("master_images_clone").split(): image.remove()
def postprocess_image(test, params, image_name): """ Postprocess a single QEMU image according to the instructions in params. @param test: An Autotest test object. @param params: A dict containing image postprocessing parameters. """ if params.get("storage_type") == "iscsi": iscsidev = kvm_storage.Iscsidev(params, test.bindir, image_name) iscsidev.cleanup() else: image = kvm_storage.QemuImg(params, test.bindir, image_name) if params.get("check_image") == "yes": try: image.check_image(params, test.bindir) except Exception, e: if params.get("restore_image_on_check_error", "no") == "yes": image.backup_image(params, test.bindir, "restore", True) raise e if params.get("remove_image") == "yes": image.remove()