Libraries common throughout Nova or just ones that haven’t been categorized very well yet.
RequestContext: context for requests that persist through all of nova.
Bases: object
Security context and request information.
Represents the user taking a given action within the system.
Return a version of this context with admin flag set.
Nova base exception handling.
Includes decorator for re-raising Nova-type exceptions.
SHOULD include dedicated exception logging.
Bases: nova.exception.NotFound
Bases: nova.exception.NotAuthorized
Bases: nova.exception.Error
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.HostNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Error
Wraps an implementation specific exception.
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: exceptions.Exception
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotAllowed
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.ImageNotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.UserExists
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: exceptions.Exception
Base Nova 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.
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: exceptions.IOError
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Error
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Error
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Error
This decorator wraps a method to catch any exceptions that may get thrown. It logs the exception as well as optionally sending it to the notification system.
Command-line flag library.
Wraps gflags.
Package-level global flags are defined here, the rest are defined where they’re used.
Bases: gflags.FlagValues
Extension of gflags.FlagValues that allows undefined and runtime flags.
Unknown flags will be ignored when parsing the command line, but the command line will be kept so that it can be replayed if new flags are defined after the initial parsing.
Mark a flag as dirty so that accessing it will case a reparse.
Bases: object
Wrapper around FlagValues objects.
Wraps FlagValues objects for string.Template so that we’re sure to return strings.
Delay import of rpc_backend until FLAGS are loaded.
Base classes for our unit tests.
Allows overriding of flags for use of fakes, and some black magic for inline callbacks.
Bases: unittest.case.TestCase
Test case base class for all unit tests.
Assert a list of dicts are equivalent.
Assert two dicts are equivalent.
This is a ‘deep’ match in the sense that it handles nested dictionaries appropriately.
NOTE:
If you don’t care (or don’t know) a given value, you can specify the string DONTCARE as the value. This will cause that dict-item to be skipped.
Python < v2.7 compatibility. Assert ‘a’ in ‘b’
Python < v2.7 compatibility. Assert ‘a’ NOT in ‘b’
Assert a sub_dict is subset of super_dict.
Override flag variables for a test.
Resets all flag variables for the test.
Runs after each test.
Run before each test method to initialize test environment.
Runs after each test method to tear down test environment.
Bases: object
Decorator that skips a test if contition is true.
Decorator that skips a test if running in fake mode.
Bases: object
Decorator that skips a test.
Bases: object
Decorator that skips a test if condition is not true.
Utilities and helper functions.
Bases: object
A pluggable backend loaded lazily based on some value.
Bases: object
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()
Bases: object
Generic userspace on-disk ringbuffer implementation.
Read the entire ringbuffer without consuming it.
Write some amount of data to the ringbuffer, discarding the oldest data as max_size is exceeded.
Advance overriden time using a datetime.timedelta.
Advance overriden time by seconds.
Convert a string representation of a bool into a bool value
Checks that obj is of type cls, and lets PyLint infer types.
Remove the overridden time.
Convert a value or list into a list of dicts
Helper method to execute command with optional retry.
:cmd Passed to subprocess.Popen. :process_input Send to opened process. :check_exit_code Defaults to 0. Raise exception.ProcessExecutionError
unless program exits with this code.
: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 :raises exception.ProcessExecutionError
Recursively flatten a nested dictionary.
Generate a random password from the supplied symbols.
Believed to be reasonably secure (with a reasonable password length!)
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.
Returns a class from a string including module and class.
Returns an object including a module or module and class.
Return True if before is older than seconds.
For our purposes, a UUID is a string in canoical form:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
valid the address strictly as per format xxx.xxx.xxx.xxx. where xxx is a value between 0 and 255.
Returns iso formatted utcnow.
Return a dict in which the dictionaries keys are mapped to new keys.
If the Flags.monkey_patch set as True, this functuion 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: ‘nova.api.ec2.cloud:nova.notifier.api.notify_decorator’
Parameters of the decorator is as follows. (See nova.notifier.api.notify_decorator)
name - name of the function function - object of the function
Turn an iso formatted time back into a datetime.
Parses the given server_string and returns a list of host and port. If it’s not a combination of host part and port, the port element is a null string. If the input is invalid expression, return a null list.
Turn a formatted time back into a datetime.
Return two dicts, one with keys the other with everything else.
Override utils.utcnow to return a constant time.
Returns formatted utcnow.
Return a dict that only contains a subset of keys.
Synchronization decorator.
Decorating a method like so: @synchronized(‘mylock’) def foo(self, *args):
...
ensures that only one thread will execute the bar method at a time.
Different methods can share the same lock: @synchronized(‘mylock’) def foo(self, *args):
...
@synchronized(‘mylock’) def bar(self, *args):
...
This way only one of either foo or bar can be executing at a time.
The external keyword argument denotes whether this lock should work across multiple processes. This means that if two different workers both run a a method decorated with @synchronized(‘mylock’, external=True), only one of them will execute at a time.
Convert a complex object into primitives.
Handy for JSON serialization. We can optionally handle instances, but since this is a recursive function, we could have cyclical data structures.
To handle cyclical data structures we could track the actual objects visited in a set, but not all objects are hashable. Instead we just track the depth of the object inspections and don’t go too deep.
Therefore, convert_instances=True is lossy ... be aware.
Overridable version of utils.utcnow.
Timestamp version of our utcnow function.
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
Sends a vpn negotiation packet and returns the server session.
Returns False on a failure. Basic packet structure is below.
x | cli_id |
x = packet identifier 0x38 cli_id = 64 bit identifier ? = unknown, probably flags/padding
x | srv_id | cli_id |
x = packet identifier 0x40 cli_id = 64 bit identifier ? = unknown, probably flags/padding bit 9 was 1 and the rest were 0 in testing
Escapes a string so it is valid within XML or XHTML.
Code is directly from the utf8 function in http://github.com/facebook/tornado/blob/master/tornado/escape.py
Utility methods for working with WSGI servers.
Bases: object
Base WSGI application wrapper. Subclasses need to implement __call__.
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 = nova.api.fancy_api:Wadl.factory
which would result in a call to the Wadl class as
import nova.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.
Bases: nova.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.
Iterator that prints the contents of a wrapper string.
Bases: object
Used to load WSGI applications from paste configurations.
Return the paste URLMap wrapped WSGI application.
Parameters: | name – Name of the application to load. |
---|---|
Returns: | Paste URLMap object wrapping the requested application. |
Raises : | nova.exception.PasteAppNotFound |
Bases: nova.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.
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 = nova.api.analytics:Analytics.factory
which would result in a call to the Analytics class as
import nova.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.
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.
Do whatever you’d like to the response.
Bases: webob.request.Request
Bases: object
WSGI middleware that maps incoming requests to WSGI apps.
Bases: object
Server class to manage a WSGI server, serving a WSGI application.
Start serving a WSGI application.
Parameters: | backlog – Maximum number of queued connections. |
---|---|
Returns: | None |
Run a raw TCP server with the given application.
Stop this server.
This is not a very nice action, as currently the method by which a server is stopped is by killing it’s eventlet.
Returns: | None |
---|
Block, until the server has stopped.
Waits on the server’s eventlet to finish, then returns.
Returns: | None |
---|