The cinder.volume.drivers.vmware.volumeops Module

Implements operations on volumes residing on VMware datastores.

class ControllerType

Bases: object

Encapsulate various controller types.

BUS_LOGIC = 'VirtualBusLogicController'
CONTROLLER_TYPE_DICT = {'paraVirtual': 'ParaVirtualSCSIController', 'ide': 'VirtualIDEController', 'busLogic': 'VirtualBusLogicController', 'lsiLogicsas': 'VirtualLsiLogicSASController', 'lsiLogic': 'VirtualLsiLogicController'}
IDE = 'VirtualIDEController'
LSI_LOGIC = 'VirtualLsiLogicController'
LSI_LOGIC_SAS = 'VirtualLsiLogicSASController'
PARA_VIRTUAL = 'ParaVirtualSCSIController'
static get_controller_type(adapter_type)

Get the disk controller type based on the given adapter type.

Parameters:adapter_type – disk adapter type
Returns:controller type corresponding to the given adapter type
Raises:InvalidAdapterTypeException
static is_scsi_controller(controller_type)

Check if the given controller is a SCSI controller.

Parameters:controller_type – controller type
Returns:True if the controller is a SCSI controller
class FlatExtentVirtualDiskPath(ds_name, folder_path, disk_name)

Bases: cinder.volume.drivers.vmware.volumeops.VirtualDiskPath

Paths of files in a non-monolithic disk with a single flat extent.

get_flat_extent_ds_file_path()

Get datastore file path of the flat extent.

get_flat_extent_file_path()

Get absolute file path of the flat extent.

class MonolithicSparseVirtualDiskPath(ds_name, folder_path, disk_name)

Bases: cinder.volume.drivers.vmware.volumeops.VirtualDiskPath

Paths of file comprising a monolithic sparse disk.

class VMwareVolumeOps(session, max_objects)

Bases: object

Manages volume operations.

attach_disk_to_backing(backing, size_in_kb, disk_type, adapter_type, profile_id, vmdk_ds_file_path)

Attach an existing virtual disk to the backing VM.

Parameters:
  • backing – reference to the backing VM
  • size_in_kb – disk size in KB
  • disk_type – virtual disk type
  • adapter_type – disk adapter type
  • profile_id – storage policy profile identification
  • vmdk_ds_file_path – datastore file path of the virtual disk to be attached
cancel_retrieval(retrieve_result)

Cancel retrieval of results if necessary.

Parameters:retrieve_result – Result from RetrievePropertiesEx
change_backing_profile(backing, profile_id)

Change storage profile of the backing VM.

The current profile is removed if the new profile is None.

clone_backing(name, backing, snapshot, clone_type, datastore, disk_type=None, host=None, resource_pool=None, extra_config=None, folder=None)

Clone backing.

If the clone_type is ‘full’, then a full clone of the source volume backing will be created. Else, if it is ‘linked’, then a linked clone of the source volume backing will be created.

Parameters:
  • name – Name for the clone
  • backing – Reference to the backing entity
  • snapshot – Snapshot point from which the clone should be done
  • clone_type – Whether a full clone or linked clone is to be made
  • datastore – Reference to the datastore entity
  • disk_type – Disk type of the clone
  • host – Target host
  • resource_pool – Target resource pool
  • extra_config – Key-value pairs to be written to backing’s extra-config
  • folder – The location of the clone
continue_retrieval(retrieve_result)

Continue retrieval of results if necessary.

Parameters:retrieve_result – Result from RetrievePropertiesEx
copy_vmdk_file(src_dc_ref, src_vmdk_file_path, dest_vmdk_file_path, dest_dc_ref=None)

Copy contents of the src vmdk file to dest vmdk file.

Parameters:
  • src_dc_ref – Reference to datacenter containing src datastore
  • src_vmdk_file_path – Source vmdk file path
  • dest_vmdk_file_path – Destination vmdk file path
  • dest_dc_ref – Reference to datacenter of dest datastore. If unspecified, source datacenter is used.
create_backing(name, size_kb, disk_type, folder, resource_pool, host, ds_name, profileId=None, adapter_type='lsiLogic', extra_config=None)

Create backing for the volume.

