Volume-related Utilities and helpers.
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: class MyClass(object, metaclass=utils.TraceWrapperMetaclass):
Bases: ABCMeta
, TraceWrapperMetaclass
Metaclass that wraps all methods of a class with trace.
Encode pool into host info.
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.
multipath – A boolean indicating whether the connector can support multipath.
enforce_multipath – If True, it raises exception when multipath=True is specified but multipathd is not running. If False, it falls back to multipath=False when multipathd is not running.
Wrapper to get a brick encryptor object.
Check cinder db for already managed volume.
vol_id – volume id parameter
bool – return True, if db entry with specified volume id exists, otherwise return False
ValueError if vol_id is not a valid uuid string
Check that this is a LUKS encryption provider.
encryption dict
Validates the image metadata.
Unprovision old volumes to prevent data leaking between users.
Convert config file replication string to a dict.
The only supported form is as follows: “{‘key-1’=’val-1’ ‘key-2’=’val-2’…}”
config_string – Properly formatted string to convert to dict.
dict of string values
Downloads Glance image to the specified volume.
Copy data from the source volume to the destination volume.
The parameters ‘src’ and ‘dest’ are both typically of type str, which represents the path to each volume on the filesystem. Connectors can optionally return a volume handle of type RawIOBase for volumes that are not available on the local filesystem for open/close operations.
If either ‘src’ or ‘dest’ are not of type str, then they are assumed to be of type RawIOBase or any derivative that supports file operations such as read and write. In this case, the handles are treated as file handles instead of file paths and, at present moment, throttling is unavailable.
Extract Host, Backend or Pool information from host string.
host – String for host, which could include host@backend#pool info
level – Indicate which level of information should be extracted from host string. Level can be ‘host’, ‘backend’ or ‘pool’, default value is ‘backend’
default_pool_name – this flag specify what to do if level == ‘pool’ and there is no ‘pool’ info encoded in host string. default_pool_name=True will return DEFAULT_POOL_NAME, otherwise we return None. Default value of this parameter is False.
expected information, string or None
exception.InvalidVolume
host = ‘HostA@BackendB#PoolC’ ret = extract_host(host, ‘host’) # ret is ‘HostA’ ret = extract_host(host, ‘backend’) # ret is ‘HostA@BackendB’ ret = extract_host(host, ‘pool’) # ret is ‘PoolC’
host = ‘HostX@BackendY’ ret = extract_host(host, ‘pool’) # ret is None ret = extract_host(host, ‘pool’, True) # ret is ‘_pool0’
Return a snapshot’s ID from its name on the backend.
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!)
Get a configuration object for a specific backend.
Get the max_over_subscription_ratio from a string
As some drivers need to do some calculations with the value and we are now receiving a string value in the conf, this converts the value to float when appropriate.
str_value – Configuration object
supports_auto – Tell if the calling driver supports auto MOSR.
value of mosr
Annoy the log about unsupported drivers.
Paginate a list of entries.
entries – list of dictionaries
The last element previously returned
The maximum number of items to return
The number of items to skip from the marker or from the first element.
A list of keys in the dictionaries to sort by
A list of sort directions, where each is either ‘asc’ or ‘dec’
Verifies if driver is initialized
If the driver is not initialized, an exception will be raised.
The driver instance.
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.
hostname – Host name to resolve.
IP Address for Host name.
Ensure IPv6 addresses are enclosed in [] for iSCSI portals.
Return a hostname which conforms to RFC-952 and RFC-1123 specs.
Set global variables for each trace flag.
Sets variables TRACE_METHOD and TRACE_API, which represent whether to log methods or api traces.
trace_flags – a list of strings
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.
a function decorator
Decorates a function if TRACE_API is true.
Decorates a function if TRACE_METHOD is true.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.