Utilities and helper functions.
Bases: xml.sax.expatreader.ExpatParser
An expat parser which disables DTD’s and entities by default.
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.
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: |
|
---|
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 the length of specified string.
Parameters: |
|
---|
Convert to native string.
Convert bytes and Unicode strings to native strings:
Invoke an interactive shell session on server.
Convenience wrapper around oslo’s execute() method.
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 |
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.
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.
Generate a hash for the contents of a file.
Check if a value looks like an int.
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.
Convert list of dicts to a indexted dict.
Takes a list of dicts, and converts it a nested dict indexed by <key>
Parameters: | seq – list of dicts |
---|---|
Parm key: | key in dicts to index by |
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. |
Parse an XML string using minidom safely.
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.
Walk class hierarchy, yielding most derived classes first.
Escapes a string so it is valid within XML or XHTML.