The cinder.volume.drivers.lvm Module

The cinder.volume.drivers.lvm Module

Driver for Linux servers running LVM.

class LVMVolumeDriver(vg_obj=None, *args, **kwargs)

Bases: cinder.volume.driver.VolumeDriver

Executes commands relating to Volumes.

CI_WIKI_NAME = 'Cinder_Jenkins'
VERSION = '3.0.0'
check_for_setup_error()

Verify that requirements are in place to use LVM driver.

clone_image(context, volume, image_location, image_meta, image_service)

Create a volume efficiently from an existing image.

image_location is a string whose format depends on the image service backend in use. The driver should use it to determine whether cloning is possible.

image_id is a string which represents id of the image. It can be used by the driver to introspect internal stores or registry to do an efficient image clone.

image_meta is a dictionary that includes ‘disk_format’ (e.g. raw, qcow2) and other image attributes that allow drivers to decide whether they can clone the image without first requiring conversion.

image_service is the reference of the image_service to use. Note that this is needed to be passed here for drivers that will want to fetch images from the image service directly.

Returns a dict of volume properties eg. provider_location, boolean indicating whether cloning occurred

copy_image_to_volume(context, volume, image_service, image_id)

Fetch the image from image_service and write it to the volume.

copy_volume_to_image(context, volume, image_service, image_meta)

Copy the volume to the specified image.

create_cloned_volume(volume, src_vref)

Creates a clone of the specified volume.

create_export(context, volume, connector, vg=None)

Exports the volume.

Can optionally return a Dictionary of changes to the volume object to be persisted.

create_snapshot(snapshot)

Creates a snapshot.

create_volume(volume)

Creates a logical volume.

create_volume_from_snapshot(volume, snapshot)

Creates a volume from a snapshot.

delete_snapshot(snapshot)

Deletes a snapshot.

delete_volume(volume)

Deletes a logical volume.

ensure_export(context, volume)

Synchronously recreates an export for a volume.

extend_volume(volume, new_size)

Extend an existing volume’s size.

get_manageable_snapshots(cinder_snapshots, marker, limit, offset, sort_keys, sort_dirs)

List snapshots on the backend available for management by Cinder.

Returns a list of dictionaries, each specifying a snapshot in the host, with the following keys: - reference (dictionary): The reference for a snapshot, which can be passed to “manage_existing_snapshot”. - size (int): The size of the snapshot according to the storage backend, rounded up to the nearest GB. - safe_to_manage (boolean): Whether or not this snapshot is safe to manage according to the storage backend. For example, is the snapshot in use or invalid for any reason. - reason_not_safe (string): If safe_to_manage is False, the reason why. - cinder_id (string): If already managed, provide the Cinder ID. - extra_info (string): Any extra information to return to the user - source_reference (string): Similar to “reference”, but for the snapshot’s source volume.

Parameters:
  • cinder_snapshots – A list of snapshots in this host that Cinder currently manages, used to determine if a snapshot is manageable or not.
  • marker – The last item of the previous page; we return the next results after this value (after sorting)
  • limit – Maximum number of items to return
  • offset – Number of items to skip after marker
  • sort_keys – List of keys to sort results by (valid keys are ‘identifier’ and ‘size’)
  • sort_dirs – List of directions to sort by, corresponding to sort_keys (valid directions are ‘asc’ and ‘desc’)
get_manageable_volumes(cinder_volumes, marker, limit, offset, sort_keys, sort_dirs)

List volumes on the backend available for management by Cinder.

Returns a list of dictionaries, each specifying a volume in the host, with the following keys: - reference (dictionary): The reference for a volume, which can be passed to “manage_existing”. - size (int): The size of the volume according to the storage backend, rounded up to the nearest GB. - safe_to_manage (boolean): Whether or not this volume is safe to manage according to the storage backend. For example, is the volume in use or invalid for any reason. - reason_not_safe (string): If safe_to_manage is False, the reason why. - cinder_id (string): If already managed, provide the Cinder ID. - extra_info (string): Any extra information to return to the user

