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¶
DiskRepresentation |
Abstract disk image file representation. |
Disk modules¶
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. |
-
class
DiskRepresentation
(path)[source]¶ Bases:
object
Abstract disk image file representation.
-
__init__
(path)[source]¶ Create a representation of an existing disk.
Parameters: path (str) -- Path to existing file.
-
static
class_for_format
(disk_format)[source]¶ Get the DiskRepresentation subclass associated with the given format.
Parameters: disk_format (str) -- Disk format string such as 'iso' or 'vmdk' Returns: DiskRepresentation -- appropriate subclass object.
-
convert_to
(new_format, new_directory, new_subformat=None)[source]¶ Convert the disk file to a new format and return the new instance.
Parameters: Returns: DiskRepresentation -- Converted disk
Raises: NotImplementedError
-- if new_format is not a supported typeSee also
-
classmethod
create_file
(path, files=None, capacity=None, **kwargs)[source]¶ Create a new disk image file of this type.
Parameters: Raises: ValueError
-- if path is not a valid stringRuntimeError
-- if a file already exists at path.RuntimeError
-- if neither files nor capacity is specified
-
classmethod
file_is_this_type
(path)[source]¶ Check if the given file is image type represented by this class.
Parameters: path (str) -- Path to file to check. Returns: int -- Confidence that this file matches. 0 is definitely not a match, 100 is definitely a match. Raises: HelperError
-- if no file exists atpath
.
-
classmethod
for_new_file
(path, disk_format, **kwargs)[source]¶ Create a new disk file and return a DiskRepresentation.
Parameters: Returns: DiskRepresentation -- representation of the created file.
Raises: NotImplementedError
-- ifdisk_format
is not supported.
-
static
from_file
(path)[source]¶ Get a DiskRepresentation instance appropriate to the given file.
Parameters: path (str) -- Path of existing file to represent.
Returns: DiskRepresentation -- Representation of this file.
Raises: IOError
-- if no file exists at the given pathNotImplementedError
-- if the file is not a supported type.
-
classmethod
from_other_image
(input_image, output_dir, output_subformat=None)[source]¶ Convert the other disk image into an image of this type.
Parameters: - input_image (DiskRepresentation) -- Existing image representation.
- output_dir (str) -- Output directory to store the new image in.
- output_subformat (str) -- Any relevant subformat information.
Raises: NotImplementedError
-- Subclasses may implement this.
-
static
subclasses
()[source]¶ List of subclasses of DiskRepresentation.
Wraps the
class.__subclasses__()
builtin.
-
capacity
¶ Capacity of this disk image, in bytes.
-
disk_format
= None¶
-
disk_subformat
¶ Sub-format of the disk, such as 'rockridge' or 'streamOptimized'.
-
files
¶ List of files embedded in this disk image.
-
path
¶ System path to this disk file.
-
predicted_drive_type
¶ Disk drive type typically used for a Disk of this type.
Returns: str -- 'cdrom' or 'harddisk'
-