Common and Misc Libraries

Libraries common throughout Cinder or just ones that haven’t been categorized very well yet.

The cinder.adminclient Module

The cinder.context Module

RequestContext: context for requests that persist through all of cinder.

class RequestContext(user_id, project_id, is_admin=None, read_deleted='no', roles=None, project_name=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, service_catalog=None, **kwargs)

Bases: object

Security context and request information.

Represents the user taking a given action within the system.

RequestContext.deepcopy()
RequestContext.elevated(read_deleted=None, overwrite=False)

Return a version of this context with admin flag set.

classmethod RequestContext.from_dict(values)
RequestContext.read_deleted
RequestContext.tenant
RequestContext.to_dict()
RequestContext.update_store()
RequestContext.user
generate_request_id()
get_admin_context(read_deleted='no')

The cinder.exception Module

Cinder base exception handling.

Includes decorator for re-raising Cinder-type exceptions.

SHOULD include dedicated exception logging.

exception AdminRequired(message=None, **kwargs)

Bases: cinder.exception.NotAuthorized

AdminRequired.message = 'User does not have admin privileges'
exception BackupFailedToGetVolumeBackend(message=None, **kwargs)

Bases: cinder.exception.NotFound

BackupFailedToGetVolumeBackend.message = 'Failed to identify volume backend.'
exception BackupInvalidCephArgs(message=None, **kwargs)

Bases: cinder.exception.Invalid

BackupInvalidCephArgs.message = 'Invalid Ceph args provided for backup rbd operation'
exception BackupNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

BackupNotFound.message = 'Backup %(backup_id)s could not be found.'
exception BackupOperationError(message=None, **kwargs)

Bases: cinder.exception.Invalid

BackupOperationError.message = 'An error has occurred during backup operation'
exception BackupRBDOperationFailed(message=None, **kwargs)

Bases: cinder.exception.Invalid

BackupRBDOperationFailed.message = 'Backup RBD operation failed'
exception BadHTTPResponseStatus(message=None, **kwargs)

Bases: cinder.exception.CinderException

BadHTTPResponseStatus.message = 'Bad HTTP response status %(status)s'
exception CinderException(message=None, **kwargs)

Bases: exceptions.Exception

Base Cinder Exception

To correctly use this class, inherit from it and define a ‘message’ property. That message will get printf’d with the keyword arguments provided to the constructor.

CinderException.code = 500
CinderException.headers = {}
CinderException.message = 'An unknown exception occurred.'
CinderException.safe = False
exception ConfigNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ConfigNotFound.message = 'Could not find config at %(path)s'
exception ConvertedException(code=0, title='', explanation='')

Bases: webob.exc.WSGIHTTPException

