Table Of Contents

Previous topic

Authentication and Authorization

Next topic

Scheduler

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.

API Endpoint

Nova has a system for managing multiple APIs on different subdomains. Currently there is support for the OpenStack API, as well as the Amazon EC2 API.

Common Components

The nova.api Module

The nova.api.cloud Module

OpenStack API

The openstack Module

WSGI middleware for OpenStack API controllers.

class nova.api.openstack.APIRouter(ext_mgr=None)

Bases: nova.wsgi.Router

Routes requests on the OpenStack API to the appropriate controller and method.

classmethod APIRouter.factory(global_config, **local_config)

Simple paste factory, nova.wsgi.Router doesn’t have one

class nova.api.openstack.APIRouterV10(ext_mgr=None)

Bases: nova.api.openstack.APIRouter

Define routes specific to OpenStack API V1.0.

class nova.api.openstack.APIRouterV11(ext_mgr=None)

Bases: nova.api.openstack.APIRouter

Define routes specific to OpenStack API V1.1.

class nova.api.openstack.FaultWrapper(application)

Bases: nova.wsgi.Middleware

Calls down the middleware stack, making exceptions into faults.

class nova.api.openstack.ProjectMapper(controller_scan=<function controller_scan at 0xa108aac>, directory=None, always_scan=False, register=True, explicit=True)

Bases: routes.mapper.Mapper

ProjectMapper.resource(member_name, collection_name, **kwargs)

The auth Module

class nova.api.openstack.auth.AuthMiddleware(application, db_driver=None)

Bases: nova.wsgi.Middleware

Authorize the openstack API request or return an HTTP Forbidden.

AuthMiddleware.authenticate(req)
AuthMiddleware.authorize_token(token_hash)

retrieves user information from the datastore given a token

If the token has expired, returns None If the token is not found, returns None Otherwise returns dict(id=(the authorized user’s id))

This method will also remove the token if the timestamp is older than 2 days ago.

AuthMiddleware.get_user_by_authentication(req)
AuthMiddleware.has_authentication(req)
class nova.api.openstack.auth.NoAuthMiddleware(application)

Bases: nova.wsgi.Middleware

Return a fake token if one isn’t specified.

The backup_schedules Module

class nova.api.openstack.backup_schedules.Controller

Bases: object

The backup schedule API controller for the Openstack API

Controller.create(req, server_id, **kwargs)

No actual update method required, since the existing API allows both create and update through a POST

Controller.delete(req, server_id, id, **kwargs)

Deletes an existing backup schedule

Controller.index(req, server_id, **kwargs)

Returns the list of backup schedules for a given instance

Controller.show(req, server_id, id, **kwargs)

Returns a single backup schedule for a given instance

nova.api.openstack.backup_schedules.create_resource()

The faults Module

exception nova.api.openstack.faults.Fault(exception)

Bases: webob.exc.HTTPException

An RS API fault response.

exception nova.api.openstack.faults.OverLimitFault(message, details, retry_time)

Bases: webob.exc.HTTPException

Rate-limited request response.

The flavors Module

class nova.api.openstack.flavors.Controller

Bases: object

Flavor controller for the OpenStack API.

Controller.detail(req)

Return all flavors in detail.

Controller.index(req)

Return all flavors in brief.

Controller.show(req, id)

Return data about the given flavor id.

class nova.api.openstack.flavors.ControllerV10

Bases: nova.api.openstack.flavors.Controller

class nova.api.openstack.flavors.ControllerV11

Bases: nova.api.openstack.flavors.Controller

class nova.api.openstack.flavors.FlavorXMLSerializer

Bases: nova.api.openstack.wsgi.XMLDictSerializer

FlavorXMLSerializer.detail(flavors_container)
FlavorXMLSerializer.index(flavors_container)
FlavorXMLSerializer.show(flavor_container)
nova.api.openstack.flavors.create_resource(version='1.0')

The images Module

class nova.api.openstack.images.Controller(image_service=None, compute_service=None)

Bases: object

Base controller for retrieving/displaying images.

Controller.delete(req, id)

Delete an image, if allowed.

Parameters:
  • reqwsgi.Request object
  • id – Image identifier (integer)
Controller.get_builder(request)

Indicates that you must use a Controller subclass.

Controller.show(req, id)

Return detailed information about a specific image.

Parameters:
  • reqwsgi.Request object
  • id – Image identifier
class nova.api.openstack.images.ControllerV10(image_service=None, compute_service=None)

Bases: nova.api.openstack.images.Controller

Version 1.0 specific controller logic.

ControllerV10.create(*args, **kwargs)

Snapshot a server instance and save the image.

ControllerV10.detail(req)

Return a detailed index listing of images available to the request.

Parameters:reqwsgi.Request object.
ControllerV10.get_builder(request)

Property to get the ViewBuilder class we need to use.

ControllerV10.index(req)

Return an index listing of images available to the request.

Parameters:reqwsgi.Request object
class nova.api.openstack.images.ControllerV11(image_service=None, compute_service=None)

Bases: nova.api.openstack.images.Controller

Version 1.1 specific controller logic.

ControllerV11.create(*args, **kwargs)
ControllerV11.detail(req)

Return a detailed index listing of images available to the request.

Parameters:reqwsgi.Request object.
ControllerV11.get_builder(req)

Property to get the ViewBuilder class we need to use.

ControllerV11.index(req)

Return an index listing of images available to the request.

Parameters:reqwsgi.Request object
class nova.api.openstack.images.ImageXMLSerializer

Bases: nova.api.openstack.wsgi.XMLDictSerializer

ImageXMLSerializer.detail(images_dict)
ImageXMLSerializer.index(images_dict)
ImageXMLSerializer.show(image_dict)
nova.api.openstack.images.create_resource(version='1.0')

The ratelimiting Module

Rate limiting of arbitrary actions.

