Table Of Contents

Previous topic

Fake Drivers

Next topic

Cloudpipe – Per Project Vpns

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

Common and Misc Libraries

Libraries common throughout Nova or just ones that haven’t been categorized very well yet.

The nova.adminclient Module

The nova.context Module

RequestContext: context for requests that persist through all of nova.

class nova.context.RequestContext(user_id, project_id, is_admin=None, read_deleted=False, roles=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, strategy='noauth')

Bases: object

Security context and request information.

Represents the user taking a given action within the system.

RequestContext.elevated(read_deleted=None)

Return a version of this context with admin flag set.

classmethod RequestContext.from_dict(values)
RequestContext.to_dict()
nova.context.get_admin_context(read_deleted=False)

The nova.exception Module

Nova base exception handling.

Includes decorator for re-raising Nova-type exceptions.

SHOULD include dedicated exception logging.

exception nova.exception.AccessKeyNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.AdminRequired(*args, **kwargs)

Bases: nova.exception.NotAuthorized

exception nova.exception.ApiError(message='Unknown', code=None)

Bases: nova.exception.Error

exception nova.exception.AuthTokenNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.CannotResizeToSameSize(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.CannotResizeToSmallerSize(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.CertificateNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ClassNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ComputeHostNotFound(*args, **kwargs)

Bases: nova.exception.HostNotFound

exception nova.exception.ComputeServiceUnavailable(**kwargs)

Bases: nova.exception.ServiceUnavailable

exception nova.exception.ConsoleNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ConsoleNotFoundForInstance(*args, **kwargs)

Bases: nova.exception.ConsoleNotFound

exception nova.exception.ConsoleNotFoundInPoolForInstance(*args, **kwargs)

Bases: nova.exception.ConsoleNotFound

exception nova.exception.ConsolePoolNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ConsolePoolNotFoundForHostType(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.DBError(inner_exception=None)

Bases: nova.exception.Error

Wraps an implementation specific exception.

exception nova.exception.DatastoreNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.DestinationDiskExists(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.DestinationHypervisorTooOld(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.DiskNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.Duplicate(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.Error(message=None)

Bases: exceptions.Exception

exception nova.exception.ExportDeviceNotFoundForVolume(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FileNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FixedIpAlreadyInUse(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.FixedIpInvalid(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.FixedIpNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FixedIpNotFoundForAddress(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForHost(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForInstance(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForNetwork(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForNetworkHost(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForSpecificInstance(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FixedIpNotFoundForVirtualInterface(*args, **kwargs)

Bases: nova.exception.FixedIpNotFound

exception nova.exception.FlagNotSet(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FlavorNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FloatingIpAlreadyInUse(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.FloatingIpNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.FloatingIpNotFoundForAddress(*args, **kwargs)

Bases: nova.exception.FloatingIpNotFound

exception nova.exception.FloatingIpNotFoundForHost(*args, **kwargs)

Bases: nova.exception.FloatingIpNotFound

exception nova.exception.FloatingIpNotFoundForProject(*args, **kwargs)

Bases: nova.exception.FloatingIpNotFound

exception nova.exception.GlobalRoleNotAllowed(**kwargs)

Bases: nova.exception.NotAllowed

exception nova.exception.HostBinaryNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.HostNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ISCSITargetNotFoundForVolume(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ImageNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ImagePaginationFailed(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.ImageRotationNotAllowed(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.ImageTooLarge(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.ImageUnacceptable(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.InstanceMetadataNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.InstanceNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.InstanceNotInRescueMode(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceNotRunning(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceNotSuspended(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceRebootFailure(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceResumeFailure(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceSuspendFailure(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InstanceTypeExtraSpecsNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.InstanceTypeNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.InstanceTypeNotFoundByName(*args, **kwargs)

Bases: nova.exception.InstanceTypeNotFound

exception nova.exception.InstanceUnacceptable(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.Invalid(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.InvalidCPUInfo(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidCidr(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidContentType(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidDevicePath(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidDiskFormat(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidEc2Id(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidHypervisorType(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidImageRef(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidInput(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidInstanceType(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidIpProtocol(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidParameterValue(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidPortRange(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidSharedStorage(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.InvalidSignature(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidVLANPortGroup(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidVLANTag(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.InvalidVolumeType(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.KernelNotFoundForImage(*args, **kwargs)

Bases: nova.exception.ImageNotFound

exception nova.exception.KeyPairExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.KeypairNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.LDAPGroupExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.LDAPGroupMembershipNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.LDAPGroupNotFound(*args, **kwargs)

Bases: nova.exception.LDAPObjectNotFound

exception nova.exception.LDAPMembershipExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.LDAPObjectNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.LDAPUserExists(**kwargs)

Bases: nova.exception.UserExists

exception nova.exception.LDAPUserNotFound(*args, **kwargs)

Bases: nova.exception.LDAPObjectNotFound

exception nova.exception.ListingImageRefsNotSupported(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.MalformedRequestBody(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.MigrationError(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.MigrationNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.MigrationNotFoundByStatus(*args, **kwargs)

Bases: nova.exception.MigrationNotFound

exception nova.exception.NetworkAdapterNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NetworkHostNotSet(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NetworkNotCreated(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NetworkNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NetworkNotFoundForBridge(*args, **kwargs)

Bases: nova.exception.NetworkNotFound

exception nova.exception.NetworkNotFoundForCidr(*args, **kwargs)

Bases: nova.exception.NetworkNotFound

exception nova.exception.NetworkNotFoundForInstance(*args, **kwargs)

Bases: nova.exception.NetworkNotFound

exception nova.exception.NetworkNotFoundForProject(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NetworkNotFoundForUUID(*args, **kwargs)

Bases: nova.exception.NetworkNotFound

exception nova.exception.NoFilesFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NoFixedIpsDefined(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NoFloatingIpsDefined(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NoInstanceTypesFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NoMoreFixedIps(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NoMoreFloatingIps(*args, **kwargs)

Bases: nova.exception.FloatingIpNotFound

exception nova.exception.NoNetworksFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NoVolumeTypesFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.NotAllowed(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NotAuthorized(*args, **kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NotFound(*args, **kwargs)

Bases: nova.exception.NovaException

exception nova.exception.NovaException(**kwargs)

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.

exception nova.exception.PasteAppNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.PasteConfigNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ProcessExecutionError(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)

Bases: exceptions.IOError

exception nova.exception.ProjectExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.ProjectMembershipNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ProjectNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ProjectQuotaNotFound(*args, **kwargs)

Bases: nova.exception.QuotaNotFound

exception nova.exception.QuotaNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.RebuildRequiresActiveInstance(message=None)

Bases: nova.exception.Error

exception nova.exception.RotationRequiredForBackup(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.SchedulerCostFunctionNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SchedulerHostFilterNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SchedulerWeightFlagNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SecurityGroupExistsForInstance(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.SecurityGroupNotExistsForInstance(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.SecurityGroupNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SecurityGroupNotFoundForProject(*args, **kwargs)

Bases: nova.exception.SecurityGroupNotFound

exception nova.exception.SecurityGroupNotFoundForRule(*args, **kwargs)

Bases: nova.exception.SecurityGroupNotFound

exception nova.exception.ServiceNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ServiceUnavailable(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.SnapshotNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SourceHostUnavailable(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.StorageRepositoryNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.SwitchNotFoundForNetworkAdapter(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.UnableToMigrateToSelf(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.UserExists(**kwargs)

Bases: nova.exception.Duplicate

exception nova.exception.UserNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.UserRoleNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VSANovaAccessParamNotFound(**kwargs)

Bases: nova.exception.Invalid

exception nova.exception.VirtualInterfaceCreateException(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.VirtualInterfaceMacAddressException(**kwargs)

Bases: nova.exception.NovaException

exception nova.exception.VirtualStorageArrayNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VirtualStorageArrayNotFoundByName(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VolumeIsBusy(message=None)

Bases: nova.exception.Error

exception nova.exception.VolumeMetadataNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VolumeNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VolumeNotFoundForInstance(*args, **kwargs)

Bases: nova.exception.VolumeNotFound

exception nova.exception.VolumeServiceUnavailable(**kwargs)

Bases: nova.exception.ServiceUnavailable

exception nova.exception.VolumeTypeExtraSpecsNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VolumeTypeNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.VolumeTypeNotFoundByName(*args, **kwargs)

Bases: nova.exception.VolumeTypeNotFound

exception nova.exception.ZoneNotFound(*args, **kwargs)

Bases: nova.exception.NotFound

exception nova.exception.ZoneRequestError(message=None)

Bases: nova.exception.Error

nova.exception.wrap_db_error(f)
nova.exception.wrap_exception(notifier=None, publisher_id=None, event_type=None, level=None)

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.

The nova.flags Module

Command-line flag library.

Wraps gflags.

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 0xa9afeac>)
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_flag(*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(extra_context=None)

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.

FlagValues.ClearDirty()
FlagValues.IsDirty(name)
FlagValues.ParseNewFlags()
FlagValues.Reset()
FlagValues.SetDirty(name)

Mark a flag as dirty so that accessing it will case a reparse.

FlagValues.WasAlreadyParsed()
class nova.flags.StrWrapper(context_objs)

Bases: object

Wrapper around FlagValues objects.

Wraps FlagValues objects for string.Template so that we’re sure to return strings.

The nova.process Module

The nova.rpc Module

nova.rpc.call(context, topic, msg)
nova.rpc.cast(context, topic, msg)
nova.rpc.create_connection(new=True)
nova.rpc.fanout_cast(context, topic, msg)
nova.rpc.get_impl()

Delay import of rpc_backend until FLAGS are loaded.

nova.rpc.multicall(context, topic, msg)

The nova.server Module

The nova.test Module

The nova.utils Module

Utilities and helper functions.

class nova.utils.LazyPluggable(pivot, **backends)

Bases: object

A pluggable backend loaded lazily based on some value.

class nova.utils.LoopingCall(f=None, *args, **kw)

Bases: object

LoopingCall.start(interval, now=True)
LoopingCall.stop()
LoopingCall.wait()
exception nova.utils.LoopingCallDone(retvalue=True)

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()

nova.utils.abspath(s)
nova.utils.advance_time_delta(timedelta)

Advance overriden time using a datetime.timedelta.

nova.utils.advance_time_seconds(seconds)

Advance overriden time by seconds.

nova.utils.bool_from_str(val)

Convert a string representation of a bool into a bool value

nova.utils.check_isinstance(obj, cls)

Checks that obj is of type cls, and lets PyLint infer types.

nova.utils.clear_time_override()

Remove the overridden time.

nova.utils.convert_to_list_dict(lst, label)

Convert a value or list into a list of dicts

nova.utils.debug(arg)
nova.utils.default_flagfile(filename='nova.conf', args=None)
nova.utils.dumps(value)
nova.utils.execute(*cmd, **kwargs)

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.
:delay_on_retry True | False. Defaults to True. If set to True, wait a
short amount of time before retrying.

: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

nova.utils.fetchfile(url, target)
nova.utils.flatten_dict(dict_, flattened=None)

Recursively flatten a nested dictionary.

nova.utils.gen_uuid()
nova.utils.generate_password(length=20, symbols='23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')

Generate a random password from the supplied symbols.

Believed to be reasonably secure (with a reasonable password length!)

nova.utils.generate_uid(topic, size=8)
nova.utils.get_from_path(items, path)

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.

nova.utils.get_my_linklocal(interface)
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.is_older_than(before, seconds)

Return True if before is older than seconds.

nova.utils.is_uuid_like(val)

For our purposes, a UUID is a string in canoical form:

aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa

nova.utils.is_valid_ipv4(address)

valid the address strictly as per format xxx.xxx.xxx.xxx. where xxx is a value between 0 and 255.

nova.utils.isotime(at=None)

Returns iso formatted utcnow.

nova.utils.last_octet(address)
nova.utils.loads(s)
nova.utils.map_dict_keys(dict_, key_map)

Return a dict in which the dictionaries keys are mapped to new keys.

nova.utils.monkey_patch()

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

nova.utils.novadir()
nova.utils.parse_isotime(timestr)

Turn an iso formatted time back into a datetime.

nova.utils.parse_mailmap(mailmap='.mailmap')
nova.utils.parse_server_string(server_str)

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.

nova.utils.parse_strtime(timestr, fmt='%Y-%m-%dT%H:%M:%S.%f')

Turn a formatted time back into a datetime.

nova.utils.partition_dict(dict_, keys)

Return two dicts, one with keys the other with everything else.

nova.utils.runthis(prompt, *cmd, **kwargs)
nova.utils.set_time_override(override_time=datetime.datetime(2011, 10, 17, 15, 26, 27, 397198))

Override utils.utcnow to return a constant time.

nova.utils.ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True)
nova.utils.str_dict_replace(s, mapping)
nova.utils.strtime(at=None, fmt='%Y-%m-%dT%H:%M:%S.%f')

Returns formatted utcnow.

nova.utils.subset_dict(dict_, keys)

Return a dict that only contains a subset of keys.

nova.utils.synchronized(name, external=False)

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.

nova.utils.to_primitive(value, convert_instances=False, level=0)

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.

nova.utils.usage_from_instance(instance_ref, **kw)
nova.utils.utcnow()

Overridable version of utils.utcnow.

nova.utils.utcnow_ts()

Timestamp version of our utcnow function.

nova.utils.utf8(value)

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

nova.utils.vpn_ping(address, port, timeout=0.05, session_id=None)

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

nova.utils.xhtml_escape(value)

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

The nova.validate Module

The nova.wsgi Module

Tests

The declare_flags Module

The fake_flags Module

The flags_unittest Module

The process_unittest Module

The real_flags Module

The rpc_unittest Module

The runtime_flags Module

The validator_unittest Module