Helper methods for operations related to the management of VM records and their attributes like VDIs, VIFs, as well as their lookup functions.
Enumeration class for distinguishing different image types
Bases: nova.virt.xenapi.HelperBase
The class that wraps the helper methods together.
Partition and resize FS to match the size specified by instance_types.root_gb.
This is a fail-safe to prevent accidentally destroying data on a disk erroneously marked as auto_disk_config=True.
The criteria for allowing resize are:
- ‘auto_disk_config’ must be true for the instance (and image). (If we’ve made it here, then auto_disk_config=True.)
- The disk must have only one partition.
- The file-system on the one partition must be ext3 or ext4.
Clones a VDI and return the new VDIs reference.
Compile VM diagnostics data
Fill record with VM status information
Compile bandwidth usage, cpu, and disk metrics for all VMs on this host
Copy a VDI and return the new VDIs reference.
Creates VDI from the image stored in the local cache. If the image is not present in the cache, it streams it from glance.
Returns: A list of dictionaries that describe VDIs
Creates kernel/ramdisk file from the image stored in the cache. If the image is not present in the cache, it streams it from glance.
Returns: A list of dictionaries that describe VDIs
Creates Snapshot (Template) VM, Snapshot VBD, Snapshot VDI, Snapshot VHD
Create a VBD record and returns its reference.
Create a VDI record and returns its reference.
Create a VM record. Returns a Deferred that gives the new VM reference. the use_pv_kernel flag indicates whether the guest is HVM or PV
There are 3 scenarios:
- Using paravirtualization, kernel passed in
- Using paravirtualization, kernel within the image
- Using hardware virtualization
Destroy VBD from host database
Disk Image Types are used to determine where the kernel will reside within an image. To figure out which type we’re dealing with, we use the following rules:
Determine whether the VM will use a paravirtualized kernel or if it will use hardware virtualization.
- Glance (VHD): then we use os_type, raise if not set
- Glance (DISK_RAW): use Pygrub to figure out if pv kernel is available
- Glance (DISK): pv is assumed
- Glance (DISK_ISO): no pv is assumed
Fetch image from glance based on image type.
Returns the vdi-ref of the cached image.
Return the storage repository to hold ISO images
Return the storage repository to hold VM images
Get the VBD reference from the device number
Return the path to our storage repository
This is used when we’re dealing with VHDs directly, either by taking snapshots or by restoring an image in the DISK_VHD format.
Retrieves the primary VDI for a VM
Look the instance up and return it if available
Look for the VDIs that are attached to the VM
Makes alterations to the image before launching as part of spawn.
Same as find_iso_sr except raises a NotFound exception if SR cannot be determined
Same as find_sr except raises a NotFound exception if SR cannot be determined
Looks for the system default SR and triggers a re-scan
Scans the SR specified by sr_ref
Unplug VBD from VM
Requests that the Glance plugin bundle the specified VDIs and push them into Glance using the specified human-friendly name.
Return the VM RRD XML as a string
Return server’s scheme and address to use for retrieving RRD XMLs.
Return the RRD updates XML as a string
Returns the VHD parent of the given VDI record, as a (ref, rec) pair. Returns None if we’re at the root of the tree.
Return the appropriate location for a plugged-in VBD device
Ubuntu Maverick moved xvd? -> sd?. This is considered a bug and will be fixed in future versions:
For now, we work around it by just doing a string replace.
Call VBD.unplug on the given VBD, with a retry if we get DEVICE_DETACH_REJECTED. For reasons which I don’t understand, we’re seeing the device still in use, even when all processes using the device should be dead.
Yield vdi_recs for each element in a VDI chain