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 RequestContext(user_id, project_id, is_admin=None, read_deleted='no', roles=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, user_name=None, project_name=None, service_catalog=None, **kwargs)

Bases: object

Security context and request information.

Represents the user taking a given action within the system.

RequestContext.elevated(read_deleted=None, overwrite=False)

Return a version of this context with admin flag set.

classmethod RequestContext.from_dict(values)
RequestContext.read_deleted
RequestContext.to_dict()
RequestContext.update_store()
generate_request_id()
get_admin_context(read_deleted='no')

The nova.exception Module

Nova base exception handling.

Includes decorator for re-raising Nova-type exceptions.

SHOULD include dedicated exception logging.

exception AccessKeyNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

AccessKeyNotFound.message = 'Access Key %(access_key)s could not be found.'
exception AdminRequired(message=None, **kwargs)

Bases: nova.exception.NotAuthorized

AdminRequired.message = 'User does not have admin privileges'
exception AggregateError(message=None, **kwargs)

Bases: nova.exception.NovaException

AggregateError.message = "Aggregate %(aggregate_id)s: action '%(action)s' caused an error: %(reason)s."
exception AggregateHostConflict(message=None, **kwargs)

Bases: nova.exception.Duplicate

AggregateHostConflict.message = 'Host %(host)s already member of another aggregate.'
exception AggregateHostExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

AggregateHostExists.message = 'Aggregate %(aggregate_id)s already has host %(host)s.'
exception AggregateHostNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

AggregateHostNotFound.message = 'Aggregate %(aggregate_id)s has no host %(host)s.'
exception AggregateMetadataNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

AggregateMetadataNotFound.message = 'Aggregate %(aggregate_id)s has no metadata with key %(metadata_key)s.'
exception AggregateNameExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

AggregateNameExists.message = 'Aggregate %(aggregate_name)s already exists.'
exception AggregateNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

AggregateNotFound.message = 'Aggregate %(aggregate_id)s could not be found.'
exception AuthTokenNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

AuthTokenNotFound.message = 'Auth token %(token)s could not be found.'
exception CannotResizeToSameSize(message=None, **kwargs)

Bases: nova.exception.NovaException

CannotResizeToSameSize.message = 'When resizing, instances must change size!'
exception CertificateNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

CertificateNotFound.message = 'Certificate %(certificate_id)s not found.'
exception ClassNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ClassNotFound.message = 'Class %(class_name)s could not be found: %(exception)s'
exception ComputeHostNotFound(message=None, **kwargs)

Bases: nova.exception.HostNotFound

ComputeHostNotFound.message = 'Compute host %(host)s could not be found.'
exception ComputeServiceUnavailable(message=None, **kwargs)

Bases: nova.exception.ServiceUnavailable

ComputeServiceUnavailable.message = 'Compute service is unavailable at this time.'
exception ConfigNotFound(message=None, **kwargs)

Bases: nova.exception.NovaException

ConfigNotFound.message = 'Could not find config at %(path)s'
exception ConsoleNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ConsoleNotFound.message = 'Console %(console_id)s could not be found.'
exception ConsoleNotFoundForInstance(message=None, **kwargs)

Bases: nova.exception.ConsoleNotFound

ConsoleNotFoundForInstance.message = 'Console for instance %(instance_uuid)s could not be found.'
exception ConsoleNotFoundInPoolForInstance(message=None, **kwargs)

Bases: nova.exception.ConsoleNotFound

ConsoleNotFoundInPoolForInstance.message = 'Console for instance %(instance_uuid)s in pool %(pool_id)s could not be found.'
exception ConsolePoolNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ConsolePoolNotFound.message = 'Console pool %(pool_id)s could not be found.'
exception ConsolePoolNotFoundForHostType(message=None, **kwargs)

Bases: nova.exception.NotFound

ConsolePoolNotFoundForHostType.message = 'Console pool of type %(console_type)s for compute host %(compute_host)s on proxy host %(host)s not found.'
exception ConsoleTypeInvalid(message=None, **kwargs)

Bases: nova.exception.Invalid

ConsoleTypeInvalid.message = 'Invalid console type %(console_type)s '
exception ConstraintNotMet(message=None, **kwargs)

Bases: nova.exception.NovaException

ConstraintNotMet.code = 412
ConstraintNotMet.message = 'Constraint not met.'
exception ConvertedException(code=0, title='', explanation='')

Bases: webob.exc.WSGIHTTPException

exception CouldNotFetchImage(message=None, **kwargs)

Bases: nova.exception.NovaException

CouldNotFetchImage.message = 'Could not fetch image %(image_id)s'
exception CouldNotFetchMetrics(message=None, **kwargs)

Bases: nova.exception.NovaException

CouldNotFetchMetrics.message = 'Could not fetch bandwidth/cpu/disk metrics for this host.'
exception DBError(inner_exception=None)

Bases: nova.exception.NovaException

Wraps an implementation specific exception.

exception DatastoreNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

DatastoreNotFound.message = 'Could not find the datastore reference(s) which the VM uses.'
exception DecryptionFailure(message=None, **kwargs)

Bases: nova.exception.NovaException

DecryptionFailure.message = 'Failed to decrypt text'
exception DeprecatedConfig(message=None, **kwargs)

Bases: nova.exception.NovaException

DeprecatedConfig.message = 'Fatal call to deprecated config %(msg)'
exception DestinationDiskExists(message=None, **kwargs)

Bases: nova.exception.Invalid

DestinationDiskExists.message = 'The supplied disk path (%(path)s) already exists, it is expected not to exist.'
exception DestinationHostUnavailable(message=None, **kwargs)

