The cinder.volume.drivers.vmware.vmdk Module

Volume driver for VMware vCenter/ESX managed datastores.

The volumes created by this driver are backed by VMDK (Virtual Machine Disk) files stored in datastores. For ease of managing the VMDKs, the driver creates a virtual machine for each of the volumes. This virtual machine is never powered on and is often referred as the shadow VM.

class ImageDiskType

Bases: object

Supported disk types in images.

PREALLOCATED = 'preallocated'
SPARSE = 'sparse'
STREAM_OPTIMIZED = 'streamOptimized'
THIN = 'thin'
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 to check
Returns:True if valid
static validate(extra_spec_disk_type)

Validate the given disk type in extra_spec.

This method throws ImageUnacceptable if the disk type is not a supported one.

Parameters:extra_spec_disk_type – disk type
Raises:ImageUnacceptable
class VMwareEsxVmdkDriver(*args, **kwargs)

Bases: cinder.volume.driver.VolumeDriver

Manage volumes on VMware ESX server.

VERSION = '1.5.0'
backup_volume(context, backup, backup_service)

Create a new backup from an existing volume.

check_for_setup_error()
copy_image_to_volume(context, volume, image_service, image_id)

Creates volume from image.

This method only supports Glance image of VMDK disk format. Uses flat vmdk file copy for “sparse” and “preallocated” disk types Uses HttpNfc import API for “streamOptimized” disk types. This API creates a backing VM that wraps the VMDK in the ESX/vCenter inventory.

Parameters:
  • context – context
  • volume – Volume object
  • image_service – Glance image service
  • image_id – Glance image id
copy_volume_to_image(context, volume, image_service, image_meta)

Creates glance image from volume.

Upload of only available volume is supported. The uploaded glance image has a vmdk disk type of “streamOptimized” that can only be downloaded using the HttpNfc API. Steps followed are: 1. Get the name of the vmdk file which the volume points to right now.

Can be a chain of snapshots, so we need to know the last in the chain.
  1. Use Nfc APIs to upload the contents of the vmdk file to glance.
create_cloned_volume(volume, src_vref)

Creates volume clone.

Parameters:
  • volume – New Volume object
  • src_vref – Volume object that must be cloned
create_export(context, volume, connector)
create_snapshot(snapshot)

Creates a snapshot.

Parameters:snapshot – Snapshot object
create_volume(volume)

Creates a volume.

We do not create any backing. We do it only the first time it is being attached to a virtual machine.

Parameters:volume – Volume object
create_volume_from_snapshot(volume, snapshot)

Creates a volume from a snapshot.

Parameters:
  • volume – Volume object
  • snapshot – Snapshot object
delete_snapshot(snapshot)

Delete snapshot.

Parameters:snapshot – Snapshot object
delete_volume(volume)

Deletes volume backing.

Parameters:volume – Volume object
do_setup(context)

Perform validations and establish connection to server.

Parameters:context – Context information
ds_sel
ensure_export(context, volume)
extend_volume(volume, new_size)

Extend vmdk to new_size.

Extends the vmdk backing to new volume size. First try to extend in place on the same datastore. If that fails, try to relocate the volume to a different datastore that can accommodate the new_size’d volume.

Parameters:
  • volume – dictionary describing the existing ‘available’ volume
  • new_size – new size in GB to extend this volume to
get_volume_stats(refresh=False)

Obtain status of the volume service.

Parameters:refresh – Whether to get refreshed information
initialize_connection(volume, connector)

Allow connection to connector and return connection info.

The implementation returns the following information: {‘driver_volume_type’: ‘vmdk’

‘data’: {‘volume’: $VOLUME_MOREF_VALUE
‘volume_id’: $VOLUME_ID

}

}

Parameters:
  • volume – Volume object
  • connector – Connector information
Returns:

Return connection information

remove_export(context, volume)
restore_backup(context, backup, volume, backup_service)

Restore an existing backup to a new or existing volume.

This method raises InvalidVolume if the existing volume contains snapshots since it is not possible to restore the virtual disk of a backing with snapshots.

retype(ctxt, volume, new_type, diff, host)

Convert the volume to be of the new type.

The retype is performed only if the volume is not in use. Retype is NOP if the backing doesn’t exist. If disk type conversion is needed, the volume is cloned. If disk type conversion is needed and the volume contains snapshots, the backing is relocated instead of cloning. The backing is also relocated if the current datastore is not compliant with the new storage profile (if any). Finally, the storage profile of the backing VM is updated.

Parameters:
  • ctxt – Context
  • volume – A dictionary describing the volume to retype
  • new_type – A dictionary describing the volume type to convert to
  • diff – A dictionary with the difference between the two types
  • host – A dictionary describing the host to migrate to, where host[‘host’] is its name, and host[‘capabilities’] is a dictionary of its reported capabilities (unused)
Returns:

True if the retype occurred; False otherwise.

session
terminate_connection(volume, connector, force=False, **kwargs)
volumeops
class VMwareVcVmdkDriver(*args, **kwargs)

Bases: cinder.volume.drivers.vmware.vmdk.VMwareEsxVmdkDriver

Manage volumes on VMware vCenter server.

MIN_SUPPORTED_VC_VERSION = LooseVersion ('5.1')
PBM_ENABLED_VC_VERSION = LooseVersion ('5.5')
create_cloned_volume(volume, src_vref)

Creates volume clone.

Parameters:
  • volume – New Volume object
  • src_vref – Source Volume object
create_volume_from_snapshot(volume, snapshot)

Creates a volume from a snapshot.

Parameters:
  • volume – New Volume object
  • snapshot – Reference to snapshot entity
do_setup(context)

Any initialization the volume driver does while starting.

session

Previous topic

The cinder.volume.drivers.vmware.exceptions Module

Next topic

The cinder.volume.drivers.vmware.volumeops Module

Project Source

This Page