COT.add_disk module

Module for adding disks to VMs.

COTAddDisk(UI) Add or replace a disk in a virtual machine.
add_disk_worker(vm, UI, DISK_IMAGE[, type, ...]) Worker function for actually adding the disk.
class COTAddDisk(UI)[source]

Bases: COT.submodule.COTSubmodule

Add or replace a disk in a virtual machine.

Inherited attributes: UI, package, output

Attributes: disk_image, type, file_id, controller, subtype, address, diskname, description

create_subparser(parent, storage)[source]

Add subparser for the CLI of this submodule.

Parameters:
  • parent (object) – Subparser grouping object returned by ArgumentParser.add_subparsers()
  • storage (dict) – Dict of { ‘label’: subparser } to be updated with subparser(s) created, if any.
ready_to_run()[source]

Check whether the module is ready to run().

Returns:(True, ready_message) or (False, reason_why_not)
run()[source]

Do the actual work of this submodule.

Raises InvalidInputError:
 if ready_to_run() reports False
validate_controller_address(controller, address)[source]

Check validity of the given address string for the given controller.

Helper method for the controller/address setters.

Parameters:
  • controller (str) – 'ide' or 'scsi'
  • address (str) – A string like ‘0:0’ or ‘2:10’
Raises:

InvalidInputError if the address/controller combo is invalid.

address

Disk device address on controller (1:0, etc.).

Raises:InvalidInputError, see validate_controller_address()
controller

Disk controller type (ide, scsi).

Raises:InvalidInputError, see validate_controller_address()
description = None

Description of the disk.

disk_image

Path to disk image file to add to the VM.

Raises:InvalidInputError if the file does not exist.
diskname = None

Name string for the disk.

file_id = None

File identifier to map disk to file.

subtype = None

Controller subtype, such as “virtio”.

type = None

Disk type (‘harddisk’ or ‘cdrom’).

add_disk_worker(vm, UI, DISK_IMAGE, type=None, file_id=None, controller=None, subtype=None, address=None, diskname=None, description=None)[source]

Worker function for actually adding the disk.

All parameters except vm, UI, and DISK_IMAGE are optional and will be automatically determined by COT if unspecified.

Parameters:
  • vm (OVF or other VMDescription subclass) – The virtual machine being edited.
  • UI (instance of UI or subclass.) – User interface in effect.
  • DISK_IMAGE (str) – path to disk image to add to the VM.
  • type (str) – Disk type: 'cdrom' or 'harddisk'. If not specified, will be derived automatically from the DISK_IMAGE file name extension.
  • file_id (str) – Identifier of the disk file in the VM. If not specified, the VM will automatically derive an appropriate value.
  • controller (str) – Disk controller type: 'ide' or 'scsi'. If not specified, will be derived from the type and the platform of the given vm.
  • subtype (str) – Controller subtype (‘virtio’, ‘lsilogic’, etc.)
  • address (str) – Disk device address on its controller (such as '1:0'). If this matches an existing disk device, that device will be overwritten. If not specified, the first available address not already occupied by an existing device will be selected.
  • diskname (str) – Name for disk device
  • description (str) – Description of disk device