class nova.api.openstack.ratelimiting.Limiter(limits)

Bases: object

Class providing rate limiting of arbitrary actions.

Limiter.perform(action_name, username='nobody')

Attempt to perform an action by the given username.

action_name: the string name of the action to perform. This must be a key in the limits dict passed to the ctor.

username: an optional string name of the user performing the action. Each user has her own set of rate limiting counters. Defaults to ‘nobody’ (so that if you never specify a username when calling perform(), a single set of counters will be used.)

Return None if the action may proceed. If the action may not proceed because it has been rate limited, return the float number of seconds until the action would succeed.

class nova.api.openstack.ratelimiting.RateLimitingMiddleware(application, service_host=None)

Bases: nova.wsgi.Middleware

Rate limit incoming requests according to the OpenStack rate limits.

RateLimitingMiddleware.get_action_name(req)

Return the action name for this request.

RateLimitingMiddleware.get_delay(action_name, username)

Return the delay for the given action and username, or None if the action would not be rate limited.

RateLimitingMiddleware.rate_limited_request(req, application)

Rate limit the request.

If the request should be rate limited, return a 413 status with a Retry-After header giving the time when the request would succeed.

class nova.api.openstack.ratelimiting.WSGIApp(limiter)

Bases: object

Application that tracks rate limits in memory. Send requests to it of this form:

POST /limiter/<username>/<urlencoded action>

and receive a 200 OK, or a 403 Forbidden with an X-Wait-Seconds header containing the number of seconds to wait before the action would succeed.

class nova.api.openstack.ratelimiting.WSGIAppProxy(service_host)

Bases: object

Limiter lookalike that proxies to a ratelimiting.WSGIApp.

WSGIAppProxy.perform(action, username='nobody')

The servers Module

class nova.api.openstack.servers.Controller

Bases: object

The Server API base controller class for the OpenStack API

Controller.action(*args, **kwargs)
Controller.actions(req, id)

Permit Admins to retrieve server actions.

Controller.create(req, body)

Creates a new server for a given user

Controller.detail(req)

Returns a list of server details for a given user

Controller.diagnostics(*args, **kwargs)
Controller.get_ajax_console(*args, **kwargs)
Controller.get_lock(*args, **kwargs)
Controller.get_vnc_console(*args, **kwargs)
Controller.index(req)

Returns a list of server names and ids for a given user

Controller.inject_network_info(*args, **kwargs)
Controller.lock(*args, **kwargs)
Controller.migrate(*args, **kwargs)
Controller.pause(*args, **kwargs)
Controller.rescue(*args, **kwargs)
Controller.reset_network(*args, **kwargs)
Controller.resize(req, instance_id, flavor_id)

Begin the resize process with given instance/flavor.

Controller.resume(*args, **kwargs)
Controller.show(*args, **kwargs)
Controller.suspend(*args, **kwargs)
Controller.unlock(*args, **kwargs)
Controller.unpause(*args, **kwargs)
Controller.unrescue(*args, **kwargs)
Controller.update(*args, **kwargs)
class nova.api.openstack.servers.ControllerV10

Bases: nova.api.openstack.servers.Controller

v1.0 OpenStack API controller

ControllerV10.delete(*args, **kwargs)
class nova.api.openstack.servers.ControllerV11

Bases: nova.api.openstack.servers.Controller

v1.1 OpenStack API controller

ControllerV11.delete(*args, **kwargs)
ControllerV11.get_default_xmlns(req)
class nova.api.openstack.servers.HeadersSerializer

Bases: nova.api.openstack.wsgi.ResponseHeadersSerializer

HeadersSerializer.action(response, data)
HeadersSerializer.create(response, data)
HeadersSerializer.delete(response, data)
class nova.api.openstack.servers.ServerXMLSerializer

Bases: nova.api.openstack.wsgi.XMLDictSerializer

ServerXMLSerializer.action(server_dict)
ServerXMLSerializer.create(server_dict)
ServerXMLSerializer.detail(servers_dict)
ServerXMLSerializer.index(servers_dict)
ServerXMLSerializer.show(server_dict)
ServerXMLSerializer.update(server_dict)
nova.api.openstack.servers.create_resource(version='1.0')
nova.api.openstack.servers.remove_invalid_options(context, search_options, allowed_search_options)

Remove search options that are not valid for non-admin API/context

The sharedipgroups Module

EC2 API

The nova.api.ec2 Module

Starting point for routing EC2 requests.

class nova.api.ec2.Authenticate(application)

Bases: nova.wsgi.Middleware

Authenticate an EC2 request and add ‘nova.context’ to WSGI environ.

class nova.api.ec2.Authorizer(application)

Bases: nova.wsgi.Middleware

Authorize an EC2 API request.

Return a 401 if ec2.controller and ec2.action in WSGI environ may not be executed in nova.context.

class nova.api.ec2.Executor

Bases: nova.wsgi.Application

Execute an EC2 API request.

Executes ‘ec2.action’ upon ‘ec2.controller’, passing ‘nova.context’ and ‘ec2.action_args’ (all variables in WSGI environ.) Returns an XML response, or a 400 upon failure.

class nova.api.ec2.Lockout(application)

Bases: nova.wsgi.Middleware

Lockout for x minutes on y failed auths in a z minute period.

x = lockout_timeout flag y = lockout_window flag z = lockout_attempts flag

Uses memcached if lockout_memcached_servers flag is set, otherwise it uses a very simple in-proccess cache. Due to the simplicity of the implementation, the timeout window is started with the first failed request, so it will block if there are x failed logins within that period.

There is a possible race condition where simultaneous requests could sneak in before the lockout hits, but this is extremely rare and would only result in a couple of extra failed attempts.

class nova.api.ec2.NoAuth(application)

Bases: nova.wsgi.Middleware

Add user:project as ‘nova.context’ to WSGI environ.