Parameters:
  • cinder_volumes – A list of volumes in this host that Cinder currently manages, used to determine if a volume is manageable or not.
  • marker – The last item of the previous page; we return the next results after this value (after sorting)
  • limit – Maximum number of items to return
  • offset – Number of items to skip after marker
  • sort_keys – List of keys to sort results by (valid keys are ‘identifier’ and ‘size’)
  • sort_dirs – List of directions to sort by, corresponding to sort_keys (valid directions are ‘asc’ and ‘desc’)
get_pool(volume)

Return pool name where volume reside on.

Parameters:volume – The volume hosted by the driver.
Returns:name of the pool where given volume is in.
get_volume_stats(refresh=False)

Get volume status.

If ‘refresh’ is True, run update the stats first.

initialize_connection(volume, connector)

Allow connection to connector and return connection info.

Parameters:
  • volume – The volume to be attached
  • connector – Dictionary containing information about what is being connected to.
Returns conn_info:
 

A dictionary of connection information.

local_path(volume, vg=None)
manage_existing(volume, existing_ref)

Manages an existing LV.

Renames the LV to match the expected name for the volume. Error checking done by manage_existing_get_size is not repeated.

manage_existing_get_size(volume, existing_ref)

Return size of volume to be managed by manage_existing.

When calculating the size, round up to the next GB.

Parameters:
  • volume – Cinder volume to manage
  • existing_ref – Driver-specific information used to identify a volume
Returns size:

Volume size in GiB (integer)

manage_existing_object_get_size(existing_object, existing_ref, object_type)

Return size of an existing LV for manage existing volume/snapshot.

existing_ref is a dictionary of the form: {‘source-name’: <name of LV>}

manage_existing_snapshot(snapshot, existing_ref)

Brings an existing backend storage object under Cinder management.

existing_ref is passed straight through from the API request’s manage_existing_ref value, and it is up to the driver how this should be interpreted. It should be sufficient to identify a storage object that the driver should somehow associate with the newly-created cinder snapshot structure.

There are two ways to do this:

  1. Rename the backend storage object so that it matches the snapshot[‘name’] which is how drivers traditionally map between a cinder snapshot and the associated backend storage object.
  2. Place some metadata on the snapshot, or somewhere in the backend, that allows other driver requests (e.g. delete) to locate the backend storage object when required.

If the existing_ref doesn’t make sense, or doesn’t refer to an existing backend storage object, raise a ManageExistingInvalidReference exception.

Parameters:
  • snapshot – Cinder volume snapshot to manage
  • existing_ref – Driver-specific information used to identify a volume snapshot
manage_existing_snapshot_get_size(snapshot, existing_ref)

Return size of snapshot to be managed by manage_existing.

When calculating the size, round up to the next GB.

Parameters:
  • snapshot – Cinder volume snapshot to manage
  • existing_ref – Driver-specific information used to identify a volume snapshot
Returns size:

Volume snapshot size in GiB (integer)

migrate_volume(ctxt, volume, host, thin=False, mirror_count=0)

Optimize the migration if the destination is on the same server.

If the specified host is another back-end on the same server, and the volume is not attached, we can do the migration locally without going through iSCSI.

remove_export(context, volume)

Removes an export for a volume.

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

Retypes a volume, allow QoS and extra_specs change.

revert_to_snapshot(context, volume, snapshot)

Revert a volume to a snapshot

terminate_connection(volume, connector, **kwargs)

Disallow connection from connector

Parameters:
  • volume – The volume to be disconnected.
  • connector – A dictionary describing the connection with details about the initiator. Can be None.
update_migrated_volume(ctxt, volume, new_volume, original_volume_status)

Return model update from LVM for migrated volume.

This method should rename the back-end volume name(id) on the destination host back to its original name(id) on the source host.

Parameters:
  • ctxt – The context used to run the method update_migrated_volume
  • volume – The original volume that was migrated to this backend
  • new_volume – The migration volume object that was created on this backend as part of the migration process
  • original_volume_status – The status of the original volume
Returns:

model_update to update DB with any needed changes

validate_connector(connector)

Fail if connector doesn’t contain all the data needed by driver.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.