Bases: nova.exception.Invalid

DestinationHostUnavailable.message = 'Destination compute host is unavailable at this time.'
exception DestinationHypervisorTooOld(message=None, **kwargs)

Bases: nova.exception.Invalid

DestinationHypervisorTooOld.message = 'The instance requires a newer hypervisor version than has been provided.'
exception DeviceIsBusy(message=None, **kwargs)

Bases: nova.exception.Invalid

DeviceIsBusy.message = 'The supplied device (%(device)s) is busy.'
exception DiskNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

DiskNotFound.message = 'No disk at %(location)s'
exception Duplicate(message=None, **kwargs)

Bases: nova.exception.NovaException

exception DuplicateSfVolumeNames(message=None, **kwargs)

Bases: nova.exception.Duplicate

DuplicateSfVolumeNames.message = 'Detected more than one volume with name %(vol_name)s'
exception DuplicateVlan(message=None, **kwargs)

Bases: nova.exception.Duplicate

DuplicateVlan.message = 'Detected existing vlan with id %(vlan)d'
exception EC2APIError(message=None, code=None)

Bases: nova.exception.NovaException

EC2APIError.message = 'Unknown'
exception FileNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

FileNotFound.message = 'File %(file_path)s could not be found.'
exception FixedIpAlreadyInUse(message=None, **kwargs)

Bases: nova.exception.NovaException

FixedIpAlreadyInUse.message = 'Fixed IP address %(address)s is already in use.'
exception FixedIpInvalid(message=None, **kwargs)

Bases: nova.exception.Invalid

FixedIpInvalid.message = 'Fixed IP address %(address)s is invalid.'
exception FixedIpNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