Creates a VM with one VMDK based on the given inputs.

Parameters:
  • name – Name of the backing
  • size_kb – Size in KB of the backing
  • disk_type – VMDK type for the disk
  • folder – Folder, where to create the backing under
  • resource_pool – Resource pool reference
  • host – Host reference
  • ds_name – Datastore name where the disk is to be provisioned
  • profileId – Storage profile ID to be associated with backing
  • adapter_type – Disk adapter type
  • extra_config – Key-value pairs to be written to backing’s extra-config
Returns:

Reference to the created backing entity

create_backing_disk_less(name, folder, resource_pool, host, ds_name, profileId=None, extra_config=None)

Create disk-less volume backing.

This type of backing is useful for creating volume from image. The downloaded image from the image service can be copied to a virtual disk of desired provisioning type and added to the backing VM.

Parameters:
  • name – Name of the backing
  • folder – Folder where the backing is created
  • resource_pool – Resource pool reference
  • host – Host reference
  • ds_name – Name of the datastore used for VM storage
  • profileId – Storage profile ID to be associated with backing
  • extra_config – Key-value pairs to be written to backing’s extra-config
Returns:

Reference to the created backing entity

create_datastore_folder(ds_name, folder_path, datacenter)

Creates a datastore folder.

This method returns silently if the folder already exists.

Parameters:
  • ds_name – datastore name
  • folder_path – path of folder to create
  • datacenter – datacenter of target datastore
create_flat_extent_virtual_disk_descriptor(dc_ref, path, size_in_kb, adapter_type, disk_type)

Create descriptor for a single flat extent virtual disk.

To create the descriptor, we create a virtual disk and delete its flat extent.

Parameters:
  • dc_ref – reference to the datacenter
  • path – descriptor datastore file path
  • size_in_kb – size of the virtual disk in KB
  • adapter_type – virtual disk adapter type
  • disk_type – type of the virtual disk
create_folder(parent_folder, child_folder_name)

Creates child folder with given name under the given parent folder.

The method first checks if a child folder already exists, if it does, then it returns a moref for the folder, else it creates one and then return the moref.

Parameters:
  • parent_folder – Reference to the folder entity
  • child_folder_name – Name of the child folder
Returns:

Reference to the child folder with input name if it already exists, else create one and return the reference

create_snapshot(backing, name, description, quiesce=False)

Create snapshot of the backing with given name and description.

Parameters:
  • backing – Reference to the backing entity
  • name – Snapshot name
  • description – Snapshot description
  • quiesce – Whether to quiesce the backing when taking snapshot
Returns:

Created snapshot entity reference

create_virtual_disk(dc_ref, vmdk_ds_file_path, size_in_kb, adapter_type='busLogic', disk_type='preallocated')

Create virtual disk with the given settings.

Parameters:
  • dc_ref – datacenter reference
  • vmdk_ds_file_path – datastore file path of the virtual disk
  • size_in_kb – disk size in KB
  • adapter_type – disk adapter type
  • disk_type – vmdk type
create_vm_inventory_folder(datacenter, path_comp)

Create and return a VM inventory folder.

This method caches references to inventory folders returned.

Parameters:
  • datacenter – Reference to datacenter
  • path_comp – Path components as a list
delete_backing(backing)

Delete the backing.

Parameters:backing – Managed object reference to the backing
delete_file(file_path, datacenter=None)

Delete file or folder on the datastore.

Parameters:file_path – Datastore path of the file or folder
delete_snapshot(backing, name)

Delete a given snapshot from volume backing.

Parameters:
  • backing – Reference to the backing entity
  • name – Snapshot name
delete_vmdk_file(vmdk_file_path, dc_ref)

Delete given vmdk files.

Parameters:
  • vmdk_file_path – VMDK file path to be deleted
  • dc_ref – Reference to datacenter that contains this VMDK file
detach_disk_from_backing(backing, disk_device)

Detach the given disk from backing.

extend_virtual_disk(requested_size_in_gb, path, dc_ref, eager_zero=False)

Extend the virtual disk to the requested size.

Parameters:
  • requested_size_in_gb – Size of the volume in GB
  • path – Datastore path of the virtual disk to extend
  • dc_ref – Reference to datacenter
  • eager_zero – Boolean determining if the free space is zeroed out