class nova.api.ec2.RequestLogging(application)

Bases: nova.wsgi.Middleware

Access-Log akin logging for all EC2 API requests.

RequestLogging.log_request_completion(response, request, start)
class nova.api.ec2.Requestify(app, controller)

Bases: nova.wsgi.Middleware

class nova.api.ec2.Versions

Bases: nova.wsgi.Application

The admin Module

Admin API controller, exposed through http via the api worker.

class nova.api.ec2.admin.AdminController

Bases: object

API Controller for users, hosts, nodes, and workers.

AdminController.block_external_addresses(context, cidr)

Add provider-level firewall rules to block incoming traffic.

AdminController.deregister_project(context, name)

Permanently deletes a project.

AdminController.deregister_user(context, name, **_kwargs)

Deletes a single user (NOT undoable.) Should throw an exception if the user has instances, volumes, or buckets remaining.

AdminController.describe_external_address_blocks(context)
AdminController.describe_hosts(context, **_kwargs)

Returns status info for all nodes. Includes: * Hostname * Compute (up, down, None) * Instance count * Volume (up, down, None) * Volume Count

AdminController.describe_instance_types(context, **_kwargs)

Returns all active instance types data (vcpus, memory, etc.)

AdminController.describe_project(context, name, **kwargs)

Returns project data, including member ids.

AdminController.describe_project_members(context, name, **kwargs)
AdminController.describe_projects(context, user=None, **kwargs)

Returns all projects - should be changed to deal with a list.

AdminController.describe_roles(context, project_roles=True, **kwargs)

Returns a list of allowed roles.

AdminController.describe_user(_context, name, **_kwargs)

Returns user data, including access and secret keys.

AdminController.describe_user_roles(context, user, project=None, **kwargs)

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.

AdminController.describe_users(_context, **_kwargs)

Returns all users - should be changed to deal with a list.

AdminController.describe_vpns(context)
AdminController.generate_x509_for_user(context, name, project=None, **kwargs)

Generates and returns an x509 certificate for a single user. Is usually called from a client that will wrap this with access and secret key info, and return a zip file.

AdminController.modify_project(context, name, manager_user, description=None, **kwargs)

Modifies a project

AdminController.modify_project_member(context, user, project, operation, **kwargs)

Add or remove a user from a project.

AdminController.modify_user_role(context, user, role, project=None, operation='add', **kwargs)

Add or remove a role for a user and project.

AdminController.register_project(context, name, manager_user, description=None, member_users=None, **kwargs)

Creates a new project

AdminController.register_user(context, name, **_kwargs)

Creates a new user, and returns generated credentials.

AdminController.remove_external_address_block(context, cidr)
AdminController.start_vpn(context, project)
nova.api.ec2.admin.host_dict(host, compute_service, instances, volume_service, volumes, now)

Convert a host model object to a result dict

nova.api.ec2.admin.instance_dict(inst)
nova.api.ec2.admin.project_dict(project)

Convert the project object to a result dict

nova.api.ec2.admin.user_dict(user, base64_file=None)

Convert the user object to a result dict

nova.api.ec2.admin.vpn_dict(project, vpn_instance)

The apirequest Module

APIRequest class

class nova.api.ec2.apirequest.APIRequest(controller, action, version, args)

Bases: object

APIRequest.invoke(context)

The cloud Module

Cloud Controller: Implementation of EC2 REST API calls, which are dispatched to other nodes via AMQP RPC. State is via distributed datastore.

class nova.api.ec2.cloud.CloudController

Bases: object

CloudController provides the critical dispatch between inbound API calls through the endpoint and messages sent to the other nodes.

CloudController.allocate_address(context, **kwargs)
CloudController.associate_address(context, instance_id, public_ip, **kwargs)
CloudController.attach_volume(context, volume_id, instance_id, device, **kwargs)
CloudController.authorize_security_group_ingress(context, group_name=None, group_id=None, **kwargs)
CloudController.create_image(context, instance_id, **kwargs)
CloudController.create_key_pair(context, key_name, **kwargs)
CloudController.create_security_group(context, group_name, group_description)
CloudController.create_snapshot(context, volume_id, **kwargs)
CloudController.create_volume(context, **kwargs)
CloudController.delete_key_pair(context, key_name, **kwargs)
CloudController.delete_security_group(context, group_name=None, group_id=None, **kwargs)
CloudController.delete_snapshot(context, snapshot_id, **kwargs)
CloudController.delete_volume(context, volume_id, **kwargs)
CloudController.deregister_image(context, image_id, **kwargs)
CloudController.describe_addresses(context, **kwargs)
CloudController.describe_availability_zones(context, **kwargs)
CloudController.describe_image_attribute(context, image_id, attribute, **kwargs)
CloudController.describe_images(context, image_id=None, **kwargs)
CloudController.describe_instance_attribute(context, instance_id, attribute, **kwargs)
CloudController.describe_instances(context, **kwargs)
CloudController.describe_instances_v6(context, **kwargs)
CloudController.describe_key_pairs(context, key_name=None, **kwargs)
CloudController.describe_regions(context, region_name=None, **kwargs)
CloudController.describe_security_groups(context, group_name=None, group_id=None, **kwargs)
CloudController.describe_snapshots(context, snapshot_id=None, owner=None, restorable_by=None, **kwargs)
CloudController.describe_volumes(context, volume_id=None, **kwargs)
CloudController.detach_volume(context, volume_id, **kwargs)
CloudController.disassociate_address(context, public_ip, **kwargs)
CloudController.format_addresses(context)
CloudController.get_ajax_console(context, instance_id, **kwargs)
CloudController.get_console_output(context, instance_id, **kwargs)
CloudController.get_metadata(address)
CloudController.get_vnc_console(context, instance_id, **kwargs)

Returns vnc browser url. Used by OS dashboard.

