NOVA Libraries

The crypto Module

Wrappers around standard crypto, including root and intermediate CAs, SSH keypairs 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_ip='127.0.0.1', region='nova', access_key='admin', secret_key='admin', **kwargs)

Bases: object

connection_for(username, **kwargs)
Returns a boto ec2 connection for the given username.
create_user(username)
creates a new user, returning the userinfo object with access/secret
delete_user(username)
deletes a user
get_hosts()
get_user(name)
grab a single user by name
get_users()
grabs the list of all users
get_zip(username)
returns the content of a zip file containing novarc and access credentials.
has_user(username)
determine if user exists
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)

The datastore Module

Datastore:

MAKE Sure that ReDIS is running, and your flags are set properly, before trying to run this.

class nova.datastore.BasicModel(*args, **kwargs)

Bases: object

All Redis-backed data derives from this class.

You MUST specify an identifier() property that returns a unique string per instance.

You MUST have an initializer that takes a single argument that is a value returned by identifier() to load a new class with.

You may want to specify a dictionary for default_state().

You may also specify override_type at the class left to use a key other than __class__.__name__.

You override save and destroy calls to automatically build and destroy associations.

add_associated_model_to_its_set(my_type, my_id)
add_to_index(*args, **kwargs)
classmethod all(*args, **kwargs)
associate_with(*args, **kwargs)
classmethod associated_to(*args, **kwargs)
copy()
default_state()
You probably want to define this in your subclass
destroy(*args, **kwargs)
get(item, default)
identifier
You DEFINITELY want to define this in your subclass
is_new_record()
keys()
classmethod lookup(identifier)
remove_from_index(*args, **kwargs)
save(*args, **kwargs)
setdefault(item, default)
unassociate_with(*args, **kwargs)
update(update_dict)
exception nova.datastore.ConnectionError(message=None)
Bases: nova.exception.Error
class nova.datastore.Redis

Bases: object

classmethod instance()
nova.datastore.absorb_connection_error(fn)

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.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
nova.exception.wrap_exception(f)

The flags Module

Package-level global flags are defined here, the rest are defined where they’re used.

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

receive(*args, **kw)
class nova.rpc.Connection(hostname=None, userid=None, password=None, virtual_host=None, port=None, **kwargs)

Bases: carrot.connection.BrokerConnection

classmethod instance()
classmethod recreate()
class nova.rpc.Consumer(connection, queue=None, exchange=None, routing_key=None, **kwargs)

Bases: carrot.messaging.Consumer

attachToTornado(io_inst=None)
attach_to_tornado(io_inst=None)
attach_to_twisted()
fetch(*args, **kwargs)
class nova.rpc.DirectConsumer(connection=None, msg_id=None)
Bases: nova.rpc.Consumer
class nova.rpc.DirectPublisher(connection=None, msg_id=None)
Bases: nova.rpc.Publisher
class nova.rpc.Publisher(connection, exchange=None, routing_key=None, **kwargs)
Bases: carrot.messaging.Publisher
class nova.rpc.TopicConsumer(connection=None, topic='broadcast')
Bases: nova.rpc.Consumer
class nova.rpc.TopicPublisher(connection=None, topic='broadcast')
Bases: nova.rpc.Publisher
nova.rpc.call(topic, msg)
nova.rpc.cast(topic, msg)
nova.rpc.generic_response(message_data, message)
nova.rpc.msg_reply(msg_id, reply)
nova.rpc.send_message(topic, message, wait=True)

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

run(result=None)
setUp()
set_up()
tearDown()
tear_down()
class nova.test.TrialTestCase(methodName='runTest')

Bases: twisted.trial.unittest.TestCase

flags(**kw)
reset_flags()
setUp()
tearDown()
nova.test.skip_if_fake(f)

The utils Module

System-level utilities and helper functions.

nova.utils.abspath(s)
nova.utils.debug(arg)
nova.utils.default_flagfile(filename='nova.conf')
nova.utils.execute(cmd, input=None, addl_env=None)
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.isotime(at=None)
nova.utils.last_octet(address)
nova.utils.runthis(prompt, cmd)