get_backing(name)

Get the backing based on name.

Parameters:name – Name of the backing
Returns:Managed object reference to the backing
get_cluster_hosts(cluster)

Get hosts in the given cluster.

Parameters:cluster – cluster reference
Returns:references to hosts in the cluster
get_cluster_refs(names)

Get references to given clusters.

Parameters:names – list of cluster names
Returns:Dictionary of cluster names to references
get_connected_hosts(datastore)

Get all the hosts to which the datastore is connected and usable.

The datastore is considered to be usable for a host only if it is writable, mounted and accessible.

Parameters:datastore – Reference to the datastore entity
Returns:List of managed object references of all connected hosts
get_create_spec(name, size_kb, disk_type, ds_name, profile_id=None, adapter_type='lsiLogic', extra_config=None)

Return spec for creating backing with a single disk.

Parameters:
  • name – name of the backing
  • size_kb – disk size in KB
  • disk_type – disk provisioning type
  • ds_name – datastore name where the disk is to be provisioned
  • profile_id – storage policy profile identification
  • adapter_type – disk adapter type
  • extra_config – key-value pairs to be written to backing’s extra-config
Returns:

spec for creation

get_datastore(backing)

Get datastore where the backing resides.

Parameters:backing – Reference to the backing
Returns:Datastore reference to which the backing belongs
get_dc(child)

Get parent datacenter up the hierarchy via ‘parent’ property.

Parameters:child – Reference of the child entity
Returns:Parent Datacenter of the param child entity
get_disk_device(vm, vmdk_path)

Get the disk device of the VM which corresponds to the given path.

Parameters:
  • vm – VM reference
  • vmdk_path – Datastore path of virtual disk
Returns:

Matching disk device

get_disk_size(backing)

Get disk size of the backing.

Parameters:backing – backing VM reference
Returns:disk size in bytes
get_entity_by_inventory_path(path)

Returns the managed object identified by the given inventory path.

Parameters:path – Inventory path
Returns:Reference to the managed object
get_entity_name(entity)

Get name of the managed entity.

Parameters:entity – Reference to the entity
Returns:Name of the managed entity
get_host(instance)

Get host under which instance is present.

Parameters:instance – Managed object reference of the instance VM
Returns:Host managing the instance VM
get_hosts()

Get all host from the inventory.

Returns:All the hosts from the inventory
get_path_name(backing)

Get path name of the backing.

Parameters:backing – Reference to the backing entity
Returns:Path name of the backing
get_profile(backing)

Query storage profile associated with the given backing.

Parameters:backing – backing reference
Returns:profile name
get_snapshot(backing, name)

Get snapshot of the backing with given name.

Parameters:
  • backing – Reference to the backing entity
  • name – Snapshot name
Returns:

Snapshot entity of the backing with given name

get_summary(datastore)

Get datastore summary.

Parameters:datastore – Reference to the datastore
Returns:‘summary’ property of the datastore
get_vmdk_path(backing)

Get the vmdk file name of the backing.

The vmdk file path of the backing returned is of the form: “[datastore1] my_folder/my_vm.vmdk”

Parameters:backing – Reference to the backing
Returns:VMDK file path of the backing
get_vmfolder(datacenter)

Get the vmFolder.

Parameters:datacenter – Reference to the datacenter entity
Returns:vmFolder property of the datacenter
is_datastore_accessible(datastore, host)

Check if the datastore is accessible to the given host.

Parameters:datastore – datastore reference
Returns:True if the datastore is accessible
is_host_usable(host)

Check if the given ESX host is usable.

A host is usable if it is connected to vCenter server and not in maintenance mode.

Parameters:host – Managed object reference to the ESX host
Returns:True if host is usable, False otherwise
move_backing_to_folder(backing, folder)

Move the volume backing to the folder.

Parameters:
  • backing – Reference to the backing
  • folder – Reference to the folder
move_vmdk_file(src_dc_ref, src_vmdk_file_path, dest_vmdk_file_path, dest_dc_ref=None)

Move the given vmdk file to another datastore location.

