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, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, **kwargs)
Bases: object
Security context and request information.
Represents the user taking a given action within the system.
-
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.to_dict()
-
RequestContext.update_store()
-
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 = u'User does not have admin privileges'
-
exception BadHTTPResponseStatus(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
BadHTTPResponseStatus.message = u'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 = u'An unknown exception occurred.'
-
CinderException.safe = False
-
exception ClassNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ClassNotFound.message = u'Class %(class_name)s could not be found: %(exception)s'
-
exception ConfigNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ConfigNotFound.message = u'Could not find config at %(path)s'
-
exception ConvertedException(code=0, title='', explanation='')
Bases: webob.exc.WSGIHTTPException
-
exception DBError(inner_exception=None)
Bases: cinder.exception.Error
Wraps an implementation specific exception.
-
exception DeprecatedConfig(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
DeprecatedConfig.message = u'Fatal call to deprecated config %(msg)s'
-
exception DiskNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
DiskNotFound.message = u'No disk at %(location)s'
-
exception Duplicate(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
exception DuplicateSfVolumeNames(message=None, **kwargs)
Bases: cinder.exception.Duplicate
-
DuplicateSfVolumeNames.message = u'Detected more than one volume with name %(vol_name)s'
-
exception Error
Bases: exceptions.Exception
-
exception FailedCmdWithDump(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
FailedCmdWithDump.message = u'Operation failed with status=%(status)s. Full dump: %(data)s'
-
exception FileNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
FileNotFound.message = u'File %(file_path)s could not be found.'
-
exception GlanceConnectionFailed(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
GlanceConnectionFailed.message = u'Connection to glance failed: %(reason)s'
-
exception HostBinaryNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
HostBinaryNotFound.message = u'Could not find binary %(binary)s on host %(host)s.'
-
exception HostNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
HostNotFound.message = u'Host %(host)s could not be found.'
-
exception ISCSITargetCreateFailed(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
ISCSITargetCreateFailed.message = u'Failed to create iscsi target for volume %(volume_id)s.'
-
exception ISCSITargetNotFoundForVolume(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ISCSITargetNotFoundForVolume.message = u'No target id found for volume %(volume_id)s.'
-
exception ISCSITargetRemoveFailed(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
ISCSITargetRemoveFailed.message = u'Failed to remove iscsi target for volume %(volume_id)s.'
-
exception ImageNotAuthorized(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
ImageNotAuthorized.message = u'Not authorized for image %(image_id)s.'
-
exception ImageNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ImageNotFound.message = u'Image %(image_id)s could not be found.'
-
exception ImageUnacceptable(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
ImageUnacceptable.message = u'Image %(image_id)s is unacceptable: %(reason)s'
-
exception InstanceNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
InstanceNotFound.message = u'Instance %(instance_id)s could not be found.'
-
exception Invalid(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
Invalid.code = 400
-
Invalid.message = u'Unacceptable parameters.'
-
exception InvalidContentType(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidContentType.message = u'Invalid content type %(content_type)s.'
-
exception InvalidImageRef(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidImageRef.message = u'Invalid image href %(image_href)s.'
-
exception InvalidInput(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidInput.message = u'Invalid input received: %(reason)s'
-
exception InvalidParameterValue(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidParameterValue.message = u'%(err)s'
-
exception InvalidPortRange(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidPortRange.message = u'Invalid port range %(from_port)s:%(to_port)s. %(msg)s'
-
exception InvalidQuotaValue(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidQuotaValue.message = u'Change would make usage less than 0 for the following resources: %(unders)s'
-
exception InvalidRequest(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidRequest.message = u'The request is invalid.'
-
exception InvalidReservationExpiration(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidReservationExpiration.message = u'Invalid reservation expiration %(expire)s.'
-
exception InvalidResults(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidResults.message = u'The results are invalid.'
-
exception InvalidSnapshot(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidSnapshot.message = u'Invalid snapshot: %(reason)s'
-
exception InvalidUUID(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidUUID.message = u'Expected a uuid but received %(uuid).'
-
exception InvalidUnicodeParameter(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidUnicodeParameter.message = u'Invalid Parameter: Unicode is not supported by the current database.'
-
exception InvalidVolume(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidVolume.message = u'Invalid volume: %(reason)s'
-
exception InvalidVolumeType(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
InvalidVolumeType.message = u'Invalid volume type: %(reason)s'
-
exception KeyPairExists(message=None, **kwargs)
Bases: cinder.exception.Duplicate
-
KeyPairExists.message = u'Key pair %(key_name)s already exists.'
-
exception MalformedRequestBody(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
MalformedRequestBody.message = u'Malformed message body: %(reason)s'
-
exception MalformedResponse(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
MalformedResponse.message = u'Malformed response to command %(cmd)s: %(reason)s'
-
exception MigrationError(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
MigrationError.message = u'Migration error: %(reason)s'
-
exception MigrationNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
MigrationNotFound.message = u'Migration %(migration_id)s could not be found.'
-
exception MigrationNotFoundByStatus(message=None, **kwargs)
Bases: cinder.exception.MigrationNotFound
-
MigrationNotFoundByStatus.message = u'Migration not found for instance %(instance_id)s with status %(status)s.'
-
exception NfsException(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
NfsException.message = u'Unknown NFS exception'
-
exception NfsNoSharesMounted(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
NfsNoSharesMounted.message = u'No mounted NFS shares found'
-
exception NfsNoSuitableShareFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
NfsNoSuitableShareFound.message = u'There is no share which can host %(volume_size)sG'
-
exception NoValidHost(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
NoValidHost.message = u'No valid host was found. %(reason)s'
-
exception NotAllowed(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
NotAllowed.message = u'Action not allowed.'
-
exception NotAuthorized(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
NotAuthorized.code = 403
-
NotAuthorized.message = u'Not authorized.'
-
exception NotFound(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
NotFound.code = 404
-
NotFound.message = u'Resource could not be found.'
-
NotFound.safe = True
-
exception OverQuota(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
OverQuota.message = u'Quota exceeded for resources: %(overs)s'
-
exception PasteAppNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
PasteAppNotFound.message = u"Could not load paste app '%(name)s' from %(path)s"
-
exception PersistentVolumeFileNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
PersistentVolumeFileNotFound.message = u'Volume %(volume_id)s persistence file could not be found.'
-
exception PolicyNotAuthorized(message=None, **kwargs)
Bases: cinder.exception.NotAuthorized
-
PolicyNotAuthorized.message = u"Policy doesn't allow %(action)s to be performed."
-
exception ProcessExecutionError(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)
Bases: exceptions.IOError
-
exception ProjectQuotaNotFound(message=None, **kwargs)
Bases: cinder.exception.QuotaNotFound
-
ProjectQuotaNotFound.message = u'Quota for project %(project_id)s could not be found.'
-
exception QuotaClassNotFound(message=None, **kwargs)
Bases: cinder.exception.QuotaNotFound
-
QuotaClassNotFound.message = u'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 = u'Quota exceeded: code=%(code)s'
-
QuotaError.safe = True
-
exception QuotaNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
QuotaNotFound.message = u'Quota could not be found'
-
exception QuotaResourceUnknown(message=None, **kwargs)
Bases: cinder.exception.QuotaNotFound
-
QuotaResourceUnknown.message = u'Unknown quota resources %(unknown)s.'
-
exception QuotaUsageNotFound(message=None, **kwargs)
Bases: cinder.exception.QuotaNotFound
-
QuotaUsageNotFound.message = u'Quota usage for project %(project_id)s could not be found.'
-
exception ReservationNotFound(message=None, **kwargs)
Bases: cinder.exception.QuotaNotFound
-
ReservationNotFound.message = u'Quota reservation %(uuid)s could not be found.'
-
exception ServiceNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ServiceNotFound.message = u'Service %(service_id)s could not be found.'
-
exception ServiceUnavailable(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
ServiceUnavailable.message = u'Service is unavailable at this time.'
-
exception SfAccountNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
SfAccountNotFound.message = u'Unable to locate account %(account_name)s on Solidfire device'
-
exception SfJsonEncodeFailure(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
SfJsonEncodeFailure.message = u'Failed to load data into json format'
-
exception SnapshotIsBusy(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
SnapshotIsBusy.message = u'deleting snapshot %(snapshot_name)s that has dependent volumes'
-
exception SnapshotNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
SnapshotNotFound.message = u'Snapshot %(snapshot_id)s could not be found.'
-
exception SolidFireAPIDataException(message=None, **kwargs)
Bases: cinder.exception.SolidFireAPIException
-
SolidFireAPIDataException.message = u'Error in SolidFire API response: data=%(data)s'
-
exception SolidFireAPIException(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
SolidFireAPIException.message = u'Bad response from SolidFire API'
-
exception UnknownCmd(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
UnknownCmd.message = u'Unknown or unsupported command %(cmd)s'
-
exception VolumeAttached(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
VolumeAttached.message = u'Volume %(volume_id)s is still attached, detach volume first.'
-
exception VolumeBackendAPIException(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
VolumeBackendAPIException.message = u'Bad or unexpected response from the storage volume backend API: %(data)s'
-
exception VolumeIsBusy(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
VolumeIsBusy.message = u'deleting volume %(volume_name)s that has snapshot'
-
exception VolumeLimitExceeded(message=None, **kwargs)
Bases: cinder.exception.QuotaError
-
VolumeLimitExceeded.message = u'Maximum number of volumes allowed (%(allowed)d) exceeded'
-
exception VolumeMetadataNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
VolumeMetadataNotFound.message = u'Volume %(volume_id)s has no metadata with key %(metadata_key)s.'
-
exception VolumeNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
VolumeNotFound.message = u'Volume %(volume_id)s could not be found.'
-
exception VolumeNotFoundForInstance(message=None, **kwargs)
Bases: cinder.exception.VolumeNotFound
-
VolumeNotFoundForInstance.message = u'Volume not found for instance %(instance_id)s.'
-
exception VolumeSizeExceedsAvailableQuota(message=None, **kwargs)
Bases: cinder.exception.QuotaError
-
VolumeSizeExceedsAvailableQuota.message = u'Requested volume exceeds allowed volume size quota'
-
exception VolumeSizeExceedsQuota(message=None, **kwargs)
Bases: cinder.exception.QuotaError
-
VolumeSizeExceedsQuota.message = u'Maximum volume size exceeded'
-
exception VolumeTypeCreateFailed(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
VolumeTypeCreateFailed.message = u'Cannot create volume_type with name %(name)s and specs %(extra_specs)s'
-
exception VolumeTypeExists(message=None, **kwargs)
Bases: cinder.exception.Duplicate
-
VolumeTypeExists.message = u'Volume Type %(name)s already exists.'
-
exception VolumeTypeExtraSpecsNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
VolumeTypeExtraSpecsNotFound.message = u'Volume Type %(volume_type_id)s has no extra specs with key %(extra_specs_key)s.'
-
exception VolumeTypeNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
VolumeTypeNotFound.message = u'Volume type %(volume_type_id)s could not be found.'
-
exception VolumeTypeNotFoundByName(message=None, **kwargs)
Bases: cinder.exception.VolumeTypeNotFound
-
VolumeTypeNotFoundByName.message = u'Volume type with name %(volume_type_name)s could not be found.'
-
exception WillNotSchedule(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
WillNotSchedule.message = u"Host %(host)s is not up or doesn't exist."
-
exception ZadaraAttachmentsNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ZadaraAttachmentsNotFound.message = u'Failed to retrieve attachments for volume %(name)s'
-
exception ZadaraInvalidAttachmentInfo(message=None, **kwargs)
Bases: cinder.exception.Invalid
-
ZadaraInvalidAttachmentInfo.message = u'Invalid attachment info for volume %(name)s: %(reason)s'
-
exception ZadaraServerCreateFailure(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
ZadaraServerCreateFailure.message = u'Unable to create server object for initiator %(name)s'
-
exception ZadaraServerNotFound(message=None, **kwargs)
Bases: cinder.exception.NotFound
-
ZadaraServerNotFound.message = u'Unable to find server object for initiator %(name)s'
-
exception ZadaraVPSANoActiveController(message=None, **kwargs)
Bases: cinder.exception.CinderException
-
ZadaraVPSANoActiveController.message = u'Unable to find any active VPSA controller'
-
wrap_db_error(f)
The cinder.flags 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.
-
DECLARE(name, module_string, flag_values=<cinder.openstack.common.cfg.CommonConfigOpts object at 0xa107a4c>)
-
exception UnrecognizedFlag
Bases: exceptions.Exception
-
parse_args(argv, default_config_files=None)
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 UndoManager
Bases: object
Provides a mechanism to facilitate rolling back a series of actions
when an exception is raised.
-
UndoManager.rollback_and_reraise(msg=None, **kwargs)
Rollback a series of actions then re-raise the exception.
Note
(sirp) This should only be called within an
exception handler.
-
UndoManager.undo_with(undo_func)
-
bool_from_str(val)
Convert a string representation of a bool into a bool value
-
check_isinstance(obj, cls)
Checks that obj is of type cls, and lets PyLint infer types.
-
cinderdir()
-
convert_to_list_dict(lst, label)
Convert a value or list into a list of dicts
-
debug(arg)
-
delete_if_exists(pathname)
delete a file, but ignore file not found error
-
ensure_tree(path)
Create a directory (and any ancestor directories required)
Parameters: | path – Directory to create |
-
execute(*cmd, **kwargs)
Helper method to execute command with optional retry.
If you add a run_as_root=True command, don’t forget to add the
corresponding filter to etc/cinder/rootwrap.d !
Parameters: |
- cmd – Passed to subprocess.Popen.
- process_input – Send to opened process.
- check_exit_code – Single bool, int, or list of allowed exit
codes. Defaults to [0]. Raise
exception.ProcessExecutionError unless
program exits with one of these code.
- delay_on_retry – True | False. Defaults to True. If set to
True, wait a short amount of time
before retrying.
- attempts – How many times to retry cmd.
- run_as_root – True | False. Defaults to False. If set to True,
the command is prefixed by the command specified
in the root_helper FLAG.
|
Raises: |
- exception.Error – on receiving unknown arguments
- exception.ProcessExecutionError –
|
Returns: | a tuple, (stdout, stderr) from the spawned process, or None if
the command fails.
|
-
fetchfile(url, target)
-
file_open(*args, **kwargs)
Open file
see built-in file() documentation for more details
- Note: The reason this is kept in a separate module is to easily
- be able to provide a stub module that doesn’t alter system
state at all (for unit tests)
-
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 |
-
flatten_dict(dict_, flattened=None)
Recursively flatten a nested dictionary.
-
gen_uuid()
-
generate_glance_url()
Generate the URL to glance.
-
generate_mac_address()
Generate an Ethernet MAC address.
-
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_uid(topic, size=8)
-
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_my_linklocal(interface)
-
hash_file(file_like_object)
Generate a hash for the contents of a file.
-
is_uuid_like(val)
For our purposes, a UUID is a string in canonical form:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
-
is_valid_boolstr(val)
Check if the provided string is a valid bool string or not.
-
is_valid_ipv4(address)
valid the address strictly as per format xxx.xxx.xxx.xxx.
where xxx is a value between 0 and 255.
-
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.
-
last_octet(address)
-
logging_error(*args, **kwds)
Catches exception, write message to the log, re-raise.
This is a common refinement of save_and_reraise that writes a specific
message to the log.
-
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
-
map_dict_keys(dict_, key_map)
Return a dict in which the dictionaries keys are mapped to new keys.
-
monkey_patch()
If the Flags.monkey_patch set as True,
this function patches a decorator
for all functions in specified modules.
You can set decorators for each modules
using FLAGS.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
-
parse_mailmap(mailmap='.mailmap')
-
partition_dict(dict_, keys)
Return two dicts, one with keys the other with everything else.
-
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.
-
remove_path_on_error(*args, **kwds)
Protect code that wants to operate on PATH atomically.
Any exception will cause PATH to be removed.
-
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.
-
ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True)
-
str_dict_replace(s, mapping)
-
strcmp_const_time(s1, s2)
Constant-time string comparison.
Params s1: | the first string |
Params s2: | the second string |
Returns: | True if the strings are equal. |
This function takes two strings and compares them. It is intended to be
used when doing a comparison for authentication purposes to help guard
against timing attacks.
-
subset_dict(dict_, keys)
Return a dict that only contains a subset of keys.
-
tempdir(*args, **kwds)
-
temporary_chown(*args, **kwds)
Temporarily chown a path.
Params owner_uid: |
| UID of temporary owner (defaults to current user) |
-
temporary_mutation(*args, **kwds)
Temporarily set the attr on a particular object to a given value then
revert when finished.
One use of this is to temporarily set the read_deleted flag on a context
object:
- with temporary_mutation(context, read_deleted=”yes”):
- do_something_that_needed_deleted_objects()
-
timefunc(func)
Decorator that logs how long a particular function took to execute
-
total_seconds(td)
Local total_seconds implementation for compatibility with python 2.6
-
trycmd(*args, **kwargs)
A wrapper around execute() to more easily handle warnings and errors.
Returns an (out, err) tuple of strings containing the output of
the command’s stdout and stderr. If ‘err’ is not empty then the
command can be considered to have failed.
- :discard_warnings True | False. Defaults to False. If set to True,
- then for succeeding commands, stderr is cleared
-
utf8(value)
Try to turn a string into utf-8 if possible.
Code is directly from the utf8 function in
http://github.com/facebook/tornado/blob/master/tornado/escape.py
-
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
Tests
The declare_flags Module
The fake_flags Module
The flags_unittest Module
The process_unittest Module
The real_flags Module
The rpc_unittest Module
The runtime_flags Module
The validator_unittest Module