COT.disks package reference

Package for handling various disk file types (VMDK, ISO, QCOW2, etc.).

Tries to provide an API that abstracts away differences in how the various types need to be operated on (e.g., qemu-img, mkisofs, etc.).

API

convert_disk Convert a disk representation into a new format.
create_disk Create a disk of the requested format.
disk_representation_from_file Get a DiskRepresentation appropriate to the given file.
DiskRepresentation Abstract disk image file representation.

Disk modules

COT.disks.disk Abstract base class for representations of disk image files.
COT.disks.iso Handling of ISO files.
COT.disks.qcow2 Handling of QCOW2 files.
COT.disks.raw Handling of raw disk image files.
COT.disks.vmdk Handling of VMDK files.
convert_disk(disk_image, new_directory, new_format, new_subformat=None)[source]

Convert a disk representation into a new format.

Parameters:
  • disk_image (DiskRepresentation) – Existing disk image as input.
  • new_directory (str) – Directory to create new image under
  • new_format (str) – Format to convert to.
  • new_subformat (str) – (optional) Sub-format to convert to.
Returns:

DiskRepresentation – Converted disk.

create_disk(disk_format, *args, **kwargs)[source]

Create a disk of the requested format.

Parameters:disk_format (str) – Disk format such as ‘iso’ or ‘vmdk’.

For the other parameters, see DiskRepresentation.

Returns:DiskRepresentation – Created disk
disk_representation_from_file(file_path)[source]

Get a DiskRepresentation appropriate to the given file.

Parameters:file_path (str) – Path of existing file to represent.
Returns:DiskRepresentation – Representation of this file.