Parameters:
  • src_dc_ref – Reference to datacenter containing src datastore
  • src_vmdk_file_path – Source vmdk file path
  • dest_vmdk_file_path – Destination vmdk file path
  • dest_dc_ref – Reference to datacenter of dest datastore. If unspecified, source datacenter is used.
relocate_backing(backing, datastore, resource_pool, host, disk_type=None)

Relocates backing to the input datastore and resource pool.

The implementation uses moveAllDiskBackingsAndAllowSharing disk move type.

Parameters:
  • backing – Reference to the backing
  • datastore – Reference to the datastore
  • resource_pool – Reference to the resource pool
  • host – Reference to the host
  • disk_type – destination disk type
rename_backing(backing, new_name)

Rename backing VM.

Parameters:
  • backing – VM to be renamed
  • new_name – new VM name
snapshot_exists(backing)

Check if the given backing contains snapshots.

update_backing_disk_uuid(backing, disk_uuid)

Update backing VM’s disk UUID.

Parameters:
  • backing – Reference to backing VM
  • disk_uuid – New disk UUID
update_backing_extra_config(backing, extra_config)
class VirtualDiskAdapterType

Bases: object

Supported virtual disk adapter types.

BUS_LOGIC = 'busLogic'
IDE = 'ide'
LSI_LOGIC = 'lsiLogic'
LSI_LOGIC_SAS = 'lsiLogicsas'
PARA_VIRTUAL = 'paraVirtual'
static get_adapter_type(extra_spec_adapter)

Get the adapter type to be used in VirtualDiskSpec.

Parameters:extra_spec_adapter – adapter type in the extra_spec
Returns:adapter type to be used in VirtualDiskSpec
static is_valid(adapter_type)

Check if the given adapter type is valid.

Parameters:adapter_type – adapter type to check
Returns:True if valid
static validate(extra_spec_adapter_type)

Validate the given adapter type in extra_spec.

This method throws an instance of InvalidAdapterTypeException if the given adapter type is invalid.

Parameters:extra_spec_adapter_type – adapter type in extra_spec
Raises:InvalidAdapterTypeException
class VirtualDiskPath(ds_name, folder_path, disk_name)

Bases: object

Class representing paths of files comprising a virtual disk.

get_datastore_file_path(ds_name, file_path)

Get datastore path corresponding to the given file path.

Parameters:
  • ds_name – name of the datastore containing the file represented by the given file path
  • file_path – absolute path of the file
Returns:

datastore file path

get_descriptor_ds_file_path()

Get datastore file path of the virtual disk descriptor.

get_descriptor_file_path()

Get absolute file path of the virtual disk descriptor.

class VirtualDiskType

Bases: object

Supported virtual disk types.

EAGER_ZEROED_THICK = 'eagerZeroedThick'
EXTRA_SPEC_DISK_TYPE_DICT = {'thick': 'preallocated', 'eagerZeroedThick': 'eagerZeroedThick', 'thin': 'thin'}
PREALLOCATED = 'preallocated'
THIN = 'thin'
static get_virtual_disk_type(extra_spec_disk_type)

Return disk type corresponding to the extra_spec disk type.

Parameters:extra_spec_disk_type – disk type in extra_spec
Returns:virtual disk type
Raises:InvalidDiskTypeException
static is_valid(extra_spec_disk_type)

Check if the given disk type in extra_spec is valid.

Parameters:extra_spec_disk_type – disk type in extra_spec
Returns:True if valid
static validate(extra_spec_disk_type)

Validate the given disk type in extra_spec.

This method throws an instance of InvalidDiskTypeException if the given disk type is invalid.

Parameters:extra_spec_disk_type – disk type in extra_spec
Raises:InvalidDiskTypeException
split_datastore_path(datastore_path)

Split the datastore path to components.

return the datastore name, relative folder path and the file name

E.g. datastore_path = [datastore1] my_volume/my_volume.vmdk, returns (datastore1, my_volume/, my_volume.vmdk)

Parameters:datastore_path – Datastore path of a file
Returns:Parsed datastore name, relative folder path and file name

Previous topic

The cinder.volume.drivers.vmware.vmdk Module

Next topic

The cinder.volume.drivers.vzstorage Module

Project Source

This Page