FixedIpNotFound.message = 'No fixed IP associated with id %(id)s.'
exception FixedIpNotFoundForAddress(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForAddress.message = 'Fixed ip not found for address %(address)s.'
exception FixedIpNotFoundForHost(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForHost.message = 'Host %(host)s has zero fixed ips.'
exception FixedIpNotFoundForInstance(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForInstance.message = 'Instance %(instance_id)s has zero fixed ips.'
exception FixedIpNotFoundForNetwork(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForNetwork.message = 'Fixed IP address (%(address)s) does not exist in network (%(network_uuid)s).'
exception FixedIpNotFoundForNetworkHost(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForNetworkHost.message = 'Network host %(host)s has zero fixed ips in network %(network_id)s.'
exception FixedIpNotFoundForSpecificInstance(message=None, **kwargs)

Bases: nova.exception.FixedIpNotFound

FixedIpNotFoundForSpecificInstance.message = "Instance %(instance_id)s doesn't have fixed ip '%(ip)s'."
exception FlavorNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

FlavorNotFound.message = 'Flavor %(flavor_id)s could not be found.'
exception FloatingIpAssociated(message=None, **kwargs)

Bases: nova.exception.NovaException

FloatingIpAssociated.message = 'Floating ip %(address)s is associated.'
exception FloatingIpDNSExists(message=None, **kwargs)

Bases: nova.exception.Invalid

FloatingIpDNSExists.message = 'The DNS entry %(name)s already exists in domain %(domain)s.'
exception FloatingIpLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

FloatingIpLimitExceeded.message = 'Maximum number of floating ips exceeded'
exception FloatingIpNotAssociated(message=None, **kwargs)

Bases: nova.exception.NovaException

FloatingIpNotAssociated.message = 'Floating ip %(address)s is not associated.'
exception FloatingIpNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

FloatingIpNotFound.message = 'Floating ip not found for id %(id)s.'
exception FloatingIpNotFoundForAddress(message=None, **kwargs)

Bases: nova.exception.FloatingIpNotFound

FloatingIpNotFoundForAddress.message = 'Floating ip not found for address %(address)s.'
exception FloatingIpNotFoundForHost(message=None, **kwargs)

Bases: nova.exception.FloatingIpNotFound

FloatingIpNotFoundForHost.message = 'Floating ip not found for host %(host)s.'
exception GlanceConnectionFailed(message=None, **kwargs)

Bases: nova.exception.NovaException

GlanceConnectionFailed.message = 'Connection to glance failed: %(reason)s'
exception GlobalRoleNotAllowed(message=None, **kwargs)

Bases: nova.exception.NotAllowed

GlobalRoleNotAllowed.message = 'Unable to use global role %(role_id)s'
exception HostBinaryNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

HostBinaryNotFound.message = 'Could not find binary %(binary)s on host %(host)s.'
exception HostNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

HostNotFound.message = 'Host %(host)s could not be found.'
exception ISCSITargetNotFoundForVolume(message=None, **kwargs)

Bases: nova.exception.NotFound

ISCSITargetNotFoundForVolume.message = 'No target id found for volume %(volume_id)s.'
exception ImageNotAuthorized(message=None, **kwargs)

Bases: nova.exception.NovaException

ImageNotAuthorized.message = 'Not authorized for image %(image_id)s.'
exception ImageNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ImageNotFound.message = 'Image %(image_id)s could not be found.'
exception ImagePaginationFailed(message=None, **kwargs)

Bases: nova.exception.NovaException

ImagePaginationFailed.message = 'Failed to paginate through images from image service'
exception ImageRotationNotAllowed(message=None, **kwargs)

Bases: nova.exception.NovaException

ImageRotationNotAllowed.message = 'Rotation is not allowed for snapshots'
exception ImageTooLarge(message=None, **kwargs)

Bases: nova.exception.NovaException

ImageTooLarge.message = 'Image is larger than instance type allows'
exception ImageUnacceptable(message=None, **kwargs)

Bases: nova.exception.Invalid

ImageUnacceptable.message = 'Image %(image_id)s is unacceptable: %(reason)s'
exception InstanceExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

InstanceExists.message = 'Instance %(name)s already exists.'
exception InstanceInvalidState(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceInvalidState.message = 'Instance %(instance_uuid)s in %(attr)s %(state)s. Cannot %(method)s while the instance is in this state.'
exception InstanceMetadataNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

InstanceMetadataNotFound.message = 'Instance %(instance_uuid)s has no metadata with key %(metadata_key)s.'
exception InstanceNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

InstanceNotFound.message = 'Instance %(instance_id)s could not be found.'
exception InstanceNotInRescueMode(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceNotInRescueMode.message = 'Instance %(instance_id)s is not in rescue mode'
exception InstanceNotRunning(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceNotRunning.message = 'Instance %(instance_id)s is not running.'
exception InstanceNotSuspended(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceNotSuspended.message = 'Instance %(instance_id)s is not suspended.'
exception InstanceRebootFailure(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceRebootFailure.message = 'Failed to reboot instance: %(reason)s'
exception InstanceResumeFailure(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceResumeFailure.message = 'Failed to resume server: %(reason)s.'
exception InstanceSuspendFailure(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceSuspendFailure.message = 'Failed to suspend instance: %(reason)s'
exception InstanceSystemMetadataNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

InstanceSystemMetadataNotFound.message = 'Instance %(instance_uuid)s has no system metadata with key %(metadata_key)s.'
exception InstanceTerminationFailure(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceTerminationFailure.message = 'Failed to terminate instance: %(reason)s'
exception InstanceTypeCreateFailed(message=None, **kwargs)

Bases: nova.exception.NovaException

InstanceTypeCreateFailed.message = 'Unable to create instance type'
exception InstanceTypeDiskTooSmall(message=None, **kwargs)

Bases: nova.exception.NovaException

InstanceTypeDiskTooSmall.message = "Instance type's disk is too small for requested image."
exception InstanceTypeExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

InstanceTypeExists.message = 'Instance Type %(name)s already exists.'
exception InstanceTypeExtraSpecsNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

InstanceTypeExtraSpecsNotFound.message = 'Instance Type %(instance_type_id)s has no extra specs with key %(extra_specs_key)s.'
exception InstanceTypeMemoryTooSmall(message=None, **kwargs)

Bases: nova.exception.NovaException

InstanceTypeMemoryTooSmall.message = "Instance type's memory is too small for requested image."
exception InstanceTypeNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

InstanceTypeNotFound.message = 'Instance type %(instance_type_id)s could not be found.'
exception InstanceTypeNotFoundByName(message=None, **kwargs)

Bases: nova.exception.InstanceTypeNotFound

InstanceTypeNotFoundByName.message = 'Instance type with name %(instance_type_name)s could not be found.'
exception InstanceUnacceptable(message=None, **kwargs)

Bases: nova.exception.Invalid

InstanceUnacceptable.message = 'Instance %(instance_id)s is unacceptable: %(reason)s'
exception InsufficientFreeMemory(message=None, **kwargs)

Bases: nova.exception.NovaException

InsufficientFreeMemory.message = 'Insufficient free memory on compute node to start %(uuid)s.'
exception Invalid(message=None, **kwargs)

Bases: nova.exception.NovaException

Invalid.code = 400
Invalid.message = 'Unacceptable parameters.'
exception InvalidAggregateAction(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidAggregateAction.message = "Cannot perform action '%(action)s' on aggregate %(aggregate_id)s. Reason: %(reason)s."
exception InvalidCPUInfo(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidCPUInfo.message = 'Unacceptable CPU info: %(reason)s'
exception InvalidCidr(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidCidr.message = 'Invalid cidr %(cidr)s.'
exception InvalidContentType(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidContentType.message = 'Invalid content type %(content_type)s.'
exception InvalidDevicePath(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidDevicePath.message = 'The supplied device path (%(path)s) is invalid.'
exception InvalidDiskFormat(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidDiskFormat.message = 'Disk format %(disk_format)s is not acceptable'
exception InvalidEc2Id(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidEc2Id.message = 'Ec2 id %(ec2_id)s is unacceptable.'
exception InvalidGroup(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidGroup.message = 'Group not valid. Reason: %(reason)s'
exception InvalidHypervisorType(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidHypervisorType.message = 'The supplied hypervisor type of is invalid.'
exception InvalidImageRef(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidImageRef.message = 'Invalid image href %(image_href)s.'
exception InvalidInput(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidInput.message = 'Invalid input received: %(reason)s'
exception InvalidInstanceIDMalformed(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidInstanceIDMalformed.message = 'Invalid id: %(val)s (expecting "i-...").'
exception InvalidInstanceType(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidInstanceType.message = 'Invalid instance type %(instance_type)s.'
exception InvalidIpAddressError(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidIpAddressError.message = '%(address)s is not a valid IP v4/6 address.'
exception InvalidIpProtocol(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidIpProtocol.message = 'Invalid IP protocol %(protocol)s.'
exception InvalidKeypair(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidKeypair.message = 'Keypair data is invalid'
exception InvalidMetadata(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidMetadata.message = 'Invalid metadata: %(reason)s'
exception InvalidParameterValue(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidParameterValue.message = '%(err)s'
exception InvalidPortRange(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidPortRange.message = 'Invalid port range %(from_port)s:%(to_port)s. %(msg)s'
exception InvalidQuotaValue(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidQuotaValue.message = 'Change would make usage less than 0 for the following resources: %(unders)s'
exception InvalidRequest(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidRequest.message = 'The request is invalid.'
exception InvalidReservationExpiration(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidReservationExpiration.message = 'Invalid reservation expiration %(expire)s.'
exception InvalidSharedStorage(message=None, **kwargs)

Bases: nova.exception.NovaException

InvalidSharedStorage.message = '%(path)s is on shared storage: %(reason)s'
exception InvalidSignature(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidSignature.message = 'Invalid signature %(signature)s for user %(user)s.'
exception InvalidSnapshot(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidSnapshot.message = 'Invalid snapshot: %(reason)s'
exception InvalidUUID(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidUUID.message = 'Expected a uuid but received %(uuid).'
exception InvalidUnicodeParameter(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidUnicodeParameter.message = 'Invalid Parameter: Unicode is not supported by the current database.'
exception InvalidVLANPortGroup(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidVLANPortGroup.message = 'vSwitch which contains the port group %(bridge)s is not associated with the desired physical adapter. Expected vSwitch is %(expected)s, but the one associated is %(actual)s.'
exception InvalidVLANTag(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidVLANTag.message = 'VLAN tag is not appropriate for the port group %(bridge)s. Expected VLAN tag is %(tag)s, but the one associated with the port group is %(pgroup)s.'
exception InvalidVolume(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidVolume.message = 'Invalid volume: %(reason)s'
exception InvalidVolumeType(message=None, **kwargs)

Bases: nova.exception.Invalid

InvalidVolumeType.message = 'Invalid volume type: %(reason)s'
exception KernelNotFoundForImage(message=None, **kwargs)

Bases: nova.exception.ImageNotFound

KernelNotFoundForImage.message = 'Kernel not found for image %(image_id)s.'
exception KeyPairExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

KeyPairExists.message = 'Key pair %(key_name)s already exists.'
exception KeypairLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

KeypairLimitExceeded.message = 'Maximum number of key pairs exceeded'
exception KeypairNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

KeypairNotFound.message = 'Keypair %(name)s not found for user %(user_id)s'
exception LDAPGroupExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

LDAPGroupExists.message = 'LDAP group %(group)s already exists.'
exception LDAPGroupMembershipNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

LDAPGroupMembershipNotFound.message = 'LDAP user %(user_id)s is not a member of group %(group_id)s.'
exception LDAPGroupNotFound(message=None, **kwargs)

Bases: nova.exception.LDAPObjectNotFound

LDAPGroupNotFound.message = 'LDAP group %(group_id)s could not be found.'
exception LDAPMembershipExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

LDAPMembershipExists.message = 'User %(uid)s is already a member of the group %(group_dn)s'
exception LDAPObjectNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

LDAPObjectNotFound.message = 'LDAP object could not be found'
exception LDAPUserExists(message=None, **kwargs)

Bases: nova.exception.UserExists

LDAPUserExists.message = 'LDAP user %(user)s already exists.'
exception LDAPUserNotFound(message=None, **kwargs)

Bases: nova.exception.LDAPObjectNotFound

LDAPUserNotFound.message = 'LDAP user %(user_id)s could not be found.'
exception ListingImageRefsNotSupported(message=None, **kwargs)

Bases: nova.exception.Invalid

ListingImageRefsNotSupported.message = 'Some images have been stored via hrefs. This version of the api does not support displaying image hrefs.'
exception MalformedRequestBody(message=None, **kwargs)

Bases: nova.exception.NovaException

MalformedRequestBody.message = 'Malformed message body: %(reason)s'
exception MelangeConnectionFailed(message=None, **kwargs)

Bases: nova.exception.NovaException

MelangeConnectionFailed.message = 'Connection to melange failed: %(reason)s'
exception MetadataLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

MetadataLimitExceeded.message = 'Maximum number of metadata items exceeds %(allowed)d'
exception MigrationError(message=None, **kwargs)

Bases: nova.exception.NovaException

MigrationError.message = 'Migration error: %(reason)s'
exception MigrationNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

MigrationNotFound.message = 'Migration %(migration_id)s could not be found.'
exception MigrationNotFoundByStatus(message=None, **kwargs)

Bases: nova.exception.MigrationNotFound

MigrationNotFoundByStatus.message = 'Migration not found for instance %(instance_id)s with status %(status)s.'
exception NetworkAdapterNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NetworkAdapterNotFound.message = 'Network adapter %(adapter)s could not be found.'
exception NetworkBusy(message=None, **kwargs)

Bases: nova.exception.NovaException

NetworkBusy.message = 'Network %(network)s has active ports, cannot delete.'
exception NetworkHostNotSet(message=None, **kwargs)

Bases: nova.exception.NovaException

NetworkHostNotSet.message = 'Host is not set to the network (%(network_id)s).'
exception NetworkInUse(message=None, **kwargs)

Bases: nova.exception.NovaException

NetworkInUse.message = 'Network %(network_id)s is still in use.'
exception NetworkNotCreated(message=None, **kwargs)

Bases: nova.exception.NovaException

NetworkNotCreated.message = '%(req)s is required to create a network.'
exception NetworkNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NetworkNotFound.message = 'Network %(network_id)s could not be found.'
exception NetworkNotFoundForBridge(message=None, **kwargs)

Bases: nova.exception.NetworkNotFound

NetworkNotFoundForBridge.message = 'Network could not be found for bridge %(bridge)s'
exception NetworkNotFoundForCidr(message=None, **kwargs)

Bases: nova.exception.NetworkNotFound

NetworkNotFoundForCidr.message = 'Network could not be found with cidr %(cidr)s.'
exception NetworkNotFoundForInstance(message=None, **kwargs)

Bases: nova.exception.NetworkNotFound

NetworkNotFoundForInstance.message = 'Network could not be found for instance %(instance_id)s.'
exception NetworkNotFoundForProject(message=None, **kwargs)

Bases: nova.exception.NotFound

NetworkNotFoundForProject.message = 'Either Network uuid %(network_uuid)s is not present or is not assigned to the project %(project_id)s.'
exception NetworkNotFoundForUUID(message=None, **kwargs)

Bases: nova.exception.NetworkNotFound

NetworkNotFoundForUUID.message = 'Network could not be found for uuid %(uuid)s'
exception NoFilesFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NoFilesFound.message = 'Zero files could be found.'
exception NoFixedIpsDefined(message=None, **kwargs)

Bases: nova.exception.NotFound

NoFixedIpsDefined.message = 'Zero fixed ips could be found.'
exception NoFloatingIpInterface(message=None, **kwargs)

Bases: nova.exception.NotFound

NoFloatingIpInterface.message = 'Interface %(interface)s not found.'
exception NoFloatingIpsDefined(message=None, **kwargs)

Bases: nova.exception.NotFound

NoFloatingIpsDefined.message = 'Zero floating ips exist.'
exception NoInstanceTypesFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NoInstanceTypesFound.message = 'Zero instance types found.'
exception NoMoreFixedIps(message=None, **kwargs)

Bases: nova.exception.NovaException

NoMoreFixedIps.message = 'Zero fixed ips available.'
exception NoMoreFloatingIps(message=None, **kwargs)

Bases: nova.exception.FloatingIpNotFound

NoMoreFloatingIps.message = 'Zero floating ips available.'
exception NoNetworksFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NoNetworksFound.message = 'No networks defined.'
exception NoValidHost(message=None, **kwargs)

Bases: nova.exception.NovaException

NoValidHost.message = 'No valid host was found. %(reason)s'
exception NoVolumeTypesFound(message=None, **kwargs)

Bases: nova.exception.NotFound

NoVolumeTypesFound.message = 'Zero volume types found.'
exception NotAllowed(message=None, **kwargs)

Bases: nova.exception.NovaException

NotAllowed.message = 'Action not allowed.'
exception NotAuthorized(message=None, **kwargs)

Bases: nova.exception.NovaException

NotAuthorized.code = 403
NotAuthorized.message = 'Not authorized.'
exception NotFound(message=None, **kwargs)

Bases: nova.exception.NovaException

NotFound.code = 404
NotFound.message = 'Resource could not be found.'
exception NovaException(message=None, **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.

NovaException.message = 'An unknown exception occurred.'
exception OnsetFileContentLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

OnsetFileContentLimitExceeded.message = 'Personality file content too long'
exception OnsetFileLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

OnsetFileLimitExceeded.message = 'Personality file limit exceeded'
exception OnsetFilePathLimitExceeded(message=None, **kwargs)

Bases: nova.exception.QuotaError

OnsetFilePathLimitExceeded.message = 'Personality file path too long'
exception OverQuota(message=None, **kwargs)

Bases: nova.exception.NovaException

OverQuota.message = 'Quota exceeded for resources: %(overs)s'
exception PasteAppNotFound(message=None, **kwargs)

Bases: nova.exception.NovaException

PasteAppNotFound.message = "Could not load paste app '%(name)s' from %(path)s"
exception PolicyNotAuthorized(message=None, **kwargs)

Bases: nova.exception.NotAuthorized

PolicyNotAuthorized.message = "Policy doesn't allow %(action)s to be performed."
exception ProcessExecutionError(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)

Bases: exceptions.IOError

exception ProjectExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

ProjectExists.message = 'Project %(project)s already exists.'
exception ProjectMembershipNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ProjectMembershipNotFound.message = 'User %(user_id)s is not a member of project %(project_id)s.'
exception ProjectNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ProjectNotFound.message = 'Project %(project_id)s could not be found.'
exception ProjectQuotaNotFound(message=None, **kwargs)

Bases: nova.exception.QuotaNotFound

ProjectQuotaNotFound.message = 'Quota for project %(project_id)s could not be found.'
exception QuotaClassNotFound(message=None, **kwargs)

Bases: nova.exception.QuotaNotFound

QuotaClassNotFound.message = 'Quota class %(class_name)s could not be found.'
exception QuotaError(message=None, **kwargs)

Bases: nova.exception.NovaException

QuotaError.message = 'Quota exceeded: code=%(code)s'
exception QuotaNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

QuotaNotFound.message = 'Quota could not be found'
exception QuotaResourceUnknown(message=None, **kwargs)

Bases: nova.exception.QuotaNotFound

QuotaResourceUnknown.message = 'Unknown quota resources %(unknown)s.'
exception QuotaUsageNotFound(message=None, **kwargs)

Bases: nova.exception.QuotaNotFound

QuotaUsageNotFound.message = 'Quota usage for project %(project_id)s could not be found.'
exception ReservationNotFound(message=None, **kwargs)

Bases: nova.exception.QuotaNotFound

ReservationNotFound.message = 'Quota reservation %(uuid)s could not be found.'
exception RotationRequiredForBackup(message=None, **kwargs)

Bases: nova.exception.NovaException

RotationRequiredForBackup.message = 'Rotation param is required for backup image_type'
exception SchedulerCostFunctionNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SchedulerCostFunctionNotFound.message = 'Scheduler cost function %(cost_fn_str)s could not be found.'
exception SchedulerHostFilterNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SchedulerHostFilterNotFound.message = 'Scheduler Host Filter %(filter_name)s could not be found.'
exception SchedulerWeightFlagNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SchedulerWeightFlagNotFound.message = 'Scheduler weight flag not found: %(flag_name)s'
exception SecurityGroupExistsForInstance(message=None, **kwargs)

Bases: nova.exception.Invalid

SecurityGroupExistsForInstance.message = 'Security group %(security_group_id)s is already associated with the instance %(instance_id)s'
exception SecurityGroupNotExistsForInstance(message=None, **kwargs)

Bases: nova.exception.Invalid

SecurityGroupNotExistsForInstance.message = 'Security group %(security_group_id)s is not associated with the instance %(instance_id)s'
exception SecurityGroupNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SecurityGroupNotFound.message = 'Security group %(security_group_id)s not found.'
exception SecurityGroupNotFoundForProject(message=None, **kwargs)

Bases: nova.exception.SecurityGroupNotFound

SecurityGroupNotFoundForProject.message = 'Security group %(security_group_id)s not found for project %(project_id)s.'
exception SecurityGroupNotFoundForRule(message=None, **kwargs)

Bases: nova.exception.SecurityGroupNotFound

SecurityGroupNotFoundForRule.message = 'Security group with rule %(rule_id)s not found.'
exception ServiceNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

ServiceNotFound.message = 'Service %(service_id)s could not be found.'
exception ServiceUnavailable(message=None, **kwargs)

Bases: nova.exception.Invalid

ServiceUnavailable.message = 'Service is unavailable at this time.'
exception SfAccountNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SfAccountNotFound.message = 'Unable to locate account %(account_name)s on Solidfire device'
exception SfJsonEncodeFailure(message=None, **kwargs)

Bases: nova.exception.NovaException

SfJsonEncodeFailure.message = 'Failed to load data into json format'
exception SnapshotIsBusy(message=None, **kwargs)

Bases: nova.exception.NovaException

SnapshotIsBusy.message = 'deleting snapshot %(snapshot_name)s that has dependent volumes'
exception SnapshotNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

SnapshotNotFound.message = 'Snapshot %(snapshot_id)s could not be found.'
exception SolidFireAPIDataException(message=None, **kwargs)

Bases: nova.exception.SolidFireAPIException

SolidFireAPIDataException.message = 'Error in SolidFire API response: data=%(data)s'
exception SolidFireAPIException(message=None, **kwargs)

Bases: nova.exception.NovaException

SolidFireAPIException.message = 'Bad response from SolidFire API'
exception SolidFireAPIStatusException(message=None, **kwargs)

Bases: nova.exception.SolidFireAPIException

SolidFireAPIStatusException.message = 'Error in SolidFire API response: status=%(status)s'
exception SourceHostUnavailable(message=None, **kwargs)

Bases: nova.exception.Invalid

SourceHostUnavailable.message = 'Original compute host is unavailable at this time.'
exception StorageRepositoryNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

StorageRepositoryNotFound.message = 'Cannot find SR to read/write VDI.'
exception SwitchNotFoundForNetworkAdapter(message=None, **kwargs)

Bases: nova.exception.NotFound

SwitchNotFoundForNetworkAdapter.message = 'Virtual switch associated with the network adapter %(adapter)s not found.'
exception TooManyInstances(message=None, **kwargs)

Bases: nova.exception.QuotaError

TooManyInstances.message = 'Quota exceeded for %(overs)s: Requested %(req)s, but already used %(used)d of %(allowed)d instances'
exception UnableToMigrateToSelf(message=None, **kwargs)

Bases: nova.exception.Invalid

UnableToMigrateToSelf.message = 'Unable to migrate instance (%(instance_id)s) to current host (%(host)s).'
exception UserExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

UserExists.message = 'User %(user)s already exists.'
exception UserNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

UserNotFound.message = 'User %(user_id)s could not be found.'
exception UserRoleNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

UserRoleNotFound.message = 'Role %(role_id)s could not be found.'
exception VirtDriverNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VirtDriverNotFound.message = 'Could not find driver for connection_type %(name)s'
exception VirtualInterfaceCreateException(message=None, **kwargs)

Bases: nova.exception.NovaException

VirtualInterfaceCreateException.message = 'Virtual Interface creation failed'
exception VirtualInterfaceMacAddressException(message=None, **kwargs)

Bases: nova.exception.NovaException

VirtualInterfaceMacAddressException.message = '5 attempts to create virtual interfacewith unique mac address failed'
exception VolumeDriverNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VolumeDriverNotFound.message = 'Could not find a handler for %(driver_type)s volume.'
exception VolumeIsBusy(message=None, **kwargs)

Bases: nova.exception.NovaException

VolumeIsBusy.message = 'deleting volume %(volume_name)s that has snapshot'
exception VolumeMetadataNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VolumeMetadataNotFound.message = 'Volume %(volume_id)s has no metadata with key %(metadata_key)s.'
exception VolumeNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VolumeNotFound.message = 'Volume %(volume_id)s could not be found.'
exception VolumeNotFoundForInstance(message=None, **kwargs)

Bases: nova.exception.VolumeNotFound

VolumeNotFoundForInstance.message = 'Volume not found for instance %(instance_id)s.'
exception VolumeSizeTooLarge(message=None, **kwargs)

Bases: nova.exception.QuotaError

VolumeSizeTooLarge.message = 'Maximum volume size exceeded'
exception VolumeTypeCreateFailed(message=None, **kwargs)

Bases: nova.exception.NovaException

VolumeTypeCreateFailed.message = 'Cannot create volume_type with name %(name)s and specs %(extra_specs)s'
exception VolumeTypeExists(message=None, **kwargs)

Bases: nova.exception.Duplicate

VolumeTypeExists.message = 'Volume Type %(name)s already exists.'
exception VolumeTypeExtraSpecsNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VolumeTypeExtraSpecsNotFound.message = 'Volume Type %(volume_type_id)s has no extra specs with key %(extra_specs_key)s.'
exception VolumeTypeNotFound(message=None, **kwargs)

Bases: nova.exception.NotFound

VolumeTypeNotFound.message = 'Volume type %(volume_type_id)s could not be found.'
exception VolumeTypeNotFoundByName(message=None, **kwargs)

Bases: nova.exception.VolumeTypeNotFound

VolumeTypeNotFoundByName.message = 'Volume type with name %(volume_type_name)s could not be found.'
exception VolumeUnattached(message=None, **kwargs)

Bases: nova.exception.Invalid

VolumeUnattached.message = 'Volume %(volume_id)s is not attached to anything'
exception WillNotSchedule(message=None, **kwargs)

Bases: nova.exception.NovaException

WillNotSchedule.message = "Host %(host)s is not up or doesn't exist."
exception ZoneRequestError(message=None, **kwargs)

Bases: nova.exception.NovaException

ZoneRequestError.message = '1 or more Zones could not complete the request'
get_context_from_function_and_args(function, args, kwargs)

Find an arg of type RequestContext and return it.

This is useful in a couple of decorators where we don’t know much about the function we’re wrapping.

wrap_db_error(f)
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.

Emulates gflags by wrapping cfg.ConfigOpts.

The idea is to move fully to cfg eventually, and this wrapper is a stepping stone.

DECLARE(name, module_string, flag_values=<nova.openstack.common.cfg.CommonConfigOpts object at 0x90aa38c>)
exception UnrecognizedFlag

Bases: exceptions.Exception

parse_args(argv, default_config_files=None)

The nova.process Module

The nova.rpc Module

The nova.server Module

The nova.test Module

Base classes for our unit tests.

Allows overriding of flags for use of fakes, and some black magic for inline callbacks.

class TestCase(methodName='runTest')

Bases: unittest.case.TestCase

Test case base class for all unit tests.

TestCase.assertDictListMatch(L1, L2, approx_equal=False, tolerance=0.001)

Assert a list of dicts are equivalent.

TestCase.assertDictMatch(d1, d2, approx_equal=False, tolerance=0.001)

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.
TestCase.assertIn(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ in ‘b’

TestCase.assertIsInstance(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ is Instance of ‘b’

TestCase.assertNotIn(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ NOT in ‘b’

TestCase.assertNotRaises(exc_class, func, *args, **kwargs)

Assert that a particular exception is not raised.

If exc_class is None, then we assert that no error is raised.

Otherwise, we assert that only a particular error wasn’t raised; if any different exceptions were raised, we just silently capture them and return.

TestCase.assertSubDictMatch(sub_dict, super_dict)

Assert a sub_dict is subset of super_dict.

TestCase.flags(**kw)

Override flag variables for a test.

TestCase.setUp()

Run before each test method to initialize test environment.

TestCase.start_service(name, host=None, **kwargs)
TestCase.tearDown()

Runs after each test method to tear down test environment.

exception TestingException

Bases: exceptions.Exception

class skip_if(condition, msg)

Bases: object

Decorator that skips a test if condition is true.

skip_if_fake(func)

Decorator that skips a test if running in fake mode.

class skip_test(msg)

Bases: object

Decorator that skips a test.

class skip_unless(condition, msg)

Bases: object

Decorator that skips a test if condition is not true.

The nova.utils Module

Utilities and helper functions.

class GreenLockFile(path, threaded=True)

Bases: lockfile.LinkFileLock

Implementation of lockfile that allows for a lock per greenthread.

Simply implements lockfile:LockBase init with an addiontall suffix on the unique name of the greenthread identifier

class LazyPluggable(pivot, **backends)

Bases: object

A pluggable backend loaded lazily based on some value.

class LoopingCall(f=None, *args, **kw)

Bases: object

LoopingCall.start(interval, initial_delay=None)
LoopingCall.stop()
LoopingCall.wait()
exception 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()

class UndoManager

Bases: object

Provides a mechanism to facilitate rolling back a series of actions when an exception is raised.

UndoManager.rollback_and_reraise(msg=None, **kwargs)

Rollback a series of actions then re-raise the exception.

Note

(sirp) This should only be called within an exception handler.

UndoManager.undo_with(undo_func)
bool_from_str(val)

Convert a string representation of a bool into a bool value

check_isinstance(obj, cls)

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

cleanup_file_locks()

clean up stale locks left behind by process failures

The lockfile module, used by @synchronized, can leave stale lockfiles behind after process failure. These locks can cause process hangs at startup, when a process deadlocks on a lock which will never be unlocked.

Intended to be called at service startup.

convert_to_list_dict(lst, label)

Convert a value or list into a list of dicts

debug(arg)
delete_if_exists(pathname)

delete a file, but ignore file not found error

execute(*cmd, **kwargs)

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 nova.rootwrap !

Parameters:
  • cmd – Passed to subprocess.Popen.
  • process_input – Send to opened process.
  • check_exit_code – Single bool, int, or list of allowed exit codes. Defaults to [0]. Raise exception.ProcessExecutionError unless program exits with one of these 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.NovaException – on receiving unknown arguments
  • exception.ProcessExecutionError
Returns:

a tuple, (stdout, stderr) from the spawned process, or None if the command fails.

flatten_dict(dict_, flattened=None)

Recursively flatten a nested dictionary.

gen_uuid()
generate_glance_url()

Generate the URL to glance.

generate_image_url(image_ref)

Generate an image URL from an image_ref.

generate_mac_address()

Generate an Ethernet MAC address.

generate_password(length=20, symbolgroups=('23456789', 'ABCDEFGHJKLMNPQRSTUVWXYZ', 'abcdefghijkmnopqrstuvwxyz'))

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

generate_uid(topic, size=8)
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.

get_my_linklocal(interface)
hash_file(file_like_object)

Generate a hash for the contents of a file.

is_uuid_like(val)

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

aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa

is_valid_cidr(address)

Check if the provided ipv4 or ipv6 address is a valid CIDR address or not

is_valid_ipv4(address)

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

last_completed_audit_period(unit=None)

This method gives you the most recently completed audit period.

arguments:
units: string, one of ‘hour’, ‘day’, ‘month’, ‘year’
Periods normally begin at the beginning (UTC) of the period unit (So a ‘day’ period begins at midnight UTC, a ‘month’ unit on the 1st, a ‘year’ on Jan, 1) unit string may be appended with an optional offset like so: 'day@18‘ This will begin the period at 18:00 UTC. 'month@15‘ starts a monthly period on the 15th, and year@3 begins a yearly one on March 1st.
returns: 2 tuple of datetimes (begin, end)
The begin timestamp of this audit period is the same as the end of the previous.
last_octet(address)
make_dev_path(dev, partition=None, base='/dev')

Return a path to a particular device.

>>> make_dev_path('xvdc')
/dev/xvdc
>>> make_dev_path('xvdc', 1)
/dev/xvdc1
map_dict_keys(dict_, key_map)

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

monkey_patch()

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

novadir()
parse_mailmap(mailmap='.mailmap')
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.

partition_dict(dict_, keys)

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

read_cached_file(filename, cache_info, reload_func=None)

Read from a file if it has been modified.

Parameters:
  • cache_info – dictionary to hold opaque cache.
  • reload_func – optional function to be called with data when file is reloaded due to a modification.
Returns:

data from file

read_file_as_root(file_path)

Secure helper to read file as root.

remove_path_on_error(*args, **kwds)

Protect code that wants to operate on PATH atomically. Any exception will cause PATH to be removed.

sanitize_hostname(hostname)

Return a hostname which conforms to RFC-952 and RFC-1123 specs.

service_is_up(service)

Check whether a service is up based on last heartbeat.

ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True)
str_dict_replace(s, mapping)
strcmp_const_time(s1, s2)

Constant-time string comparison.

Params s1:the first string
Params s2:the second string
Returns:True if the strings are equal.

This function takes two strings and compares them. It is intended to be used when doing a comparison for authentication purposes to help guard against timing attacks.

subset_dict(dict_, keys)

Return a dict that only contains a subset of keys.

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.

Important limitation: you can only have one external lock running per thread at a time. For example the following will fail:

@utils.synchronized(‘testlock1’, external=True) def outer_lock():

@utils.synchronized(‘testlock2’, external=True) def inner_lock():

pass

inner_lock()

outer_lock()

sys_platform_translate(arch)

Translate cpu architecture into supported platforms.

tempdir(*args, **kwds)
temporary_chown(*args, **kwds)

Temporarily chown a path.

Params owner_uid:
 UID of temporary owner (defaults to current user)
temporary_mutation(*args, **kwds)

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

Decorator that logs how long a particular function took to execute

total_seconds(td)

Local total_seconds implementation for compatibility with python 2.6

trycmd(*args, **kwargs)

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.

:discard_warnings True | False. Defaults to False. If set to True,
then for succeeding commands, stderr is cleared
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

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

Escapes a string so it is valid within XML or XHTML.

The nova.validate Module

The nova.wsgi Module

Utility methods for working with WSGI servers.

class Application

Bases: object

Base WSGI application wrapper. Subclasses need to implement __call__.

classmethod Application.factory(global_config, **local_config)

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.

class Debug(application)

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.

static Debug.print_generator(app_iter)

Iterator that prints the contents of a wrapper string.

class Loader(config_path=None)

Bases: object

Used to load WSGI applications from paste configurations.

Loader.load_app(name)

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
class Middleware(application)

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.

classmethod Middleware.factory(global_config, **local_config)

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.

Middleware.process_request(req)

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.

Middleware.process_response(response)

Do whatever you’d like to the response.

class Request(environ, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default), **kw)

Bases: webob.request.Request

class Router(mapper)

Bases: object

WSGI middleware that maps incoming requests to WSGI apps.

class Server(name, app, host='0.0.0.0', port=0, pool_size=None, protocol=<class eventlet.wsgi.HttpProtocol at 0x93d323c>, backlog=128)

Bases: object

Server class to manage a WSGI server, serving a WSGI application.

Server.default_pool_size = 1000
Server.start()

Start serving a WSGI application.

Returns:None
Server.stop()

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
Server.wait()

Block, until the server has stopped.

Waits on the server’s eventlet to finish, then returns.

Returns:None

Tests

The declare_flags Module

The fake_flags Module

set_defaults(conf)

The flags_unittest Module

The process_unittest Module

The real_flags Module

The rpc_unittest Module

The runtime_flags Module

The validator_unittest Module