static CloudController.image_ec2_id(image_id, image_type='ami')

Returns image ec2_id using id and three letter type.

CloudController.import_public_key(context, key_name, public_key, fingerprint=None)
CloudController.modify_image_attribute(context, image_id, attribute, operation_type, **kwargs)
CloudController.reboot_instances(context, instance_id, **kwargs)

instance_id is a list of instance ids

CloudController.register_image(context, image_location=None, **kwargs)
CloudController.release_address(context, public_ip, **kwargs)
CloudController.rescue_instance(context, instance_id, **kwargs)

This is an extension to the normal ec2_api

CloudController.revoke_security_group_ingress(context, group_name=None, group_id=None, **kwargs)
CloudController.run_instances(context, **kwargs)
CloudController.setup()

Ensure the keychains and folders exist.

CloudController.start_instances(context, instance_id, **kwargs)

Start each instances in instance_id. Here instance_id is a list of instance ids

CloudController.stop_instances(context, instance_id, **kwargs)

Stop each instances in instance_id. Here instance_id is a list of instance ids

CloudController.terminate_instances(context, instance_id, **kwargs)

Terminate each instance in instance_id, which is a list of ec2 ids. instance_id is a kwarg so its name cannot be modified.

CloudController.unrescue_instance(context, instance_id, **kwargs)

This is an extension to the normal ec2_api

CloudController.update_image(context, image_id, **kwargs)
CloudController.update_instance(context, instance_id, **kwargs)
CloudController.update_volume(context, volume_id, **kwargs)
nova.api.ec2.cloud.state_description_from_vm_state(vm_state)

Map the vm state to the server status string

The images Module

The metadatarequesthandler Module

Metadata request handler.

class nova.api.ec2.metadatarequesthandler.MetadataRequestHandler

Bases: nova.wsgi.Application

Serve metadata from the EC2 API.

MetadataRequestHandler.lookup(path, data)
MetadataRequestHandler.print_data(data)

Tests

The api_unittest Module

The api_integration Module

The cloud_unittest Module

The api.fakes Module

The api.test_wsgi Module

Test WSGI basics and provide some helper functions for other WSGI tests.

class nova.tests.api.test_wsgi.Test(methodName='runTest')

Bases: nova.test.TestCase

Test.test_debug()
Test.test_router()

The test_api Module

class nova.tests.api.openstack.test_api.APITest(methodName='runTest')

Bases: nova.test.TestCase

APITest.test_exceptions_are_converted_to_faults()
APITest.test_malformed_json()
APITest.test_malformed_xml()

The test_auth Module

class nova.tests.api.openstack.test_auth.Test(methodName='runTest')

Bases: nova.test.TestCase

Test.setUp()
Test.tearDown()
Test.test_authorize_project()
Test.test_authorize_token()
Test.test_authorize_user()
Test.test_bad_project()
Test.test_bad_token()
Test.test_bad_user_bad_key()
Test.test_bad_user_good_key()
Test.test_no_user()
Test.test_not_existing_project()
Test.test_token_expiry()
class nova.tests.api.openstack.test_auth.TestFunctional(methodName='runTest')

Bases: nova.test.TestCase

TestFunctional.test_token_doesnotexist()
TestFunctional.test_token_expiry()
class nova.tests.api.openstack.test_auth.TestLimiter(methodName='runTest')

Bases: nova.test.TestCase

TestLimiter.setUp()
TestLimiter.tearDown()
TestLimiter.test_authorize_token()

The test_faults Module

class nova.tests.api.openstack.test_faults.FaultsXMLSerializationTestV11(methodName='runTest')

Bases: nova.test.TestCase

Tests covering nova.api.openstack.faults:Fault class.

FaultsXMLSerializationTestV11.test_400_fault()
FaultsXMLSerializationTestV11.test_404_fault()
FaultsXMLSerializationTestV11.test_413_fault()
class nova.tests.api.openstack.test_faults.TestFaults(methodName='runTest')

Bases: nova.test.TestCase

Tests covering nova.api.openstack.faults:Fault class.

TestFaults.test_400_fault_json()

Test fault serialized to JSON via file-extension and/or header.

TestFaults.test_400_fault_xml()

Test fault serialized to XML via file-extension and/or header.

TestFaults.test_413_fault_json()

Test fault serialized to JSON via file-extension and/or header.

TestFaults.test_413_fault_xml()
TestFaults.test_fault_has_status_int()

Ensure the status_int is set correctly on faults

TestFaults.test_raise()

Ensure the ability to raise `Fault`s in WSGI-ified methods.

TestFaults.test_v10_xml_serializer()

Ensure that a v1.0 request responds with a v1.0 xmlns

TestFaults.test_v11_xml_serializer()

Ensure that a v1.1 request responds with a v1.1 xmlns

The test_flavors Module

class nova.tests.api.openstack.test_flavors.FlavorsTest(methodName='runTest')

Bases: nova.test.TestCase

FlavorsTest.setUp()
FlavorsTest.tearDown()
FlavorsTest.test_get_empty_flavor_list_v1_0()
FlavorsTest.test_get_empty_flavor_list_v1_1()
FlavorsTest.test_get_flavor_by_id_v1_0()
FlavorsTest.test_get_flavor_by_id_v1_1()
FlavorsTest.test_get_flavor_by_invalid_id()
FlavorsTest.test_get_flavor_list_detail_v1_0()
FlavorsTest.test_get_flavor_list_detail_v1_1()
FlavorsTest.test_get_flavor_list_v1_0()
FlavorsTest.test_get_flavor_list_v1_1()
class nova.tests.api.openstack.test_flavors.FlavorsXMLSerializationTest(methodName='runTest')

Bases: nova.test.TestCase

