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.
Ensures a request has permission to access the given project.
Ensures a request has permission to access the given quota class.
Ensures a request has permission to access the given user.
Indicates if the request context is a normal user.
Raise exception.AdminRequired() if context is an admin context.
Raise exception.NotAuthorized() if context is not a user or an admin context.
Nova base exception handling.
Includes decorator for re-raising Nova-type exceptions.
SHOULD include dedicated exception logging.
Bases: nova.exception.NotAuthorized
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.HostNotFound
Bases: nova.exception.ServiceUnavailable
Bases: nova.exception.ServiceUnavailable
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.ConsoleNotFound
Bases: nova.exception.ConsoleNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: webob.exc.WSGIHTTPException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.FileNotFound
Bases: nova.exception.FileNotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.Duplicate
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.FixedIpNotFound
Bases: nova.exception.FixedIpNotFound
Bases: nova.exception.FixedIpNotFound
Bases: nova.exception.FixedIpNotFound
Bases: nova.exception.FixedIpNotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Duplicate
Bases: nova.exception.QuotaError
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.FloatingIpNotFound
Bases: nova.exception.FloatingIpNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.ImageNotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Duplicate
Bases: nova.exception.Invalid
Bases: nova.exception.InstanceInvalidState
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
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.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Duplicate
Bases: nova.exception.NotFound
Bases: nova.exception.Duplicate
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.InstanceTypeNotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.InvalidBDM
Bases: nova.exception.InvalidBDM
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.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.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.Duplicate
Bases: nova.exception.QuotaError
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.QuotaError
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.MigrationNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NetworkNotFound
Bases: nova.exception.NetworkNotFound
Bases: nova.exception.NetworkNotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NetworkNotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.FloatingIpNotFound
Bases: nova.exception.NotFound
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.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.QuotaError
Bases: nova.exception.QuotaError
Bases: nova.exception.QuotaError
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotAuthorized
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: exceptions.IOError
Bases: nova.exception.NotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.QuotaNotFound
Bases: nova.exception.NovaException
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.Invalid
Bases: nova.exception.QuotaError
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.SecurityGroupNotFound
Bases: nova.exception.SecurityGroupNotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.QuotaError
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.Invalid
Bases: nova.exception.Invalid
Bases: nova.exception.NovaException
Bases: nova.exception.NovaException
Bases: nova.exception.NotFound
Bases: nova.exception.NotFound
Bases: nova.exception.Invalid
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.
Base classes for our unit tests.
Allows overriding of flags for use of fakes, and some black magic for inline callbacks.
Bases: object
Bases: fixtures.fixture.Fixture
Any addition steps that are needed outside of the migrations.
Bases: fixtures.fixture.Fixture
Deal with code around mox and stubout as a fixture.
Bases: fixtures.fixture.Fixture
Replace a module with a fake module.
Bases: fixtures.fixture.Fixture
Run a service as a test fixture.
Bases: testtools.testcase.TestCase
Test case base class for all unit tests.
Override flag variables for a test.
Run before each test method to initialize test environment.
Bases: exceptions.Exception
Bases: fixtures.fixture.Fixture
Fixture to start and remove time override.
Utilities and helper functions.
Bases: nova.utils.LoopingCallBase
A looping call which happens sleeps until the next known event.
The function called should return how long to sleep for before being called again.
Bases: object
Class to wrap another and translate the ClientExceptions raised by its function calls to the actual ones
Bases: nova.utils.LoopingCallBase
A looping call which happens at a fixed interval.
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: xml.sax.expatreader.ExpatParser
An expat parser which disables DTD’s and entities by default.
Bases: object
Provides a mechanism to facilitate rolling back a series of actions when an exception is raised.
Rollback a series of actions then re-raise the exception.
Note
(sirp) This should only be called within an exception handler.
Convert a string representation of a bool into a bool value.
Checks that obj is of type cls, and lets PyLint infer types.
Check the length of specified string :param value: the value of the string :param name: the name of the string :param min_length: the min_length of the string :param max_length: the max_length of the string
Convert a value or list into a list of dicts.
delete a file, but ignore file not found error.
Return a dict describing how to change orig to new. The keys correspond to values that have changed; the value will be a list of one or two elements. The first element of the list will be either ‘+’ or ‘-‘, indicating whether the key was updated or deleted; if the key was updated, the list will contain a second element, giving the updated value.
Helper method to execute command with optional retry.
If you add a run_as_root=True command, don’t forget to add the corresponding filter to etc/nova/rootwrap.d !
Parameters: |
|
---|---|
Raises: |
|
Returns: | a tuple, (stdout, stderr) from the spawned process, or None if the command fails. |
Open file
see built-in file() documentation for more details
Recursively flatten a nested dictionary.
Generate an Ethernet MAC address.
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!)
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 the IP version of a network (IPv4 or IPv6). Raises AddrFormatError if invalid network.
Get the method at the bottom of a stack of decorators.
This is a simplified inspect.getcallargs (2.7+).
It should be replaced when python >= 2.7 is standard.
Generate a hash for the contents of a file.
Check if a value looks like an int.
Check if the provided string is a valid bool string or not.
Check if the provided ipv4 or ipv6 address is a valid CIDR address or not
Verify that address represents a valid IPv4 address.
Return num bytes from the end of the file, and remaining byte count.
Parameters: |
|
---|
:returns (data, remaining)
This method gives you the most recently completed audit period.
Return a path to a particular device.
>>> make_dev_path('xvdc')
/dev/xvdc
>>> make_dev_path('xvdc', 1)
/dev/xvdc1
Return a dict in which the dictionaries keys are mapped to new keys.
Format a file or block device
Parameters: |
|
---|
If the Flags.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:
‘nova.api.ec2.cloud:nova.openstack.common.notifier.api.notify_decorator’
Parameters of the decorator is as follows. (See nova.openstack.common.notifier.api.notify_decorator)
name - name of the function function - object of the function
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.
Return two dicts, one with keys the other with everything else.
Read from a file if it has been modified.
Parameters: |
|
---|---|
Returns: | data from file |
Secure helper to read file as root.
Protect code that wants to operate on PATH atomically. Any exception will cause PATH to be removed.
Parse an XML string using minidom safely.
Return a hostname which conforms to RFC-952 and RFC-1123 specs.
Return a dict that only contains a subset of keys.
Temporarily chown a path.
Params owner_uid: | |
---|---|
UID of temporary owner (defaults to current user) |
Temporarily set the attr on a particular object to a given value then revert when finished.
One use of this is to temporarily set the read_deleted flag on a context object:
- with temporary_mutation(context, read_deleted=”yes”):
- do_something_that_needed_deleted_objects()
Decorator that logs how long a particular function took to execute.
Try to turn a string into a number of bytes. Looks at the last characters of the text to determine what conversion is needed to turn the input text into a byte number.
Supports: B/b, K/k, M/m, G/g, T/t (or the same with b/B on the end)
Local total_seconds implementation for compatibility with python 2.6.
A wrapper around execute() to more easily handle warnings and errors.
Returns an (out, err) tuple of strings containing the output of the command’s stdout and stderr. If ‘err’ is not empty then the command can be considered to have failed.
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.
Client packet (14 bytes):
0 1 8 9 13
+-+--------+-----+
|x| cli_id |?????|
+-+--------+-----+
x = packet identifier 0x38
cli_id = 64 bit identifier
? = unknown, probably flags/padding
Server packet (26 bytes):
0 1 8 9 13 14 21 2225
+-+--------+-----+--------+----+
|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
Walk class hierarchy, yielding most derived classes first.
Escapes a string so it is valid within XML or XHTML.
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.
Returns: | None |
---|
Stop this server.
This is not a very nice action, as currently the method by which a server is stopped is by killing its eventlet.
Returns: | None |
---|
Block, until the server has stopped.
Waits on the server’s eventlet to finish, then returns.
Returns: | None |
---|