The cinder.image.image_utils
Module¶
Helper methods to deal with images.
This is essentially a copy from nova.virt.images.py Some slight modifications, but at some point we should look at maybe pushing this up to Oslo
-
class
QemuImgJsonInfo
(cmd_output=None)¶ Bases:
oslo_utils.imageutils.QemuImgInfo
-
class
TemporaryImages
(image_service)¶ Bases:
object
Manage temporarily downloaded images to avoid downloading it twice.
In the ‘with TemporaryImages.fetch(image_service, ctx, image_id) as tmp’ clause, ‘tmp’ can be used as the downloaded image path. In addition, image_utils.fetch() will use the pre-fetched image by the TemporaryImages. This is useful to inspect image contents before conversion.
-
classmethod
fetch
(*args, **kwds)¶
-
static
for_image_service
(image_service)¶
-
get
(context, image_id)¶
-
classmethod
-
check_available_space
(dest, image_size, image_id)¶
-
check_image_format
(source, image_id=None, data=None, run_as_root=True)¶ Do some image format checks.
Verifies that the src_format matches what qemu-img thinks the image format is, and does some vmdk subformat checks. See Bug #1996188. - Does not check for a qcow2 backing file. - Will make a call out to qemu_img if data is None. :param source: filename of the image to check :param src_format: source image format recognized by qemu_img, or None :param image_id: the image ID if this is a Glance image, or None :param data: a imageutils.QemuImgInfo object from this image, or None :param run_as_root: when ‘data’ is None, call ‘qemu-img info’ as root :raises ImageUnacceptable: when the image fails some format checks :raises ProcessExecutionError: if ‘qemu-img info’ fails
-
check_qemu_img_version
(minimum_version)¶
-
check_vmdk_image
(image_id, data)¶ Check some rules about VMDK images.
Make sure the VMDK subformat (the “createType” in vmware docs) is one that we allow as determined by the ‘vmdk_allowed_types’ configuration option. The default set includes only types that do not reference files outside the VMDK file, which can otherwise be used in exploits to expose host information. :param image_id: the image id :param data: an imageutils.QemuImgInfo object :raises ImageUnacceptable: when the VMDK createType is not in the
allowed list
-
cleanup_temporary_file
(backend_name)¶
-
coalesce_chain
(vhd_chain)¶
-
coalesce_vhd
(vhd_path)¶
-
convert_image
(source, dest, out_format, run_as_root=True, throttle=None, image_id=None, data=None)¶
-
create_temporary_file
(*args, **kwargs)¶
-
discover_vhd_chain
(directory)¶
-
extract_targz
(archive_name, target)¶
-
fetch
(context, image_service, image_id, path, _user_id, _project_id)¶
-
fetch_to_raw
(context, image_service, image_id, dest, blocksize, user_id=None, project_id=None, size=None, run_as_root=True)¶
-
fetch_to_vhd
(context, image_service, image_id, dest, blocksize, user_id=None, project_id=None, run_as_root=True)¶
-
fetch_to_volume_format
(context, image_service, image_id, dest, volume_format, blocksize, user_id=None, project_id=None, size=None, run_as_root=True)¶
-
fetch_verify_image
(context, image_service, image_id, dest, user_id=None, project_id=None, size=None, run_as_root=True)¶
-
fix_vhd_chain
(vhd_chain)¶
-
get_qemu_img_version
()¶
-
get_vhd_size
(vhd_path)¶
-
is_xenserver_format
(image_meta)¶
-
is_xenserver_image
(context, image_service, image_id)¶
-
qemu_img_info
(path, run_as_root=True)¶ Return an object containing the parsed output from qemu-img info.
-
replace_xenserver_image_with_coalesced_vhd
(image_file)¶
-
resize_image
(source, size, run_as_root=False)¶ Changes the virtual size of the image.
-
resize_vhd
(vhd_path, size, journal)¶
-
set_vhd_parent
(vhd_path, parentpath)¶
-
temporary_dir
()¶
-
temporary_file
(*args, **kwds)¶
-
upload_volume
(context, image_service, image_meta, volume_path, volume_format='raw', run_as_root=True)¶
-
validate_disk_format
(disk_format)¶