FlavorsXMLSerializationTest.test_detail()
FlavorsXMLSerializationTest.test_index()
FlavorsXMLSerializationTest.test_index_empty()
FlavorsXMLSerializationTest.test_show()
FlavorsXMLSerializationTest.test_show_handles_integers()
nova.tests.api.openstack.test_flavors.return_instance_type_by_flavor_id(context, flavorid)
nova.tests.api.openstack.test_flavors.return_instance_type_not_found(context, flavor_id)
nova.tests.api.openstack.test_flavors.return_instance_types(context, num=2)
nova.tests.api.openstack.test_flavors.stub_flavor(flavorid, name, memory_mb='256', local_gb='10')

The test_images Module

Tests of the new image services, both as a service layer, and as a WSGI layer

class nova.tests.api.openstack.test_images.GlanceImageServiceTest(*args, **kwargs)

Bases: nova.tests.api.openstack.test_images._BaseImageServiceTests

Tests the Glance image service, in particular that metadata translation works properly.

At a high level, the translations involved are:

  1. Glance -> ImageService - This is needed so we can support multple ImageServices (Glance, Local, etc)
  2. ImageService -> API - This is needed so we can support multple APIs (OpenStack, EC2)
GlanceImageServiceTest.setUp()
GlanceImageServiceTest.tearDown()
GlanceImageServiceTest.test_create_with_instance_id()

Ensure instance_id is persisted as an image-property

GlanceImageServiceTest.test_create_without_instance_id()

Ensure we can create an image without having to specify an instance_id. Public images are an example of an image not tied to an instance.

GlanceImageServiceTest.test_detail_limit()
GlanceImageServiceTest.test_detail_marker()
GlanceImageServiceTest.test_detail_marker_and_limit()
GlanceImageServiceTest.test_index_default_limit()
GlanceImageServiceTest.test_index_limit()
GlanceImageServiceTest.test_index_marker()
GlanceImageServiceTest.test_index_marker_and_limit()
class nova.tests.api.openstack.test_images.ImageControllerWithGlanceServiceTest(methodName='runTest')

Bases: nova.test.TestCase

Test of the OpenStack API /images application controller w/Glance.

ImageControllerWithGlanceServiceTest.setUp()

Run before each test.

ImageControllerWithGlanceServiceTest.tearDown()

Run after each test.

ImageControllerWithGlanceServiceTest.test_create_image()
ImageControllerWithGlanceServiceTest.test_create_image_no_server_id()
ImageControllerWithGlanceServiceTest.test_create_image_snapshots_disabled()
ImageControllerWithGlanceServiceTest.test_create_snapshot_no_name()

Name is required for snapshots

ImageControllerWithGlanceServiceTest.test_get_image()
ImageControllerWithGlanceServiceTest.test_get_image_404_json()
ImageControllerWithGlanceServiceTest.test_get_image_404_v1_1_json()
ImageControllerWithGlanceServiceTest.test_get_image_404_v1_1_xml()
ImageControllerWithGlanceServiceTest.test_get_image_404_xml()
ImageControllerWithGlanceServiceTest.test_get_image_details()
ImageControllerWithGlanceServiceTest.test_get_image_details_v1_1()
ImageControllerWithGlanceServiceTest.test_get_image_found()
ImageControllerWithGlanceServiceTest.test_get_image_index()
ImageControllerWithGlanceServiceTest.test_get_image_index_v1_1()
ImageControllerWithGlanceServiceTest.test_get_image_non_existent()
ImageControllerWithGlanceServiceTest.test_get_image_not_owned()

We should return a 404 if we request an image that doesn’t belong to us

ImageControllerWithGlanceServiceTest.test_get_image_v1_1()
ImageControllerWithGlanceServiceTest.test_get_image_xml()
ImageControllerWithGlanceServiceTest.test_get_image_xml_no_name()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_changes_since()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_not_supported()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_server()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_with_name()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_with_property()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_with_status()
ImageControllerWithGlanceServiceTest.test_image_detail_filter_with_type()
ImageControllerWithGlanceServiceTest.test_image_detail_no_filters()
ImageControllerWithGlanceServiceTest.test_image_filter_changes_since()
ImageControllerWithGlanceServiceTest.test_image_filter_not_supported()
ImageControllerWithGlanceServiceTest.test_image_filter_server()
ImageControllerWithGlanceServiceTest.test_image_filter_with_name()
ImageControllerWithGlanceServiceTest.test_image_filter_with_property()
ImageControllerWithGlanceServiceTest.test_image_filter_with_status()
ImageControllerWithGlanceServiceTest.test_image_filter_with_type()
ImageControllerWithGlanceServiceTest.test_image_no_filters()
class nova.tests.api.openstack.test_images.ImageXMLSerializationTest(methodName='runTest')

Bases: nova.test.TestCase

ImageXMLSerializationTest.test_detail()
ImageXMLSerializationTest.test_index()
ImageXMLSerializationTest.test_index_zero_images()
ImageXMLSerializationTest.test_show()
ImageXMLSerializationTest.test_show_image_no_metadata_key()
ImageXMLSerializationTest.test_show_no_server()
ImageXMLSerializationTest.test_show_zero_metadata()

The test_ratelimiting Module

The test_servers Module

class nova.tests.api.openstack.test_servers.MockSetAdminPassword

Bases: object

class nova.tests.api.openstack.test_servers.ServerXMLSerializationTest(methodName='runTest')

Bases: nova.test.TestCase

ServerXMLSerializationTest.setUp()
ServerXMLSerializationTest.test_action()
ServerXMLSerializationTest.test_create()
ServerXMLSerializationTest.test_detail()
ServerXMLSerializationTest.test_index()
ServerXMLSerializationTest.test_show()
ServerXMLSerializationTest.test_update()
class nova.tests.api.openstack.test_servers.ServersTest(methodName='runTest')

Bases: nova.test.TestCase

