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
Return a version of this context with admin flag set.
Nova base exception handling, including decorator for re-raising Nova-type exceptions. SHOULD include dedicated exception logging.
Bases: nova.exception.Error
Bases: nova.exception.Error
Wraps an implementation specific exception
Bases: nova.exception.Error
Bases: exceptions.Exception
Bases: nova.exception.NotFound
Bases: nova.exception.Error
Bases: nova.exception.Error
Bases: nova.exception.Error
Bases: nova.exception.Error
Bases: nova.exception.Error
Bases: nova.exception.Error
Bases: exceptions.IOError
Bases: nova.exception.Error
Bases: nova.exception.NotFound
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.
AMQP-based RPC. Queues have consumers and publishers. No fan-out support yet.
Bases: nova.rpc.Consumer
Calls methods on a proxy object based on method and args
Bases: carrot.connection.BrokerConnection
Connection instance object
Returns the instance
Recreates the connection instance
This is necessary to recover from some network errors/disconnects
Bases: carrot.messaging.Consumer
Consumer base class
Contains methods for connecting the fetch method to async loops
Only needed for unit tests!
Wraps the parent fetch with some logic for failed connections
Bases: nova.rpc.Consumer
Consumes messages directly on a channel specified by msg_id
Bases: nova.rpc.Publisher
Publishes messages directly on a channel specified by msg_id
Bases: nova.rpc.AdapterConsumer
Consumes messages from a fanout exchange
Bases: nova.rpc.Publisher
Publishes messages to a fanout exchange.
Bases: carrot.messaging.Publisher
Publisher base class
Bases: nova.exception.Error
Signifies that a remote class has raised an exception
Containes a string representation of the type of the original exception, the value of the original exception, and the traceback. These are sent to the parent as a joined string so printing the exception contains all of the relevent info.
Bases: nova.rpc.AdapterConsumer
Consumes messages on a specific topic
Bases: nova.rpc.Publisher
Publishes messages on a specific topic
Sends a message on a topic and wait for a response
Sends a message on a topic without waiting for a response
Sends a message on a fanout exchange without waiting for a response
Logs a result and exits
Sends a reply or an error on the channel signified by msg_id
failure should be a sys.exc_info() tuple.
Sends a message for testing
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.
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 finalize/tear down test environment.
Decorator that skips a test if running in fake mode
Twisted daemon helpers, specifically to parse out gFlags from twisted flags, manage pid files and support syslogging.
Bases: object
Bases: twisted.scripts._twistd_unix.ServerOptions
Stop the daemon
System-level utilities and helper functions.
Bases: object
A pluggable backend loaded lazily based on some value.
Bases: object
Bases: exceptions.Exception
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()
Advance overriden time using a datetime.timedelta.
Advance overriden time by seconds.
Checks that obj is of type cls, and lets PyLint infer types
Remove the overridden time.
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
Returns iso formatted utcnow.
Return a dictionary in which the dictionaries keys are mapped to new keys.
Turn an iso formatted time back into a datetime
Return two dicts, one containing only keys the other containing everything but keys
Override utils.utcnow to return a constant time.
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.
Overridable version of datetime.datetime.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 fles.
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: object
WSGI app that reads routing information supplied by RoutesMiddleware and calls the requested action method upon itself. All action methods must, in addition to their normal parameters, accept a ‘req’ argument which is the incoming wsgi.Request. They raise a webob.exc exception, or return a dict which will be serialized by requested content type.
Provide the XML namespace to use if none is otherwise specified.
Bases: nova.wsgi.Middleware
Helper class that 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 iterator when iterated.
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 fles.
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
Determine the most acceptable content-type based on the query extension then the Accept header
Bases: object
WSGI middleware that maps incoming requests to WSGI apps.
Bases: object
Serializes and deserializes dictionaries to certain MIME types.
Deserialize a string to a dictionary.
The string must be in the format of a supported MIME type.
Serialize a dictionary into a string of the specified content type.
Bases: object
Server class to manage multiple WSGI sockets and applications.
Run a WSGI server with the given application.
Wait until all servers have completed running.
Bases: object
A thin wrapper that responds to write and logs.
Builds a wsgi app from a paste config, None if app not configured.
Returns a paste configuration dict, or None.
Find the best location in the system for a paste config file.
The search for a paste config file honors FLAGS.state_path, which in a version checked out from bzr will be the nova directory in the top level of the checkout, and in an installation for a package for your distribution will likely point to someplace like /etc/nova.
This method tries to load places likely to be used in development or experimentation before falling back to the system-wide configuration in /etc/nova/.