exception CoraidESMBadCredentials(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidESMBadCredentials.message = 'Login on ESM failed.'
exception CoraidESMBadGroup(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidESMBadGroup.message = 'Group with name "%(group_name)s" not found.'
exception CoraidESMConfigureError(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidESMConfigureError.message = 'ESM configure request failed: %(message)s.'
exception CoraidESMNotAvailable(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidESMNotAvailable.message = 'Coraid ESM not available with reason: %(reason)s.'
exception CoraidESMReloginFailed(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidESMReloginFailed.message = 'Relogin on ESM failed.'
exception CoraidException(message=None, **kwargs)

Bases: cinder.exception.CinderException

CoraidException.message = 'Coraid Cinder Driver exception.'
exception CoraidJsonEncodeFailure(message=None, **kwargs)

Bases: cinder.exception.CoraidException

CoraidJsonEncodeFailure.message = 'Failed to encode json data.'
exception DeviceUnavailable(message=None, **kwargs)

Bases: cinder.exception.Invalid

DeviceUnavailable.message = 'The device in the path %(path)s is unavailable: %(reason)s'
exception DriverNotInitialized(message=None, **kwargs)

Bases: cinder.exception.CinderException

DriverNotInitialized.message = "Volume driver '%(driver)s' not initialized."
exception Duplicate(message=None, **kwargs)

Bases: cinder.exception.CinderException

exception DuplicateSfVolumeNames(message=None, **kwargs)

Bases: cinder.exception.Duplicate

DuplicateSfVolumeNames.message = 'Detected more than one volume with name %(vol_name)s'
exception Error

Bases: exceptions.Exception

exception ExportFailure(message=None, **kwargs)

Bases: cinder.exception.Invalid

ExportFailure.message = 'Failed to export for volume: %(reason)s'
exception FailedCmdWithDump(message=None, **kwargs)

Bases: cinder.exception.CinderException

FailedCmdWithDump.message = 'Operation failed with status=%(status)s. Full dump: %(data)s'
exception FileNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

FileNotFound.message = 'File %(file_path)s could not be found.'
exception GlanceConnectionFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

GlanceConnectionFailed.message = 'Connection to glance failed: %(reason)s'
exception GlanceMetadataExists(message=None, **kwargs)

Bases: cinder.exception.Invalid

GlanceMetadataExists.message = 'Glance metadata cannot be updated, key %(key)s exists for volume id %(volume_id)s'
exception GlanceMetadataNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

GlanceMetadataNotFound.message = 'Glance metadata for volume/snapshot %(id)s cannot be found.'
exception GlusterfsException(message=None, **kwargs)

Bases: cinder.exception.CinderException

GlusterfsException.message = 'Unknown Gluster exception'
exception GlusterfsNoSharesMounted(message=None, **kwargs)

Bases: cinder.exception.NotFound

GlusterfsNoSharesMounted.message = 'No mounted Gluster shares found'
exception GlusterfsNoSuitableShareFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

GlusterfsNoSuitableShareFound.message = 'There is no share which can host %(volume_size)sG'
exception HostBinaryNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

HostBinaryNotFound.message = 'Could not find binary %(binary)s on host %(host)s.'
exception HostNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

HostNotFound.message = 'Host %(host)s could not be found.'
exception ISCSITargetNotFoundForVolume(message=None, **kwargs)

Bases: cinder.exception.NotFound

ISCSITargetNotFoundForVolume.message = 'No target id found for volume %(volume_id)s.'
exception ImageCopyFailure(message=None, **kwargs)

Bases: cinder.exception.Invalid

ImageCopyFailure.message = 'Failed to copy image to volume: %(reason)s'
exception ImageNotAuthorized(message=None, **kwargs)

Bases: cinder.exception.CinderException

ImageNotAuthorized.message = 'Not authorized for image %(image_id)s.'
exception ImageNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ImageNotFound.message = 'Image %(image_id)s could not be found.'
exception ImageUnacceptable(message=None, **kwargs)

Bases: cinder.exception.Invalid

ImageUnacceptable.message = 'Image %(image_id)s is unacceptable: %(reason)s'
exception InstanceNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

InstanceNotFound.message = 'Instance %(instance_id)s could not be found.'
exception Invalid(message=None, **kwargs)

Bases: cinder.exception.CinderException

Invalid.code = 400
Invalid.message = 'Unacceptable parameters.'
exception Invalid3PARDomain(message=None, **kwargs)

Bases: cinder.exception.CinderException

Invalid3PARDomain.message = 'Invalid 3PAR Domain: %(err)s'
exception InvalidAuthKey(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidAuthKey.message = 'Invalid auth key: %(reason)s'
exception InvalidBackup(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidBackup.message = 'Invalid backup: %(reason)s'
exception InvalidConfigurationValue(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidConfigurationValue.message = 'Value "%(value)s" is not valid for configuration option "%(option)s"'
exception InvalidContentType(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidContentType.message = 'Invalid content type %(content_type)s.'
exception InvalidHost(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidHost.message = 'Invalid host: %(reason)s'
exception InvalidImageRef(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidImageRef.message = 'Invalid image href %(image_href)s.'
exception InvalidInput(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidInput.message = 'Invalid input received: %(reason)s'
exception InvalidParameterValue(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidParameterValue.message = '%(err)s'
exception InvalidQoSSpecs(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidQoSSpecs.message = 'Invalid qos specs: %(reason)s'
exception InvalidQuotaValue(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidQuotaValue.message = 'Change would make usage less than 0 for the following resources: %(unders)s'
exception InvalidReservationExpiration(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidReservationExpiration.message = 'Invalid reservation expiration %(expire)s.'
exception InvalidResults(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidResults.message = 'The results are invalid.'
exception InvalidSnapshot(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidSnapshot.message = 'Invalid snapshot: %(reason)s'
exception InvalidUUID(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidUUID.message = 'Expected a uuid but received %(uuid)s.'
exception InvalidVolume(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidVolume.message = 'Invalid volume: %(reason)s'
exception InvalidVolumeAttachMode(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidVolumeAttachMode.message = "Invalid attaching mode '%(mode)s' for volume %(volume_id)s."
exception InvalidVolumeMetadata(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidVolumeMetadata.message = 'Invalid metadata: %(reason)s'
exception InvalidVolumeMetadataSize(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidVolumeMetadataSize.message = 'Invalid metadata size: %(reason)s'
exception InvalidVolumeType(message=None, **kwargs)

Bases: cinder.exception.Invalid

InvalidVolumeType.message = 'Invalid volume type: %(reason)s'
exception KeyManagerError(message=None, **kwargs)

Bases: cinder.exception.CinderException

KeyManagerError.msg_fmt = 'key manager error: %(reason)s'
exception MalformedRequestBody(message=None, **kwargs)

Bases: cinder.exception.CinderException

MalformedRequestBody.message = 'Malformed message body: %(reason)s'
exception MalformedResponse(message=None, **kwargs)

Bases: cinder.exception.Invalid

MalformedResponse.message = 'Malformed response to command %(cmd)s: %(reason)s'
exception MetadataCopyFailure(message=None, **kwargs)

Bases: cinder.exception.Invalid

MetadataCopyFailure.message = 'Failed to copy metadata to volume: %(reason)s'
exception MetadataCreateFailure(message=None, **kwargs)

Bases: cinder.exception.Invalid

MetadataCreateFailure.message = 'Failed to create metadata for volume: %(reason)s'
exception MetadataUpdateFailure(message=None, **kwargs)

Bases: cinder.exception.Invalid

MetadataUpdateFailure.message = 'Failed to update metadata for volume: %(reason)s'
exception MigrationNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

MigrationNotFound.message = 'Migration %(migration_id)s could not be found.'
exception NfsException(message=None, **kwargs)

Bases: cinder.exception.CinderException

NfsException.message = 'Unknown NFS exception'
exception NfsNoSharesMounted(message=None, **kwargs)

Bases: cinder.exception.NotFound

NfsNoSharesMounted.message = 'No mounted NFS shares found'
exception NfsNoSuitableShareFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

NfsNoSuitableShareFound.message = 'There is no share which can host %(volume_size)sG'
exception NoValidHost(message=None, **kwargs)

Bases: cinder.exception.CinderException

NoValidHost.message = 'No valid host was found. %(reason)s'
exception NotAuthorized(message=None, **kwargs)

Bases: cinder.exception.CinderException

NotAuthorized.code = 403
NotAuthorized.message = 'Not authorized.'
exception NotFound(message=None, **kwargs)

Bases: cinder.exception.CinderException

NotFound.code = 404
NotFound.message = 'Resource could not be found.'
NotFound.safe = True
exception OverQuota(message=None, **kwargs)

Bases: cinder.exception.CinderException

OverQuota.message = 'Quota exceeded for resources: %(overs)s'
exception ParameterNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ParameterNotFound.message = 'Could not find parameter %(param)s'
exception PasteAppNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

PasteAppNotFound.message = "Could not load paste app '%(name)s' from %(path)s"
exception PolicyNotAuthorized(message=None, **kwargs)

Bases: cinder.exception.NotAuthorized

PolicyNotAuthorized.message = "Policy doesn't allow %(action)s to be performed."
exception ProjectQuotaNotFound(message=None, **kwargs)

Bases: cinder.exception.QuotaNotFound

ProjectQuotaNotFound.message = 'Quota for project %(project_id)s could not be found.'
exception QoSSpecsAssociateFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

QoSSpecsAssociateFailed.message = 'Failed to associate qos_specs: %(specs_id)s with type %(type_id)s.'
exception QoSSpecsCreateFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

QoSSpecsCreateFailed.message = 'Failed to create qos_specs: %(name)s with specs %(qos_specs)s.'
exception QoSSpecsDisassociateFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

QoSSpecsDisassociateFailed.message = 'Failed to disassociate qos_specs: %(specs_id)s with type %(type_id)s.'
exception QoSSpecsExists(message=None, **kwargs)

Bases: cinder.exception.Duplicate

QoSSpecsExists.message = 'QoS Specs %(specs_id)s already exists.'
exception QoSSpecsInUse(message=None, **kwargs)

Bases: cinder.exception.CinderException

QoSSpecsInUse.message = 'QoS Specs %(specs_id)s is still associated with entities.'
exception QoSSpecsKeyNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

QoSSpecsKeyNotFound.message = 'QoS spec %(specs_id)s has no spec with key %(specs_key)s.'
exception QoSSpecsNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

QoSSpecsNotFound.message = 'No such QoS spec %(specs_id)s.'
exception QoSSpecsUpdateFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

QoSSpecsUpdateFailed.message = 'Failed to update qos_specs: %(specs_id)s with specs %(qos_specs)s.'
exception QuotaClassNotFound(message=None, **kwargs)

Bases: cinder.exception.QuotaNotFound

QuotaClassNotFound.message = 'Quota class %(class_name)s could not be found.'
exception QuotaError(message=None, **kwargs)

Bases: cinder.exception.CinderException

QuotaError.code = 413
QuotaError.headers = {'Retry-After': 0}
QuotaError.message = 'Quota exceeded: code=%(code)s'
QuotaError.safe = True
exception QuotaNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

QuotaNotFound.message = 'Quota could not be found'
exception QuotaResourceUnknown(message=None, **kwargs)

Bases: cinder.exception.QuotaNotFound

QuotaResourceUnknown.message = 'Unknown quota resources %(unknown)s.'
exception QuotaUsageNotFound(message=None, **kwargs)

Bases: cinder.exception.QuotaNotFound

QuotaUsageNotFound.message = 'Quota usage for project %(project_id)s could not be found.'
exception ReservationNotFound(message=None, **kwargs)

Bases: cinder.exception.QuotaNotFound

ReservationNotFound.message = 'Quota reservation %(uuid)s could not be found.'
exception SSHInjectionThreat(message=None, **kwargs)

Bases: cinder.exception.CinderException

SSHInjectionThreat.message = 'SSH command injection detected: %(command)s'
exception SchedulerHostFilterNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

SchedulerHostFilterNotFound.message = 'Scheduler Host Filter %(filter_name)s could not be found.'
exception SchedulerHostWeigherNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

SchedulerHostWeigherNotFound.message = 'Scheduler Host Weigher %(weigher_name)s could not be found.'
exception ServiceNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ServiceNotFound.message = 'Service %(service_id)s could not be found.'
exception ServiceUnavailable(message=None, **kwargs)

Bases: cinder.exception.Invalid

ServiceUnavailable.message = 'Service is unavailable at this time.'
exception SfAccountNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

SfAccountNotFound.message = 'Unable to locate account %(account_name)s on Solidfire device'
exception SfJsonEncodeFailure(message=None, **kwargs)

Bases: cinder.exception.CinderException

SfJsonEncodeFailure.message = 'Failed to load data into json format'
exception SnapshotIsBusy(message=None, **kwargs)

Bases: cinder.exception.CinderException

SnapshotIsBusy.message = 'deleting snapshot %(snapshot_name)s that has dependent volumes'
exception SnapshotLimitExceeded(message=None, **kwargs)

Bases: cinder.exception.QuotaError

SnapshotLimitExceeded.message = 'Maximum number of snapshots allowed (%(allowed)d) exceeded'
exception SnapshotMetadataNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

SnapshotMetadataNotFound.message = 'Snapshot %(snapshot_id)s has no metadata with key %(metadata_key)s.'
exception SnapshotNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

SnapshotNotFound.message = 'Snapshot %(snapshot_id)s could not be found.'
exception SolidFireAPIDataException(message=None, **kwargs)

Bases: cinder.exception.SolidFireAPIException

SolidFireAPIDataException.message = 'Error in SolidFire API response: data=%(data)s'
exception SolidFireAPIException(message=None, **kwargs)

Bases: cinder.exception.CinderException

SolidFireAPIException.message = 'Bad response from SolidFire API'
exception SwiftConnectionFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

SwiftConnectionFailed.message = 'Connection to swift failed: %(reason)s'
exception TransferNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

TransferNotFound.message = 'Transfer %(transfer_id)s could not be found.'
exception UnknownCmd(message=None, **kwargs)

Bases: cinder.exception.Invalid

UnknownCmd.message = 'Unknown or unsupported command %(cmd)s'
exception VolumeAdminMetadataNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

VolumeAdminMetadataNotFound.message = 'Volume %(volume_id)s has no administration metadata with key %(metadata_key)s.'
exception VolumeAttached(message=None, **kwargs)

Bases: cinder.exception.Invalid

VolumeAttached.message = 'Volume %(volume_id)s is still attached, detach volume first.'
exception VolumeBackendAPIException(message=None, **kwargs)

Bases: cinder.exception.CinderException

VolumeBackendAPIException.message = 'Bad or unexpected response from the storage volume backend API: %(data)s'
exception VolumeIsBusy(message=None, **kwargs)

Bases: cinder.exception.CinderException

VolumeIsBusy.message = 'deleting volume %(volume_name)s that has snapshot'
exception VolumeLimitExceeded(message=None, **kwargs)

Bases: cinder.exception.QuotaError

VolumeLimitExceeded.message = 'Maximum number of volumes allowed (%(allowed)d) exceeded'
exception VolumeMetadataNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

VolumeMetadataNotFound.message = 'Volume %(volume_id)s has no metadata with key %(metadata_key)s.'
exception VolumeMigrationFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

VolumeMigrationFailed.message = 'Volume migration failed: %(reason)s'
exception VolumeNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

VolumeNotFound.message = 'Volume %(volume_id)s could not be found.'
exception VolumeSizeExceedsAvailableQuota(message=None, **kwargs)

Bases: cinder.exception.QuotaError

VolumeSizeExceedsAvailableQuota.message = 'Requested volume or snapshot exceeds allowed Gigabytes quota'
exception VolumeTypeCreateFailed(message=None, **kwargs)

Bases: cinder.exception.CinderException

VolumeTypeCreateFailed.message = 'Cannot create volume_type with name %(name)s and specs %(extra_specs)s'
exception VolumeTypeEncryptionExists(message=None, **kwargs)

Bases: cinder.exception.Invalid

VolumeTypeEncryptionExists.message = 'Volume type encryption for type %(type_id)s already exists.'
exception VolumeTypeExists(message=None, **kwargs)

Bases: cinder.exception.Duplicate

VolumeTypeExists.message = 'Volume Type %(id)s already exists.'
exception VolumeTypeExtraSpecsNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

VolumeTypeExtraSpecsNotFound.message = 'Volume Type %(volume_type_id)s has no extra specs with key %(extra_specs_key)s.'
exception VolumeTypeInUse(message=None, **kwargs)

Bases: cinder.exception.CinderException

VolumeTypeInUse.message = 'Volume Type %(volume_type_id)s deletion is not allowed with volumes present with the type.'
exception VolumeTypeNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

VolumeTypeNotFound.message = 'Volume type %(volume_type_id)s could not be found.'
exception VolumeTypeNotFoundByName(message=None, **kwargs)

Bases: cinder.exception.VolumeTypeNotFound

VolumeTypeNotFoundByName.message = 'Volume type with name %(volume_type_name)s could not be found.'
exception WillNotSchedule(message=None, **kwargs)

Bases: cinder.exception.CinderException

WillNotSchedule.message = "Host %(host)s is not up or doesn't exist."
exception ZadaraAttachmentsNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ZadaraAttachmentsNotFound.message = 'Failed to retrieve attachments for volume %(name)s'
exception ZadaraInvalidAttachmentInfo(message=None, **kwargs)

Bases: cinder.exception.Invalid

ZadaraInvalidAttachmentInfo.message = 'Invalid attachment info for volume %(name)s: %(reason)s'
exception ZadaraServerCreateFailure(message=None, **kwargs)

Bases: cinder.exception.CinderException

ZadaraServerCreateFailure.message = 'Unable to create server object for initiator %(name)s'
exception ZadaraServerNotFound(message=None, **kwargs)

Bases: cinder.exception.NotFound

ZadaraServerNotFound.message = 'Unable to find server object for initiator %(name)s'
exception ZadaraVPSANoActiveController(message=None, **kwargs)

Bases: cinder.exception.CinderException

ZadaraVPSANoActiveController.message = 'Unable to find any active VPSA controller'

The cinder.common.config Module

Command-line flag library.

Emulates gflags by wrapping cfg.ConfigOpts.

The idea is to move fully to cfg eventually, and this wrapper is a stepping stone.

The cinder.process Module

The cinder.rpc Module

The cinder.server Module

The cinder.test Module

The cinder.utils Module

Utilities and helper functions.

class LazyPluggable(pivot, **backends)

Bases: object

A pluggable backend loaded lazily based on some value.

class LoopingCall(f=None, *args, **kw)

Bases: object

LoopingCall.start(interval, initial_delay=None)
LoopingCall.stop()
LoopingCall.wait()
exception LoopingCallDone(retvalue=True)

Bases: exceptions.Exception

Exception to break out and stop a LoopingCall.

The poll-function passed to LoopingCall can raise this exception to break out of the loop normally. This is somewhat analogous to StopIteration.

An optional return-value can be included as the argument to the exception; this return-value will be returned by LoopingCall.wait()

class ProtectedExpatParser(forbid_dtd=True, forbid_entities=True, *args, **kwargs)

Bases: xml.sax.expatreader.ExpatParser

An expat parser which disables DTD’s and entities by default.

ProtectedExpatParser.entity_decl(entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
ProtectedExpatParser.reset()
ProtectedExpatParser.start_doctype_decl(name, sysid, pubid, has_internal_subset)
ProtectedExpatParser.unparsed_entity_decl(name, base, sysid, pubid, notation_name)
class SSHPool(ip, port, conn_timeout, login, password=None, privatekey=None, *args, **kwargs)

Bases: eventlet.pools.Pool

A simple eventlet pool to hold ssh connections.

SSHPool.create()
SSHPool.get()

Return an item from the pool, when one is available. This may cause the calling greenthread to block. Check if a connection is active before returning it. For dead connections create and return a new connection.

SSHPool.remove(ssh)

Close an ssh client and remove it from free_items.

as_int(obj, quiet=True)
brick_get_connector(protocol, driver=None, execute=<function execute at 0x7f5a4ca88140>, use_multipath=False, device_scan_attempts=3)

Wrapper to get a brick connector object. This automatically populates the required protocol as well as the root_helper needed to execute commands.

brick_get_connector_properties()

wrapper for the brick calls to automatically set the root_helper needed for cinder.

check_exclusive_options(**kwargs)

Checks that only one of the provided options is actually not-none.

Iterates over all the kwargs passed in and checks that only one of said arguments is not-none, if more than one is not-none then an exception will be raised with the names of those arguments who were not-none.

check_ssh_injection(cmd_list)
cinderdir()
create_channel(client, width, height)

Invoke an interactive shell session on server.

execute(*cmd, **kwargs)

Convenience wrapper around oslo’s execute() method.

find_config(config_path)

Find a configuration file using the given hint.

Parameters:config_path – Full or relative path to the config.
Returns:Full path of the config, if it exists.
Raises :cinder.exception.ConfigNotFound
generate_glance_url()

Generate the URL to glance.

generate_password(length=20, symbolgroups=('23456789', 'ABCDEFGHJKLMNPQRSTUVWXYZ', 'abcdefghijkmnopqrstuvwxyz'))

Generate a random password from the supplied symbol groups.

At least one symbol from each group will be included. Unpredictable results if length is less than the number of symbol groups.

Believed to be reasonably secure (with a reasonable password length!)

generate_username(length=20, symbolgroups=('23456789', 'ABCDEFGHJKLMNPQRSTUVWXYZ', 'abcdefghijkmnopqrstuvwxyz'))
get_from_path(items, path)

Returns a list of items matching the specified path.

Takes an XPath-like expression e.g. prop1/prop2/prop3, and for each item in items, looks up items[prop1][prop2][prop3]. Like XPath, if any of the intermediate results are lists it will treat each list item individually. A ‘None’ in items or any child expressions will be ignored, this function will not throw because of None (anywhere) in items. The returned list will contain no None values.

get_root_helper()
hash_file(file_like_object)

Generate a hash for the contents of a file.

is_valid_boolstr(val)

Check if the provided string is a valid bool string or not.

last_completed_audit_period(unit=None)

This method gives you the most recently completed audit period.

arguments:
units: string, one of ‘hour’, ‘day’, ‘month’, ‘year’
Periods normally begin at the beginning (UTC) of the period unit (So a ‘day’ period begins at midnight UTC, a ‘month’ unit on the 1st, a ‘year’ on Jan, 1) unit string may be appended with an optional offset like so: 'day@18‘ This will begin the period at 18:00 UTC. 'month@15‘ starts a monthly period on the 15th, and year@3 begins a yearly one on March 1st.
returns: 2 tuple of datetimes (begin, end)
The begin timestamp of this audit period is the same as the end of the previous.
make_dev_path(dev, partition=None, base='/dev')

Return a path to a particular device.

>>> make_dev_path('xvdc')
/dev/xvdc
>>> make_dev_path('xvdc', 1)
/dev/xvdc1
monkey_patch()

If the CONF.monkey_patch set as True, this function patches a decorator for all functions in specified modules.

You can set decorators for each modules using CONF.monkey_patch_modules. The format is “Module path:Decorator function”. Example: ‘cinder.api.ec2.cloud:’ cinder.openstack.common.notifier.api.notify_decorator’

Parameters of the decorator is as follows. (See cinder.openstack.common.notifier.api.notify_decorator)

name - name of the function function - object of the function

read_cached_file(filename, cache_info, reload_func=None)

Read from a file if it has been modified.

Parameters:
  • cache_info – dictionary to hold opaque cache.
  • reload_func – optional function to be called with data when file is reloaded due to a modification.
Returns:

data from file

read_file_as_root(file_path)

Secure helper to read file as root.

require_driver_initialized(func)
safe_minidom_parse_string(xml_string)

Parse an XML string using minidom safely.

sanitize_hostname(hostname)

Return a hostname which conforms to RFC-952 and RFC-1123 specs.

service_is_up(service)

Check whether a service is up based on last heartbeat.

tempdir(*args, **kwds)
temporary_chown(*args, **kwds)

Temporarily chown a path.

Params owner_uid:
 UID of temporary owner (defaults to current user)
total_seconds(td)

Local total_seconds implementation for compatibility with python 2.6

walk_class_hierarchy(clazz, encountered=None)

Walk class hierarchy, yielding most derived classes first

xhtml_escape(value)

Escapes a string so it is valid within XML or XHTML.

The cinder.validate Module

The cinder.wsgi Module

Utility methods for working with WSGI servers.

class Application

Bases: object

Base WSGI application wrapper. Subclasses need to implement __call__.

classmethod Application.factory(global_config, **local_config)

Used for paste app factories in paste.deploy config files.

Any local configuration (that is, values under the [app:APPNAME] section of the paste config) will be passed into the __init__ method as kwargs.

A hypothetical configuration would look like:

[app:wadl] latest_version = 1.3 paste.app_factory = cinder.api.fancy_api:Wadl.factory

which would result in a call to the Wadl class as

import cinder.api.fancy_api fancy_api.Wadl(latest_version=‘1.3’)

You could of course re-implement the factory method in subclasses, but using the kwarg passing it shouldn’t be necessary.

class Debug(application)

Bases: cinder.wsgi.Middleware

Helper class for debugging a WSGI application.

Can be inserted into any WSGI application chain to get information about the request and response.

static Debug.print_generator(app_iter)

Iterator that prints the contents of a wrapper string.

class Loader(config_path=None)

Bases: object

Used to load WSGI applications from paste configurations.

Loader.load_app(name)

Return the paste URLMap wrapped WSGI application.

Parameters:name – Name of the application to load.
Returns:Paste URLMap object wrapping the requested application.
Raises :cinder.exception.PasteAppNotFound
class Middleware(application)

Bases: cinder.wsgi.Application

Base WSGI middleware.

These classes require an application to be initialized that will be called next. By default the middleware will simply call its wrapped app, or you can override __call__ to customize its behavior.

classmethod Middleware.factory(global_config, **local_config)

Used for paste app factories in paste.deploy config files.

Any local configuration (that is, values under the [filter:APPNAME] section of the paste config) will be passed into the __init__ method as kwargs.

A hypothetical configuration would look like:

[filter:analytics] redis_host = 127.0.0.1 paste.filter_factory = cinder.api.analytics:Analytics.factory

which would result in a call to the Analytics class as

import cinder.api.analytics analytics.Analytics(app_from_paste, redis_host=‘127.0.0.1’)

You could of course re-implement the factory method in subclasses, but using the kwarg passing it shouldn’t be necessary.

Middleware.process_request(req)

Called on each request.

If this returns None, the next application down the stack will be executed. If it returns a response then that response will be returned and execution will stop here.

Middleware.process_response(response)

Do whatever you’d like to the response.

class Request(environ, charset=None, unicode_errors=None, decode_param_names=None, **kw)

Bases: webob.request.Request

class Router(mapper)

Bases: object

WSGI middleware that maps incoming requests to WSGI apps.

class Server(name, app, host=None, port=None, pool_size=None, protocol=<class eventlet.wsgi.HttpProtocol at 0x7f5a4c2667a0>)

Bases: object

Server class to manage a WSGI server, serving a WSGI application.

Server.default_pool_size = 1000
Server.host
Server.port
Server.start(backlog=128)

Start serving a WSGI application.

Parameters:backlog – Maximum number of queued connections.
Returns:None
Raises :cinder.exception.InvalidInput
Server.stop()

Stop this server.

This is not a very nice action, as currently the method by which a server is stopped is by killing its eventlet.

Returns:None
Server.wait()

Block, until the server has stopped.

Waits on the server’s eventlet to finish, then returns.

Returns:None

Tests

The declare_conf Module

The conf_fixture Module

set_defaults(conf)

The process_unittest Module

The rpc_unittest Module

The runtime_conf Module

The validator_unittest Module