Utilities and helper functions.
Bases: object
Bases: type
Metaclass that wraps all methods of a class with trace_method.
This metaclass will cause every function inside of the class to be decorated with the trace_method decorator.
To use the metaclass you define a class like so: @six.add_metaclass(utils.TraceWrapperMetaclass) class MyClass(object):
Bases: abc.ABCMeta, cinder.utils.TraceWrapperMetaclass
Metaclass that wraps all methods of a class with trace.
Add user-visible admin metadata to regular metadata.
Extracts the admin metadata keys that are to be made visible to non-administrators, and adds them to the regular metadata structure for the passed-in volume.
Attach encryption layer.
Detach encryption layer.
Wrapper to get a brick connector object.
This automatically populates the required protocol as well as the root_helper needed to execute commands.
Wrapper to automatically set root_helper in brick calls.
Parameters: |
|
---|
Wrapper to get a brick encryptor object.
Builds a string of elements joined by ‘or’.
Will join strings with the ‘or’ word and if a str_format is provided it will be used to format the resulted joined string. If there are no elements an empty string will be returned.
Parameters: |
|
---|
Calculate the virtual free capacity based on thin provisioning support.
Parameters: |
|
---|---|
Returns: | the calculated virtual free capacity. |
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.
Checks that the volume metadata properties are valid.
Check the length of specified string.
Parameters: |
|
---|
Convert to native string.
Convert bytes and Unicode strings to native strings:
Convenience wrapper around oslo’s execute() method.
Get ‘major:minor’ number of block device.
Get the device’s ‘major:minor’ number of a block device to control I/O ratelimit of the specified path. If lookup_for_file is True and the path is a regular file, lookup a disk device which the file lies on and returns the result for the device.
This primarily exists to make unit testing easier.
This primarily exists to make unit testing easier.
Returns the file size.
Check if a string represents a None value.
Check if the provided string is a valid bool string or not.
This method gives you the most recently completed audit period.
Annoy the log about unsupported drivers.
Return a path to a particular device.
>>> make_dev_path('xvdc')
/dev/xvdc
>>> make_dev_path('xvdc', 1)
/dev/xvdc1
Patches decorators for all functions in a specified module.
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)
Parameters: |
|
---|
Secure helper to read file as root.
Remove search options that are not valid for non-admin API/context.
Verifies if driver is initialized
If the driver is not initialized, an exception will be raised.
Params driver: | The driver instance. |
---|---|
Raises: | exception.DriverNotInitialized |
Resolves host name to IP address.
Resolves a host name (my.data.point.com) to an IP address (10.12.143.11). This routine also works if the data passed in hostname is already an IP. In this case, the same IP address will be returned.
Parameters: | hostname – Host name to resolve. |
---|---|
Returns: | IP Address for Host name. |
Robust file write.
Use “write to temp file and rename” model for writing the persistence file.
Parameters: |
|
---|
Return a hostname which conforms to RFC-952 and RFC-1123 specs.
Check whether a service is up based on last heartbeat.
Set global variables for each trace flag.
Sets variables TRACE_METHOD and TRACE_API, which represent whether to log method and api traces.
Parameters: | trace_flags – a list of strings |
---|
Temporarily chown a path.
Params owner_uid: | |
---|---|
UID of temporary owner (defaults to current user) |
Trace calls to the decorated function.
This decorator should always be defined as the outermost decorator so it is defined last. This is important so it does not interfere with other decorators.
Using this decorator on a function will cause its execution to be logged at DEBUG level with arguments, return values, and exceptions.
Returns: | a function decorator |
---|
Decorates a function if TRACE_API is true.
Decorates a function if TRACE_METHOD is true.
Check the length of each key and value of dictionary.
Make sure that value is a valid integer, potentially within range.
Parameters: |
|
---|---|
Returns: | integer |
Walk class hierarchy, yielding most derived classes first.