ServersTest.setUp()
ServersTest.test_create_backup_schedules()
ServersTest.test_create_instance()
ServersTest.test_create_instance_has_uuid()

Tests at the db-layer instead of API layer since that’s where the UUID is generated

ServersTest.test_create_instance_name_too_long()
ServersTest.test_create_instance_no_key_pair()
ServersTest.test_create_instance_no_name()
ServersTest.test_create_instance_no_server_entity()
ServersTest.test_create_instance_nonstring_name()
ServersTest.test_create_instance_v1_1()
ServersTest.test_create_instance_v1_1_admin_pass()
ServersTest.test_create_instance_v1_1_admin_pass_empty()
ServersTest.test_create_instance_v1_1_bad_flavor_href()
ServersTest.test_create_instance_v1_1_bad_href()
ServersTest.test_create_instance_v1_1_invalid_flavor_href()
ServersTest.test_create_instance_v1_1_invalid_flavor_id_int()
ServersTest.test_create_instance_v1_1_invalid_key_name()
ServersTest.test_create_instance_v1_1_local_href()
ServersTest.test_create_instance_v1_1_name_too_long()
ServersTest.test_create_instance_v1_1_valid_key_name()
ServersTest.test_create_instance_via_zones()

Server generated ReservationID

ServersTest.test_create_instance_via_zones_with_resid()

User supplied ReservationID

ServersTest.test_create_instance_whitespace_name()
ServersTest.test_create_instance_with_access_ip_v1_1()
ServersTest.test_create_instance_with_admin_pass_v1_0()
ServersTest.test_create_instance_with_bad_config_drive_v1_1()
ServersTest.test_create_instance_with_config_drive_as_id_v1_1()
ServersTest.test_create_instance_with_config_drive_v1_1()
ServersTest.test_create_instance_without_config_drive_v1_1()
ServersTest.test_delete_backup_schedules()
ServersTest.test_delete_server_instance()
ServersTest.test_delete_server_instance_v1_1()
ServersTest.test_get_all_server_details_v1_0()
ServersTest.test_get_all_server_details_v1_1()
ServersTest.test_get_all_server_details_with_host()

We want to make sure that if two instances are on the same host, then they return the same hostId. If two instances are on different hosts, they should return different hostId’s. In this test, there are 5 instances - 2 on one host and 3 on another.

ServersTest.test_get_all_server_details_xml_v1_0()
ServersTest.test_get_server_addresses_nonexistant_network_v1_1()
ServersTest.test_get_server_addresses_nonexistant_server_v1_1()
ServersTest.test_get_server_addresses_private_v1_0()
ServersTest.test_get_server_addresses_private_xml_v1_0()
ServersTest.test_get_server_addresses_public_v1_0()
ServersTest.test_get_server_addresses_public_xml_v1_0()
ServersTest.test_get_server_addresses_single_network_v1_1()
ServersTest.test_get_server_addresses_v1_0()
ServersTest.test_get_server_addresses_v1_1()
ServersTest.test_get_server_addresses_xml_v1_0()
ServersTest.test_get_server_backup_schedule()
ServersTest.test_get_server_backup_schedules()
ServersTest.test_get_server_by_id()
ServersTest.test_get_server_by_id_malformed_networks_v1_1()
ServersTest.test_get_server_by_id_v1_1()
ServersTest.test_get_server_by_id_v1_1_xml()
ServersTest.test_get_server_by_id_with_addresses()
ServersTest.test_get_server_by_id_with_addresses_v1_1()
ServersTest.test_get_server_by_id_with_addresses_v1_1_ipv6_disabled()
ServersTest.test_get_server_by_id_with_addresses_xml()
ServersTest.test_get_server_by_uuid()

