Handling of block device information and mapping.
This module contains helper methods for intepreting the block device information and determining the suitable mapping to guest devices and libvirt XML.
Throughout these methods there are a number of standard variables / types used
‘mapping’: a dict contains the storage device mapping.
For the default disk types it will contain the following keys & values:
‘disk’ -> disk_info ‘disk.rescue’ -> disk_info ‘disk.local’ -> disk_info ‘disk.swap’ -> disk_info ‘disk.config’ -> disk_info
If any of the default disks are overriden by the block device info mappings, the hash value will be None
For any ephemeral device there will also be a dict entry
‘disk.eph$NUM’ -> disk_info
For any volume device there will also be a dict entry:
$path -> disk_info
Finally a special key will refer to the root device:
‘root’ -> disk_info
‘disk_info’: a tuple specifying disk configuration
It contains the following 3 fields
(disk bus, disk dev, device type)
‘disk_bus’: the guest bus type (‘ide’, ‘virtio’, ‘scsi’, etc)
‘disk_dev’: the device name ‘vda’, ‘hdc’, ‘sdf’, ‘xvde’ etc
‘device_type’: type of device eg ‘disk’, ‘cdrom’, ‘floppy’
Identify a free disk dev name for a bus.
Determines the possible disk dev names for the bus, and then checks them in order until it identifies one that is not yet used in the disk mapping. If ‘last_device’ is set, it will only consider the last available disk dev name.
Returns the chosen disk_dev name, or raises an exception if none is available.
Determine the type of config drive.
If config_drive_format is set to iso9660 then the config drive will be ‘cdrom’, otherwise ‘disk’.
Returns a string indicating the config drive type.
Determine the number disks supported.
Determine how many disks can be supported in a single VM for a particular disk bus.
Returns the number of disks supported.
Determine the dev prefix for a disk bus.
Determine the dev prefix to be combined with a disk number to fix a disk_dev. eg ‘hd’ for ‘ide’ bus can be used to form a disk dev ‘hda’
Returns the dev prefix or raises an exception if the disk bus is unknown.
Determine the best disk bus to use for a device type.
Considering the currently configured virtualization type, return the optimal disk_bus to use for a given device type. For example, for a disk on KVM it will return ‘virtio’, while for a CDROM it will return ‘ide’
Returns the disk_bus, or returns None if the device type is not supported for this virtualization
Determine the disk bus for a disk dev.
Given a disk devi like ‘hda’, ‘sdf’, ‘xvdb’, etc guess what the most appropriate disk bus is for the currently configured virtualization technology
Returns the disk bus, or raises an Exception if the disk dev prefix is unknown.
Determine guest disk mapping info.
This is a wrapper around get_disk_mapping, which also returns the chosen disk_bus and cdrom_bus. The returned data is in a dict
- disk_bus: the bus for harddisks
- cdrom_bus: the bus for CDROMs
- mapping: the disk mapping
Returns the disk mapping disk.
Determine how to map default disks to the virtual machine.
This is about figuring out whether the default ‘disk’, ‘disk.local’, ‘disk.swap’ and ‘disk.config’ images have been overriden by the block device mapping.
Returns the guest disk mapping for the devices.
Determine the disk info for the next device on disk_bus.
Considering the disks already listed in the disk mapping, determine the next available disk dev that can be assigned for the disk bus.
Returns the disk_info for the next available disk.
Determine if a disk device name has already been used.
Looks at all the keys in mapping to see if any corresponding disk_info tuple has a device name matching disk_dev
Returns True if the disk_dev is in use.