The cinder.volume.drivers.rbd Module

The cinder.volume.drivers.rbd Module

RADOS Block Device Driver

class RADOSClient(driver, pool=None)

Bases: object

Context manager to simplify error handling for connecting to ceph.

features
class RBDDriver(active_backend_id=None, *args, **kwargs)

Bases: cinder.volume.driver.CloneableImageVD, cinder.volume.driver.MigrateVD, cinder.volume.driver.ManageableVD, cinder.volume.driver.BaseVD

Implements RADOS block device (RBD) volume commands.

CI_WIKI_NAME = 'Cinder_Jenkins'
RBDProxy()
SYSCONFDIR = '/etc/ceph/'
VERSION = '1.2.0'
check_for_setup_error()

Returns an error if prerequisites aren’t met.

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_encrypted_volume(context, volume, image_service, image_id)

Fetch image from image_service and write to encrypted volume.

This attaches the encryptor layer when connecting to the volume.

copy_image_to_volume(context, volume, image_service, image_id)

Fetch image from image_service and write to unencrypted volume.

This does not attach an encryptor layer when connecting 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)

Create a cloned volume from another volume.

Since we are cloning from a volume and not a snapshot, we must first create a snapshot of the source volume.

The user has the option to limit how long a volume’s clone chain can be by setting rbd_max_clone_depth. If a clone is made of another clone and that clone has rbd_max_clone_depth clones behind it, the dest volume will be flattened.

create_export(context, volume, connector)

Exports the volume.

create_snapshot(snapshot)

Creates an rbd snapshot.

create_volume(volume)

Creates a logical volume.

create_volume_from_snapshot(volume, snapshot)

Creates a volume from a snapshot.

delete_snapshot(snapshot)

Deletes an rbd snapshot.

delete_volume(volume)

Deletes a logical volume.

do_setup(context)

Performs initialization steps that could raise exceptions.

ensure_export(context, volume)

Synchronously recreates an export for a logical volume.

extend_volume(volume, new_size)

Extend an existing volume.

failover_host(context, volumes, secondary_id=None, groups=None)

Failover to replication target.

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_volume_stats(refresh=False)

Return the current state of the volume service.

If ‘refresh’ is True, run the update 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.

manage_existing(volume, existing_ref)

Manages an existing image.

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

Parameters:
  • volume – volume ref info to be set
  • existing_ref – existing_ref is a dictionary of the form: {‘source-name’: <name of rbd image>}
manage_existing_get_size(volume, existing_ref)

Return size of an existing image for manage_existing.

Parameters:
  • volume – volume ref info to be set
  • existing_ref – existing_ref is a dictionary of the form: {‘source-name’: <name of rbd image>}
manage_existing_snapshot(snapshot, existing_ref)

Manages an existing snapshot.

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

Parameters:
  • snapshot – snapshot ref info to be set
  • existing_ref – existing_ref is a dictionary of the form: {‘source-name’: <name of rbd snapshot>}
manage_existing_snapshot_get_size(snapshot, existing_ref)

Return size of an existing image for manage_existing.

Parameters:
  • snapshot – snapshot ref info to be set
  • existing_ref – existing_ref is a dictionary of the form: {‘source-name’: <name of snapshot>}
migrate_volume(context, volume, host)

Migrate the volume to the specified host.

Returns a boolean indicating whether the migration occurred, as well as model_update.

Parameters:
  • context – Context
  • volume – A dictionary describing the volume to migrate
  • 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.
remove_export(context, volume)

Removes an export for a logical volume.

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

Retype from one volume type to another on the same backend.

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.
unmanage(volume)

Removes the specified volume from Cinder management.

Does not delete the underlying backend storage object.

For most drivers, this will not need to do anything. However, some drivers might use this call as an opportunity to clean up any Cinder-specific configuration that they have associated with the backend storage object.

Parameters:volume – Cinder volume to unmanage
update_migrated_volume(ctxt, volume, new_volume, original_volume_status)

Return model update from RBD 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

class RBDVolumeProxy(driver, name, pool=None, snapshot=None, read_only=False, remote=None, timeout=None, client=None, ioctx=None)

Bases: object

Context manager for dealing with an existing rbd volume.

This handles connecting to rados and opening an ioctx automatically, and otherwise acts like a librbd Image object.

Also this may reuse an external connection (client and ioctx args), but note, that caller will be responsible for opening/closing connection. Also pool, remote, timeout args will be ignored in that case.

The underlying librados client and ioctx can be accessed as the attributes ‘client’ and ‘ioctx’.

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.