The steps involved with resolving a UUID are pretty complicated; here’s what’s happening in this scenario:

  1. Show is calling routing_get
  2. routing_get is wrapped by reroute_compute which does the work of resolving requests to child zones.
  3. reroute_compute looks up the UUID by hitting the stub (returns_server_by_uuid)
  4. Since the stub return that the record exists, reroute_compute considers the request to be ‘zone local’, so it replaces the UUID in the argument list with an integer ID and then calls the inner function (‘get’).
  5. The call to get hits the other stub ‘returns_server_by_id` which has the UUID set to FAKE_UUID

So, counterintuitively, we call get twice on the show command.

ServersTest.test_get_server_list()
ServersTest.test_get_server_list_v1_1()
ServersTest.test_get_server_list_with_reservation_id()
ServersTest.test_get_server_list_with_reservation_id_details()
ServersTest.test_get_server_list_with_reservation_id_empty()
ServersTest.test_get_server_with_active_status_by_id_v1_1()
ServersTest.test_get_server_with_id_image_ref_by_id_v1_1()
ServersTest.test_get_servers_admin_allows_ip6_v1_1()

Test getting servers by ip6 with admin_api enabled and admin context

ServersTest.test_get_servers_admin_allows_ip_v1_1()

Test getting servers by ip with admin_api enabled and admin context

ServersTest.test_get_servers_allows_changes_since_bad_value_v1_1()
ServersTest.test_get_servers_allows_changes_since_v1_1()
ServersTest.test_get_servers_allows_flavor_v1_1()
ServersTest.test_get_servers_allows_image_v1_1()
ServersTest.test_get_servers_allows_name_v1_1()
ServersTest.test_get_servers_allows_status_v1_1()
ServersTest.test_get_servers_invalid_status_v1_1()

Test getting servers by invalid status

ServersTest.test_get_servers_unknown_or_admin_options1()

Test getting servers by admin-only or unknown options. This tests when admin_api is off. Make sure the admin and unknown options are stripped before they get to compute_api.get_all()

ServersTest.test_get_servers_unknown_or_admin_options2()

Test getting servers by admin-only or unknown options. This tests when admin_api is on, but context is a user. Make sure the admin and unknown options are stripped before they get to compute_api.get_all()

ServersTest.test_get_servers_unknown_or_admin_options3()

Test getting servers by admin-only or unknown options. This tests when admin_api is on and context is admin. All options should be passed through to compute_api.get_all()

ServersTest.test_get_servers_with_bad_limit()
ServersTest.test_get_servers_with_bad_marker()
ServersTest.test_get_servers_with_bad_offset()
ServersTest.test_get_servers_with_bad_option_v1_0()
ServersTest.test_get_servers_with_bad_option_v1_1()
ServersTest.test_get_servers_with_limit()
ServersTest.test_get_servers_with_limit_and_marker()
ServersTest.test_get_servers_with_limit_and_offset()
ServersTest.test_get_servers_with_marker()
ServersTest.test_get_servers_with_offset()
ServersTest.test_rescue_accepted()
ServersTest.test_rescue_raises_handled()
ServersTest.test_server_actions()
ServersTest.test_server_backup_schedule_deprecated_v1_1()
ServersTest.test_server_diagnostics()
ServersTest.test_server_inject_network_info()
ServersTest.test_server_pause()
ServersTest.test_server_reset_network()
ServersTest.test_server_resume()
ServersTest.test_server_suspend()
ServersTest.test_server_unpause()
ServersTest.test_tenant_id_filter_converts_to_project_id_for_admin()
ServersTest.test_update_nonstring_name()

Confirm that update is filtering params

ServersTest.test_update_null_name()

Confirm that update is filtering params

ServersTest.test_update_server_access_ipv4_v1_1()
ServersTest.test_update_server_access_ipv6_v1_1()
ServersTest.test_update_server_adminPass_ignored_v1_1()
ServersTest.test_update_server_all_attributes_v1_1()
ServersTest.test_update_server_name_too_long()

Confirm that update is filtering params

ServersTest.test_update_server_name_too_long_v1_1()
ServersTest.test_update_server_name_v1_1()
ServersTest.test_update_server_no_body()
ServersTest.test_update_server_no_body_v1_1()
ServersTest.test_update_server_v1_0()
ServersTest.test_update_whitespace_name()

Confirm that update is filtering params

class nova.tests.api.openstack.test_servers.ServersViewBuilderV11Test(methodName='runTest')

Bases: nova.test.TestCase

ServersViewBuilderV11Test.setUp()
ServersViewBuilderV11Test.tearDown()
ServersViewBuilderV11Test.test_build_server()
ServersViewBuilderV11Test.test_build_server_detail()
ServersViewBuilderV11Test.test_build_server_detail_active_status()
ServersViewBuilderV11Test.test_build_server_detail_with_accessipv4()
ServersViewBuilderV11Test.test_build_server_detail_with_accessipv6()
ServersViewBuilderV11Test.test_build_server_detail_with_metadata()
ServersViewBuilderV11Test.test_build_server_with_project_id()
class nova.tests.api.openstack.test_servers.TestAddressesXMLSerialization(methodName='runTest')

Bases: nova.test.TestCase

TestAddressesXMLSerialization.test_index()
TestAddressesXMLSerialization.test_show()
class nova.tests.api.openstack.test_servers.TestGetKernelRamdiskFromImage(methodName='runTest')

Bases: nova.test.TestCase

If we’re building from an AMI-style image, we need to be able to fetch the kernel and ramdisk associated with the machine image. This information is stored with the image metadata and return via the ImageService.

These tests ensure that we parse the metadata return the ImageService correctly and that we handle failure modes appropriately.

TestGetKernelRamdiskFromImage.test_ami_kernel_ramdisk_present()

Return IDs if both kernel and ramdisk are present

TestGetKernelRamdiskFromImage.test_ami_no_kernel()

If an ami is missing a kernel it should raise NotFound

TestGetKernelRamdiskFromImage.test_ami_no_ramdisk()

If an ami is missing a ramdisk, return kernel ID and None for ramdisk ID

TestGetKernelRamdiskFromImage.test_not_ami()

Anything other than ami should return no kernel and no ramdisk

TestGetKernelRamdiskFromImage.test_status_not_active()

We should only allow fetching of kernel and ramdisk information if we have a ‘fully-formed’ image, aka ‘active’

class nova.tests.api.openstack.test_servers.TestServerCreateRequestXMLDeserializerV10(methodName='runTest')

Bases: unittest.case.TestCase

TestServerCreateRequestXMLDeserializerV10.setUp()
TestServerCreateRequestXMLDeserializerV10.test_canonical_request_from_docs()
TestServerCreateRequestXMLDeserializerV10.test_minimal_request()
TestServerCreateRequestXMLDeserializerV10.test_request_second_personality_node_ignored()
TestServerCreateRequestXMLDeserializerV10.test_request_with_empty_metadata()
TestServerCreateRequestXMLDeserializerV10.test_request_with_empty_metadata_and_personality()
TestServerCreateRequestXMLDeserializerV10.test_request_with_empty_metadata_and_personality_reversed()
TestServerCreateRequestXMLDeserializerV10.test_request_with_empty_personality()
TestServerCreateRequestXMLDeserializerV10.test_request_with_metadata_duplicate_key()
TestServerCreateRequestXMLDeserializerV10.test_request_with_metadata_missing_key()
TestServerCreateRequestXMLDeserializerV10.test_request_with_metadata_missing_value()
TestServerCreateRequestXMLDeserializerV10.test_request_with_one_metadata()
TestServerCreateRequestXMLDeserializerV10.test_request_with_one_personality()
TestServerCreateRequestXMLDeserializerV10.test_request_with_one_personality_empty_contents()
TestServerCreateRequestXMLDeserializerV10.test_request_with_one_personality_empty_contents_variation()
TestServerCreateRequestXMLDeserializerV10.test_request_with_one_personality_missing_path()
TestServerCreateRequestXMLDeserializerV10.test_request_with_two_metadata()
TestServerCreateRequestXMLDeserializerV10.test_request_with_two_metadata_missing_key()
TestServerCreateRequestXMLDeserializerV10.test_request_with_two_metadata_missing_value()
TestServerCreateRequestXMLDeserializerV10.test_request_with_two_personalities()
class nova.tests.api.openstack.test_servers.TestServerCreateRequestXMLDeserializerV11(methodName='runTest')

Bases: nova.test.TestCase

TestServerCreateRequestXMLDeserializerV11.setUp()
TestServerCreateRequestXMLDeserializerV11.test_access_ip()
TestServerCreateRequestXMLDeserializerV11.test_access_ipv4()
TestServerCreateRequestXMLDeserializerV11.test_access_ipv6()
TestServerCreateRequestXMLDeserializerV11.test_admin_pass()
TestServerCreateRequestXMLDeserializerV11.test_empty_metadata_personality()
TestServerCreateRequestXMLDeserializerV11.test_flavor_link()
TestServerCreateRequestXMLDeserializerV11.test_image_link()
TestServerCreateRequestXMLDeserializerV11.test_minimal_request()
TestServerCreateRequestXMLDeserializerV11.test_multiple_metadata_items()
TestServerCreateRequestXMLDeserializerV11.test_multiple_personality_files()
TestServerCreateRequestXMLDeserializerV11.test_request_with_empty_networks()
TestServerCreateRequestXMLDeserializerV11.test_request_with_networks_duplicate_ids()
TestServerCreateRequestXMLDeserializerV11.test_request_with_one_network()
TestServerCreateRequestXMLDeserializerV11.test_request_with_one_network_empty_fixed_ip()
TestServerCreateRequestXMLDeserializerV11.test_request_with_one_network_empty_id()
TestServerCreateRequestXMLDeserializerV11.test_request_with_one_network_missing_fixed_ip()
TestServerCreateRequestXMLDeserializerV11.test_request_with_one_network_missing_id()
TestServerCreateRequestXMLDeserializerV11.test_request_with_second_network_node_ignored()
TestServerCreateRequestXMLDeserializerV11.test_request_with_two_networks()
TestServerCreateRequestXMLDeserializerV11.test_spec_request()
class nova.tests.api.openstack.test_servers.TestServerInstanceCreation(methodName='runTest')

Bases: nova.test.TestCase

TestServerInstanceCreation.setUp()
TestServerInstanceCreation.test_create_instance_admin_pass_json()
TestServerInstanceCreation.test_create_instance_admin_pass_xml()
TestServerInstanceCreation.test_create_instance_personality_empty_content()
TestServerInstanceCreation.test_create_instance_with_no_personality()
TestServerInstanceCreation.test_create_instance_with_no_personality_xml()
TestServerInstanceCreation.test_create_instance_with_null_personality()
TestServerInstanceCreation.test_create_instance_with_personality()
TestServerInstanceCreation.test_create_instance_with_personality_no_contents()
TestServerInstanceCreation.test_create_instance_with_personality_no_path()
TestServerInstanceCreation.test_create_instance_with_personality_not_a_list()
TestServerInstanceCreation.test_create_instance_with_personality_with_non_b64_content()
TestServerInstanceCreation.test_create_instance_with_personality_xml()
TestServerInstanceCreation.test_create_instance_with_three_personalities()
class nova.tests.api.openstack.test_servers.TestServerStatus(methodName='runTest')

Bases: nova.test.TestCase

TestServerStatus.test_active()
TestServerStatus.test_password_update()
TestServerStatus.test_reboot()
TestServerStatus.test_rebuild()
TestServerStatus.test_rebuild_error()
TestServerStatus.test_resize()
TestServerStatus.test_stopped()
TestServerStatus.test_verify_resize()
nova.tests.api.openstack.test_servers.fake_compute_api(cls, req, id)
nova.tests.api.openstack.test_servers.fake_gen_uuid()
nova.tests.api.openstack.test_servers.find_host(self, context, instance_id)
nova.tests.api.openstack.test_servers.instance_addresses(context, instance_id)
nova.tests.api.openstack.test_servers.instance_update(context, instance_id, values)
nova.tests.api.openstack.test_servers.return_security_group(context, instance_id, security_group_id)
nova.tests.api.openstack.test_servers.return_server_by_id(context, id)
nova.tests.api.openstack.test_servers.return_server_by_uuid(context, uuid)
nova.tests.api.openstack.test_servers.return_server_with_addresses(private, public)
nova.tests.api.openstack.test_servers.return_server_with_attributes(**kwargs)
nova.tests.api.openstack.test_servers.return_server_with_state(vm_state, task_state=None)
nova.tests.api.openstack.test_servers.return_server_with_uuid_and_state(vm_state, task_state)
nova.tests.api.openstack.test_servers.return_servers(context, *args, **kwargs)
nova.tests.api.openstack.test_servers.return_servers_by_reservation(context, reservation_id='')
nova.tests.api.openstack.test_servers.return_servers_by_reservation_empty(context, reservation_id='')
nova.tests.api.openstack.test_servers.return_servers_from_child_zones(*args, **kwargs)
nova.tests.api.openstack.test_servers.return_servers_from_child_zones_empty(*args, **kwargs)
nova.tests.api.openstack.test_servers.return_virtual_interface_by_instance(interfaces)
nova.tests.api.openstack.test_servers.return_virtual_interface_instance_nonexistant(interfaces)
nova.tests.api.openstack.test_servers.stub_instance(id, user_id='fake', project_id='fake', private_address=None, public_addresses=None, host=None, vm_state=None, task_state=None, reservation_id='', uuid='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', image_ref='10', flavor_id='1', interfaces=None, name=None, key_name='', access_ipv4=None, access_ipv6=None)

The test_sharedipgroups Module