The cinder.volume.drivers.vmware.volumeops Module

Implements operations on volumes residing on VMware datastores.

class VMwareVolumeOps(session, max_objects)

Bases: object

Manages volume operations.

cancel_retrieval(retrieve_result)

Cancel retrieval of results if necessary.

Parameters:retrieve_result – Result from RetrievePropertiesEx
clone_backing(name, backing, snapshot, clone_type, datastore)

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
continue_retrieval(retrieve_result)

Continue retrieval of results if necessary.

Parameters:retrieve_result – Result from RetrievePropertiesEx
copy_vmdk_file(dc_ref, src_vmdk_file_path, dest_vmdk_file_path)

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

During the copy also coalesce snapshots of src if present. dest_vmdk_file_path will be created if not already present.

Parameters:
  • dc_ref – Reference to datacenter containing src and dest
  • src_vmdk_file_path – Source vmdk file path
  • dest_vmdk_file_path – Destination vmdk file path
create_backing(name, size_kb, disk_type, folder, resource_pool, host, ds_name, profileId=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
Returns:

Reference to the created backing entity

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

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
extend_virtual_disk(requested_size_in_gb, name, dc_ref, eager_zero=False)

Extend the virtual disk to the requested size.

Parameters:
  • requested_size_in_gb – Size of the volume in GB
  • name – Name of the backing
  • dc_ref – Reference datacenter
  • eager_zero – Boolean determining if the free space

is zeroed out

filter_matching_hubs(hubs, profile_id)

Filter and return only hubs that match given profile.

Parameters:
  • hubs – PbmPlacementHub morefs candidates
  • profile_id – profile id string
Returns:

subset of hubs that match given profile_id

get_all_profiles()

Get all profiles defined in current VC.

Returns:PbmProfile data objects from VC
get_backing(name)

Get the backing based on name.

Parameters:name – Name of the backing
Returns:Managed object reference to the backing
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_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_dss_rp(host)

Get accessible datastores and resource pool of the host.

Parameters:host – Managed object reference of the host
Returns:Datastores accessible to the host and resource pool to which the host belongs to
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_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
move_backing_to_folder(backing, folder)

Move the volume backing to the folder.

Parameters:
  • backing – Reference to the backing
  • folder – Reference to the folder
relocate_backing(backing, datastore, resource_pool, host)

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
retrieve_profile_id(profile_name)

Get the profile uuid from current VC for given profile name.

Parameters:profile_name – profile name as string
Returns:profile id as string
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.vmware_images Module

Next topic

The cinder.volume.drivers.windows.windows Module

This Page