NOVA Libraries
The crypto Module
Wrappers around standard crypto, including root and intermediate CAs,
SSH key_pairs and x509 certificates.
-
nova.crypto.ca_path(project_id)
-
nova.crypto.compute_md5(fp)
@type fp: file
@param fp: File pointer to the file to MD5 hash. The file pointer will be
reset to the beginning of the file before the method returns.
@rtype: tuple
@return: the hex digest version of the MD5 hash
-
nova.crypto.fetch_ca(project_id=None, chain=True)
-
nova.crypto.generate_key_pair(bits=1024)
-
nova.crypto.generate_x509_cert(subject, bits=1024)
-
nova.crypto.mkcacert(subject='nova', years=1)
-
nova.crypto.mkreq(bits, subject='foo', ca=0)
-
nova.crypto.sign_csr(csr_text, intermediate=None)
-
nova.crypto.ssl_pub_to_ssh_pub(ssl_public_key, name='root', suffix='nova')
The adminclient Module
Nova User API client library.
-
class nova.adminclient.HostInfo(connection=None)
Bases: object
- Information about a Nova Host, as parsed through SAX:
- Disk stats
Running Instances
Memory stats
CPU stats
Network address info
Firewall info
Bridge and devices
-
endElement(name, value, connection)
-
startElement(name, attrs, connection)
-
class nova.adminclient.NovaAdminClient(clc_url='http://127.0.0.1:8773', region='nova', access_key='admin', secret_key='admin', **kwargs)
Bases: object
-
add_project_member(user, project)
- Adds a user to a project.
-
add_user_role(user, role, project=None)
- Add a role to a user either globally or for a specific project.
-
connection_for(username, project, clc_url=None, region=None, **kwargs)
- Returns a boto ec2 connection for the given username.
-
create_project(projectname, manager_user, description=None, member_users=None)
- Creates a new project.
-
create_user(username)
- creates a new user, returning the userinfo object with access/secret
-
delete_project(projectname)
- Permanently deletes the specified project.
-
delete_user(username)
- deletes a user
-
get_hosts()
-
get_project(name)
- Returns a single project with the specified name.
-
get_project_members(name)
- Returns a list of members of a project.
-
get_projects(user=None)
- Returns a list of all projects.
-
get_roles(project_roles=True)
- Returns a list of available roles.
-
get_user(name)
- grab a single user by name
-
get_user_roles(user, project=None)
- Returns a list of roles for the given user.
Omitting project will return any global roles that the user has.
Specifying project will return only project specific roles.
-
get_users()
- grabs the list of all users
-
get_zip(user, project)
- Returns the content of a zip file containing novarc and access credentials.
-
has_user(username)
- determine if user exists
-
modify_project_member(user, project, operation='add')
- Adds or removes a user from a project.
-
modify_user_role(user, role, project=None, operation='add', **kwargs)
- Add or remove a role for a user and project.
-
remove_project_member(user, project)
- Removes a user from a project.
-
remove_user_role(user, role, project=None)
- Remove a role from a user either globally or for a specific project.
-
split_clc_url(clc_url)
- Splits a cloud controller endpoint url.
-
class nova.adminclient.ProjectInfo(connection=None)
Bases: object
Information about a Nova project, as parsed through SAX
Fields include:
projectname
description
projectManagerId
memberIds
-
endElement(name, value, connection)
-
startElement(name, attrs, connection)
-
class nova.adminclient.ProjectMember(connection=None)
Bases: object
Information about a Nova project member, as parsed through SAX.
Fields include:
memberId
-
endElement(name, value, connection)
-
startElement(name, attrs, connection)
-
class nova.adminclient.UserInfo(connection=None, username=None, endpoint=None)
Bases: object
Information about a Nova user, as parsed through SAX
fields include:
username
accesskey
secretkey
- and an optional field containing a zip with X509 cert & rc
- file
-
endElement(name, value, connection)
-
startElement(name, attrs, connection)
-
class nova.adminclient.UserRole(connection=None)
Bases: object
Information about a Nova user’s role, as parsed through SAX.
Fields include:
role
-
endElement(name, value, connection)
-
startElement(name, attrs, connection)
The datastore Module
Datastore:
MAKE Sure that ReDIS is running, and your flags are set properly,
before trying to run this.
-
class nova.datastore.Redis
Bases: object
-
classmethod instance()
The exception Module
Nova base exception handling, including decorator for re-raising
Nova-type exceptions. SHOULD include dedicated exception logging.
-
exception nova.exception.ApiError(message='Unknown', code='Unknown')
- Bases: nova.exception.Error
-
exception nova.exception.Duplicate(message=None)
- Bases: nova.exception.Error
-
exception nova.exception.Error(message=None)
- Bases: exceptions.Exception
-
exception nova.exception.Invalid(message=None)
- Bases: nova.exception.Error
-
exception nova.exception.NotAuthorized(message=None)
- Bases: nova.exception.Error
-
exception nova.exception.NotEmpty(message=None)
- Bases: nova.exception.Error
-
exception nova.exception.NotFound(message=None)
- Bases: nova.exception.Error
-
exception nova.exception.ProcessExecutionError(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)
- Bases: exceptions.IOError
-
nova.exception.wrap_exception(f)
The flags Module
Package-level global flags are defined here, the rest are defined
where they’re used.
-
nova.flags.DECLARE(name, module_string, flag_values=<nova.flags.FlagValues instance at 0x900aecc>)
-
nova.flags.DEFINE(*args, **kw)
-
nova.flags.DEFINE_bool(*args, **kw)
-
nova.flags.DEFINE_boolean(*args, **kw)
-
nova.flags.DEFINE_enum(*args, **kw)
-
nova.flags.DEFINE_float(*args, **kw)
-
nova.flags.DEFINE_integer(*args, **kw)
-
nova.flags.DEFINE_list(*args, **kw)
-
nova.flags.DEFINE_multi_int(*args, **kw)
-
nova.flags.DEFINE_multistring(*args, **kw)
-
nova.flags.DEFINE_spaceseplist(*args, **kw)
-
nova.flags.DEFINE_string(*args, **kw)
-
class nova.flags.FlagValues
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.
-
ClearDirty()
-
IsDirty(name)
-
ParseNewFlags()
-
SetDirty(name)
- Mark a flag as dirty so that accessing it will case a reparse.
-
WasAlreadyParsed()
The rpc Module
AMQP-based RPC. Queues have consumers and publishers.
No fan-out support yet.
-
class nova.rpc.AdapterConsumer(connection=None, topic='broadcast', proxy=None)
Bases: nova.rpc.TopicConsumer
Calls methods on a proxy object based on method and args
-
receive(*args, **kw)
-
class nova.rpc.Connection(hostname=None, userid=None, password=None, virtual_host=None, port=None, **kwargs)
Bases: carrot.connection.BrokerConnection
Connection instance object
-
classmethod instance(new=False)
- Returns the instance
-
classmethod recreate()
Recreates the connection instance
This is necessary to recover from some network errors/disconnects
-
class nova.rpc.Consumer(*args, **kwargs)
Bases: carrot.messaging.Consumer
Consumer base class
Contains methods for connecting the fetch method to async loops
-
attach_to_twisted()
- Attach a callback to twisted that fires 10 times a second
-
fetch(no_ack=None, auto_ack=None, enable_callbacks=False)
- Wraps the parent fetch with some logic for failed connections
-
class nova.rpc.DirectConsumer(connection=None, msg_id=None)
Bases: nova.rpc.Consumer
Consumes messages directly on a channel specified by msg_id
-
class nova.rpc.DirectPublisher(connection=None, msg_id=None)
Bases: nova.rpc.Publisher
Publishes messages directly on a channel specified by msg_id
-
class nova.rpc.Publisher(connection, exchange=None, routing_key=None, **kwargs)
Bases: carrot.messaging.Publisher
Publisher base class
-
exception nova.rpc.RemoteError(exc_type, value, traceback)
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.
-
class nova.rpc.TopicConsumer(connection=None, topic='broadcast')
Bases: nova.rpc.Consumer
Consumes messages on a specific topic
-
class nova.rpc.TopicPublisher(connection=None, topic='broadcast')
Bases: nova.rpc.Publisher
Publishes messages on a specific topic
-
nova.rpc.call(topic, msg)
- Sends a message on a topic and wait for a response
-
nova.rpc.call_twisted(topic, msg)
- Sends a message on a topic and wait for a response
-
nova.rpc.cast(topic, msg)
- Sends a message on a topic without waiting for a response
-
nova.rpc.generic_response(message_data, message)
- Logs a result and exits
-
nova.rpc.msg_reply(msg_id, reply=None, failure=None)
Sends a reply or an error on the channel signified by msg_id
failure should be a twisted failure object
-
nova.rpc.send_message(topic, message, wait=True)
- Sends a message for testing
The server Module
The test Module
Base classes for our unit tests.
Allows overriding of flags for use of fakes,
and some black magic for inline callbacks.
-
class nova.test.BaseTestCase(methodName='runTest')
Bases: nova.test.TrialTestCase
Base test case class for all unit tests.
DEPRECATED: This is being removed once Tornado is gone, use TrialTestCase.
-
run(result=None)
- Runs the test case
-
setUp()
- Run before each test method to initialize test environment
-
tearDown()
- Runs after each test method to finalize/tear down test environment
-
class nova.test.TrialTestCase(methodName='runTest')
Bases: twisted.trial.unittest.TestCase
Test case base class for all unit tests
-
flags(**kw)
- Override flag variables for a test
-
reset_flags()
- Resets all flag variables for the test. Runs after each test
-
run(result=None)
-
setUp()
- Run before each test method to initialize test environment
-
tearDown()
- Runs after each test method to finalize/tear down test environment
-
nova.test.skip_if_fake(func)
- Decorator that skips a test if running in fake mode
The utils Module
System-level utilities and helper functions.
-
class nova.utils.LazyPluggable(pivot, **backends)
Bases: object
A pluggable backend loaded lazily based on some value.
-
nova.utils.abspath(s)
-
nova.utils.debug(arg)
-
nova.utils.default_flagfile(filename='nova.conf')
-
nova.utils.deferredToThread(f)
-
nova.utils.execute(cmd, process_input=None, addl_env=None, check_exit_code=True)
-
nova.utils.fetchfile(url, target)
-
nova.utils.generate_mac()
-
nova.utils.generate_uid(topic, size=8)
-
nova.utils.get_my_ip()
- Returns the actual ip of the local machine.
-
nova.utils.import_class(import_str)
- Returns a class from a string including module and class
-
nova.utils.import_object(import_str)
- Returns an object including a module or module and class
-
nova.utils.isotime(at=None)
-
nova.utils.last_octet(address)
-
nova.utils.parse_isotime(timestr)
-
nova.utils.runthis(prompt, cmd, check_exit_code=True)