summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-11-11 13:26:13 -0500
committerBrian Waldon <brian.waldon@rackspace.com>2011-11-17 10:09:15 -0800
commitde635fc882caebd5d5c9701e755a7174e37a05c5 (patch)
tree7f7414caef497db6b0c7710569391f52c246b8cc /nova
parentf14ec8a9e2ef9d7869e9834bd054e9c0e271ec31 (diff)
Creating new v2 namespace in nova.api.openstack
Related to blueprint separate-nova-adminapi Change-Id: Ida35372b7263c4a4efdafd35faa1325c4436459b
Diffstat (limited to 'nova')
-rw-r--r--nova/api/openstack/__init__.py187
-rw-r--r--nova/api/openstack/faults.py116
-rw-r--r--nova/api/openstack/v2/__init__.py186
-rw-r--r--nova/api/openstack/v2/accounts.py (renamed from nova/api/openstack/accounts.py)10
-rw-r--r--nova/api/openstack/v2/auth.py (renamed from nova/api/openstack/auth.py)30
-rw-r--r--nova/api/openstack/v2/consoles.py (renamed from nova/api/openstack/consoles.py)6
-rw-r--r--nova/api/openstack/v2/contrib/__init__.py (renamed from nova/api/openstack/contrib/__init__.py)2
-rw-r--r--nova/api/openstack/v2/contrib/admin_actions.py (renamed from nova/api/openstack/contrib/admin_actions.py)4
-rw-r--r--nova/api/openstack/v2/contrib/createserverext.py (renamed from nova/api/openstack/contrib/createserverext.py)6
-rw-r--r--nova/api/openstack/v2/contrib/deferred_delete.py (renamed from nova/api/openstack/contrib/deferred_delete.py)6
-rw-r--r--nova/api/openstack/v2/contrib/disk_config.py (renamed from nova/api/openstack/contrib/disk_config.py)6
-rw-r--r--nova/api/openstack/v2/contrib/extended_status.py (renamed from nova/api/openstack/contrib/extended_status.py)7
-rw-r--r--nova/api/openstack/v2/contrib/flavorextradata.py (renamed from nova/api/openstack/contrib/flavorextradata.py)6
-rw-r--r--nova/api/openstack/v2/contrib/flavorextraspecs.py (renamed from nova/api/openstack/contrib/flavorextraspecs.py)3
-rw-r--r--nova/api/openstack/v2/contrib/floating_ips.py (renamed from nova/api/openstack/contrib/floating_ips.py)5
-rw-r--r--nova/api/openstack/v2/contrib/hosts.py (renamed from nova/api/openstack/contrib/hosts.py)7
-rw-r--r--nova/api/openstack/v2/contrib/keypairs.py (renamed from nova/api/openstack/contrib/keypairs.py)2
-rw-r--r--nova/api/openstack/v2/contrib/multinic.py (renamed from nova/api/openstack/contrib/multinic.py)4
-rw-r--r--nova/api/openstack/v2/contrib/quotas.py (renamed from nova/api/openstack/contrib/quotas.py)2
-rw-r--r--nova/api/openstack/v2/contrib/rescue.py (renamed from nova/api/openstack/contrib/rescue.py)5
-rw-r--r--nova/api/openstack/v2/contrib/security_groups.py (renamed from nova/api/openstack/contrib/security_groups.py)14
-rw-r--r--nova/api/openstack/v2/contrib/simple_tenant_usage.py (renamed from nova/api/openstack/contrib/simple_tenant_usage.py)13
-rw-r--r--nova/api/openstack/v2/contrib/virtual_interfaces.py (renamed from nova/api/openstack/contrib/virtual_interfaces.py)8
-rw-r--r--nova/api/openstack/v2/contrib/virtual_storage_arrays.py (renamed from nova/api/openstack/contrib/virtual_storage_arrays.py)20
-rw-r--r--nova/api/openstack/v2/contrib/volumes.py (renamed from nova/api/openstack/contrib/volumes.py)8
-rw-r--r--nova/api/openstack/v2/contrib/volumetypes.py (renamed from nova/api/openstack/contrib/volumetypes.py)4
-rw-r--r--nova/api/openstack/v2/contrib/zones.py (renamed from nova/api/openstack/contrib/zones.py)4
-rw-r--r--nova/api/openstack/v2/extensions.py (renamed from nova/api/openstack/extensions.py)12
-rw-r--r--nova/api/openstack/v2/flavors.py (renamed from nova/api/openstack/flavors.py)4
-rw-r--r--nova/api/openstack/v2/image_metadata.py (renamed from nova/api/openstack/image_metadata.py)4
-rw-r--r--nova/api/openstack/v2/images.py (renamed from nova/api/openstack/images.py)12
-rw-r--r--nova/api/openstack/v2/ips.py (renamed from nova/api/openstack/ips.py)5
-rw-r--r--nova/api/openstack/v2/limits.py (renamed from nova/api/openstack/limits.py)18
-rw-r--r--nova/api/openstack/v2/ratelimiting/__init__.py (renamed from nova/api/openstack/ratelimiting/__init__.py)5
-rw-r--r--nova/api/openstack/v2/schemas/atom-link.rng (renamed from nova/api/openstack/schemas/atom-link.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/atom.rng (renamed from nova/api/openstack/schemas/atom.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/addresses.rng (renamed from nova/api/openstack/schemas/v1.1/addresses.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/extension.rng (renamed from nova/api/openstack/schemas/v1.1/extension.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/extensions.rng (renamed from nova/api/openstack/schemas/v1.1/extensions.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/flavor.rng (renamed from nova/api/openstack/schemas/v1.1/flavor.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/flavors.rng (renamed from nova/api/openstack/schemas/v1.1/flavors.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/flavors_index.rng (renamed from nova/api/openstack/schemas/v1.1/flavors_index.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/image.rng (renamed from nova/api/openstack/schemas/v1.1/image.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/images.rng (renamed from nova/api/openstack/schemas/v1.1/images.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/images_index.rng (renamed from nova/api/openstack/schemas/v1.1/images_index.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/limits.rng (renamed from nova/api/openstack/schemas/v1.1/limits.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/metadata.rng (renamed from nova/api/openstack/schemas/v1.1/metadata.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/server.rng (renamed from nova/api/openstack/schemas/v1.1/server.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/servers.rng (renamed from nova/api/openstack/schemas/v1.1/servers.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/servers_index.rng (renamed from nova/api/openstack/schemas/v1.1/servers_index.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/version.rng (renamed from nova/api/openstack/schemas/v1.1/version.rng)0
-rw-r--r--nova/api/openstack/v2/schemas/v1.1/versions.rng (renamed from nova/api/openstack/schemas/v1.1/versions.rng)0
-rw-r--r--nova/api/openstack/v2/server_metadata.py (renamed from nova/api/openstack/server_metadata.py)2
-rw-r--r--nova/api/openstack/v2/servers.py (renamed from nova/api/openstack/servers.py)13
-rw-r--r--nova/api/openstack/v2/urlmap.py (renamed from nova/api/openstack/urlmap.py)2
-rw-r--r--nova/api/openstack/v2/users.py (renamed from nova/api/openstack/users.py)8
-rw-r--r--nova/api/openstack/v2/versions.py (renamed from nova/api/openstack/versions.py)7
-rw-r--r--nova/api/openstack/v2/views/__init__.py (renamed from nova/api/openstack/views/__init__.py)0
-rw-r--r--nova/api/openstack/v2/views/addresses.py (renamed from nova/api/openstack/views/addresses.py)2
-rw-r--r--nova/api/openstack/v2/views/flavors.py (renamed from nova/api/openstack/views/flavors.py)1
-rw-r--r--nova/api/openstack/v2/views/images.py (renamed from nova/api/openstack/views/images.py)0
-rw-r--r--nova/api/openstack/v2/views/limits.py (renamed from nova/api/openstack/views/limits.py)0
-rw-r--r--nova/api/openstack/v2/views/servers.py (renamed from nova/api/openstack/views/servers.py)11
-rw-r--r--nova/api/openstack/v2/views/versions.py (renamed from nova/api/openstack/views/versions.py)0
-rw-r--r--nova/api/openstack/v2/zones.py (renamed from nova/api/openstack/zones.py)14
-rw-r--r--nova/api/openstack/wsgi.py107
-rw-r--r--nova/api/openstack/xmlutil.py4
-rw-r--r--nova/flags.py2
-rw-r--r--nova/tests/api/openstack/__init__.py16
-rw-r--r--nova/tests/api/openstack/fakes.py53
-rw-r--r--nova/tests/api/openstack/test_faults.py11
-rw-r--r--nova/tests/api/openstack/v2/__init__.py16
-rw-r--r--nova/tests/api/openstack/v2/contrib/__init__.py (renamed from nova/tests/api/openstack/contrib/__init__.py)0
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_admin_actions.py (renamed from nova/tests/api/openstack/contrib/test_admin_actions.py)0
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_createserverext.py (renamed from nova/tests/api/openstack/contrib/test_createserverext.py)2
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_disk_config.py (renamed from nova/tests/api/openstack/contrib/test_disk_config.py)16
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_extendedstatus.py (renamed from nova/tests/api/openstack/contrib/test_extendedstatus.py)1
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_flavors_extra_specs.py (renamed from nova/tests/api/openstack/contrib/test_flavors_extra_specs.py)9
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_floating_ips.py (renamed from nova/tests/api/openstack/contrib/test_floating_ips.py)13
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_keypairs.py (renamed from nova/tests/api/openstack/contrib/test_keypairs.py)3
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_multinic_xs.py (renamed from nova/tests/api/openstack/contrib/test_multinic_xs.py)1
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_quotas.py (renamed from nova/tests/api/openstack/contrib/test_quotas.py)3
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_rescue.py (renamed from nova/tests/api/openstack/contrib/test_rescue.py)1
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_security_groups.py (renamed from nova/tests/api/openstack/contrib/test_security_groups.py)9
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_simple_tenant_usage.py (renamed from nova/tests/api/openstack/contrib/test_simple_tenant_usage.py)2
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_virtual_interfaces.py (renamed from nova/tests/api/openstack/contrib/test_virtual_interfaces.py)7
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_volume_types.py (renamed from nova/tests/api/openstack/contrib/test_volume_types.py)6
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_volume_types_extra_specs.py (renamed from nova/tests/api/openstack/contrib/test_volume_types_extra_specs.py)9
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_volumes.py (renamed from nova/tests/api/openstack/contrib/test_volumes.py)3
-rw-r--r--nova/tests/api/openstack/v2/contrib/test_vsa.py (renamed from nova/tests/api/openstack/contrib/test_vsa.py)13
-rw-r--r--nova/tests/api/openstack/v2/extensions/__init__.py (renamed from nova/tests/api/openstack/extensions/__init__.py)0
-rw-r--r--nova/tests/api/openstack/v2/extensions/foxinsocks.py (renamed from nova/tests/api/openstack/extensions/foxinsocks.py)2
-rw-r--r--nova/tests/api/openstack/v2/test_accounts.py (renamed from nova/tests/api/openstack/test_accounts.py)2
-rw-r--r--nova/tests/api/openstack/v2/test_api.py (renamed from nova/tests/api/openstack/test_api.py)11
-rw-r--r--nova/tests/api/openstack/v2/test_auth.py (renamed from nova/tests/api/openstack/test_auth.py)18
-rw-r--r--nova/tests/api/openstack/v2/test_consoles.py (renamed from nova/tests/api/openstack/test_consoles.py)2
-rw-r--r--nova/tests/api/openstack/v2/test_extensions.py (renamed from nova/tests/api/openstack/test_extensions.py)41
-rw-r--r--nova/tests/api/openstack/v2/test_flavors.py (renamed from nova/tests/api/openstack/test_flavors.py)2
-rw-r--r--nova/tests/api/openstack/v2/test_image_metadata.py (renamed from nova/tests/api/openstack/test_image_metadata.py)5
-rw-r--r--nova/tests/api/openstack/v2/test_images.py (renamed from nova/tests/api/openstack/test_images.py)7
-rw-r--r--nova/tests/api/openstack/v2/test_limits.py (renamed from nova/tests/api/openstack/test_limits.py)13
-rw-r--r--nova/tests/api/openstack/v2/test_server_actions.py (renamed from nova/tests/api/openstack/test_server_actions.py)25
-rw-r--r--nova/tests/api/openstack/v2/test_server_metadata.py (renamed from nova/tests/api/openstack/test_server_metadata.py)4
-rw-r--r--nova/tests/api/openstack/v2/test_servers.py (renamed from nova/tests/api/openstack/test_servers.py)17
-rw-r--r--nova/tests/api/openstack/v2/test_urlmap.py (renamed from nova/tests/api/openstack/test_urlmap.py)4
-rw-r--r--nova/tests/api/openstack/v2/test_users.py (renamed from nova/tests/api/openstack/test_users.py)2
-rw-r--r--nova/tests/api/openstack/v2/test_versions.py (renamed from nova/tests/api/openstack/test_versions.py)4
-rw-r--r--nova/tests/api/openstack/v2/test_zones.py (renamed from nova/tests/api/openstack/test_zones.py)8
-rw-r--r--nova/tests/integrated/test_extensions.py2
-rw-r--r--nova/tests/test_hosts.py3
110 files changed, 620 insertions, 650 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 07911221d..e69de29bb 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -1,187 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""
-WSGI middleware for OpenStack API controllers.
-"""
-
-import routes
-import webob.dec
-import webob.exc
-
-from nova.api.openstack import accounts
-from nova.api.openstack import faults
-from nova.api.openstack import consoles
-from nova.api.openstack import flavors
-from nova.api.openstack import images
-from nova.api.openstack import image_metadata
-from nova.api.openstack import ips
-from nova.api.openstack import limits
-from nova.api.openstack import servers
-from nova.api.openstack import server_metadata
-from nova.api.openstack import users
-from nova.api.openstack import versions
-from nova.api.openstack import wsgi
-from nova.api.openstack import zones
-from nova import flags
-from nova import log as logging
-from nova import wsgi as base_wsgi
-
-
-LOG = logging.getLogger('nova.api.openstack')
-FLAGS = flags.FLAGS
-flags.DEFINE_bool('allow_admin_api',
- False,
- 'When True, this API service will accept admin operations.')
-flags.DEFINE_bool('allow_instance_snapshots',
- True,
- 'When True, this API service will permit instance snapshot operations.')
-
-
-class FaultWrapper(base_wsgi.Middleware):
- """Calls down the middleware stack, making exceptions into faults."""
-
- @webob.dec.wsgify(RequestClass=wsgi.Request)
- def __call__(self, req):
- try:
- return req.get_response(self.application)
- except Exception as ex:
- LOG.exception(_("Caught error: %s"), unicode(ex))
- exc = webob.exc.HTTPInternalServerError()
- return faults.Fault(exc)
-
-
-class APIMapper(routes.Mapper):
- def routematch(self, url=None, environ=None):
- if url is "":
- result = self._match("", environ)
- return result[0], result[1]
- return routes.Mapper.routematch(self, url, environ)
-
-
-class ProjectMapper(APIMapper):
-
- def resource(self, member_name, collection_name, **kwargs):
- if not ('parent_resource' in kwargs):
- kwargs['path_prefix'] = '{project_id}/'
- else:
- parent_resource = kwargs['parent_resource']
- p_collection = parent_resource['collection_name']
- p_member = parent_resource['member_name']
- kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection,
- p_member)
- routes.Mapper.resource(self, member_name,
- collection_name,
- **kwargs)
-
-
-class APIRouter(base_wsgi.Router):
- """
- Routes requests on the OpenStack API to the appropriate controller
- and method.
- """
-
- @classmethod
- def factory(cls, global_config, **local_config):
- """Simple paste factory, :class:`nova.wsgi.Router` doesn't have one"""
- return cls()
-
- def __init__(self, ext_mgr=None):
- self.server_members = {}
- mapper = ProjectMapper()
- self._setup_routes(mapper)
- super(APIRouter, self).__init__(mapper)
-
- def _setup_routes(self, mapper):
- server_members = self.server_members
- server_members['action'] = 'POST'
- if FLAGS.allow_admin_api:
- LOG.debug(_("Including admin operations in API."))
-
- server_members['diagnostics'] = 'GET'
- server_members['actions'] = 'GET'
-
- mapper.resource("user", "users",
- controller=users.create_resource(),
- collection={'detail': 'GET'})
-
- mapper.resource("account", "accounts",
- controller=accounts.create_resource(),
- collection={'detail': 'GET'})
-
- mapper.resource("zone", "zones",
- controller=zones.create_resource(),
- collection={'detail': 'GET',
- 'info': 'GET',
- 'select': 'POST'})
-
- mapper.connect("versions", "/",
- controller=versions.create_resource(),
- action='show')
-
- mapper.redirect("", "/")
-
- mapper.resource("console", "consoles",
- controller=consoles.create_resource(),
- parent_resource=dict(member_name='server',
- collection_name='servers'))
-
- mapper.resource("server", "servers",
- controller=servers.create_resource(),
- collection={'detail': 'GET'},
- member=self.server_members)
-
- mapper.resource("ip", "ips", controller=ips.create_resource(),
- parent_resource=dict(member_name='server',
- collection_name='servers'))
-
- mapper.resource("image", "images",
- controller=images.create_resource(),
- collection={'detail': 'GET'})
-
- mapper.resource("limit", "limits",
- controller=limits.create_resource())
-
- mapper.resource("flavor", "flavors",
- controller=flavors.create_resource(),
- collection={'detail': 'GET'})
-
- image_metadata_controller = image_metadata.create_resource()
-
- mapper.resource("image_meta", "metadata",
- controller=image_metadata_controller,
- parent_resource=dict(member_name='image',
- collection_name='images'))
-
- mapper.connect("metadata", "/{project_id}/images/{image_id}/metadata",
- controller=image_metadata_controller,
- action='update_all',
- conditions={"method": ['PUT']})
-
- server_metadata_controller = server_metadata.create_resource()
-
- mapper.resource("server_meta", "metadata",
- controller=server_metadata_controller,
- parent_resource=dict(member_name='server',
- collection_name='servers'))
-
- mapper.connect("metadata",
- "/{project_id}/servers/{server_id}/metadata",
- controller=server_metadata_controller,
- action='update_all',
- conditions={"method": ['PUT']})
diff --git a/nova/api/openstack/faults.py b/nova/api/openstack/faults.py
deleted file mode 100644
index 83381d755..000000000
--- a/nova/api/openstack/faults.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-import webob.dec
-import webob.exc
-
-from nova.api.openstack import common
-from nova.api.openstack import wsgi
-
-
-class Fault(webob.exc.HTTPException):
- """Wrap webob.exc.HTTPException to provide API friendly response."""
-
- _fault_names = {
- 400: "badRequest",
- 401: "unauthorized",
- 403: "resizeNotAllowed",
- 404: "itemNotFound",
- 405: "badMethod",
- 409: "inProgress",
- 413: "overLimit",
- 415: "badMediaType",
- 501: "notImplemented",
- 503: "serviceUnavailable"}
-
- def __init__(self, exception):
- """Create a Fault for the given webob.exc.exception."""
- self.wrapped_exc = exception
- self.status_int = exception.status_int
-
- @webob.dec.wsgify(RequestClass=wsgi.Request)
- def __call__(self, req):
- """Generate a WSGI response based on the exception passed to ctor."""
- # Replace the body with fault details.
- code = self.wrapped_exc.status_int
- fault_name = self._fault_names.get(code, "cloudServersFault")
- fault_data = {
- fault_name: {
- 'code': code,
- 'message': self.wrapped_exc.explanation}}
- if code == 413:
- retry = self.wrapped_exc.headers['Retry-After']
- fault_data[fault_name]['retryAfter'] = retry
-
- # 'code' is an attribute on the fault tag itself
- metadata = {'attributes': {fault_name: 'code'}}
-
- xml_serializer = wsgi.XMLDictSerializer(metadata, wsgi.XMLNS_V11)
-
- content_type = req.best_match_content_type()
- serializer = {
- 'application/xml': xml_serializer,
- 'application/json': wsgi.JSONDictSerializer(),
- }[content_type]
-
- self.wrapped_exc.body = serializer.serialize(fault_data)
- self.wrapped_exc.content_type = content_type
-
- return self.wrapped_exc
-
- def __str__(self):
- return self.wrapped_exc.__str__()
-
-
-class OverLimitFault(webob.exc.HTTPException):
- """
- Rate-limited request response.
- """
-
- def __init__(self, message, details, retry_time):
- """
- Initialize new `OverLimitFault` with relevant information.
- """
- self.wrapped_exc = webob.exc.HTTPRequestEntityTooLarge()
- self.content = {
- "overLimitFault": {
- "code": self.wrapped_exc.status_int,
- "message": message,
- "details": details,
- },
- }
-
- @webob.dec.wsgify(RequestClass=wsgi.Request)
- def __call__(self, request):
- """
- Return the wrapped exception with a serialized body conforming to our
- error format.
- """
- content_type = request.best_match_content_type()
- metadata = {"attributes": {"overLimitFault": "code"}}
-
- xml_serializer = wsgi.XMLDictSerializer(metadata, wsgi.XMLNS_V11)
- serializer = {
- 'application/xml': xml_serializer,
- 'application/json': wsgi.JSONDictSerializer(),
- }[content_type]
-
- content = serializer.serialize(self.content)
- self.wrapped_exc.body = content
-
- return self.wrapped_exc
diff --git a/nova/api/openstack/v2/__init__.py b/nova/api/openstack/v2/__init__.py
new file mode 100644
index 000000000..1ea2ba250
--- /dev/null
+++ b/nova/api/openstack/v2/__init__.py
@@ -0,0 +1,186 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+WSGI middleware for OpenStack API controllers.
+"""
+
+import routes
+import webob.dec
+import webob.exc
+
+from nova.api.openstack.v2 import accounts
+from nova.api.openstack.v2 import consoles
+from nova.api.openstack.v2 import flavors
+from nova.api.openstack.v2 import images
+from nova.api.openstack.v2 import image_metadata
+from nova.api.openstack.v2 import ips
+from nova.api.openstack.v2 import limits
+from nova.api.openstack.v2 import servers
+from nova.api.openstack.v2 import server_metadata
+from nova.api.openstack.v2 import users
+from nova.api.openstack.v2 import versions
+from nova.api.openstack.v2 import zones
+from nova.api.openstack import wsgi
+from nova import flags
+from nova import log as logging
+from nova import wsgi as base_wsgi
+
+
+LOG = logging.getLogger('nova.api.openstack.v2')
+FLAGS = flags.FLAGS
+flags.DEFINE_bool('allow_admin_api',
+ False,
+ 'When True, this API service will accept admin operations.')
+flags.DEFINE_bool('allow_instance_snapshots',
+ True,
+ 'When True, this API service will permit instance snapshot operations.')
+
+
+class FaultWrapper(base_wsgi.Middleware):
+ """Calls down the middleware stack, making exceptions into faults."""
+
+ @webob.dec.wsgify(RequestClass=wsgi.Request)
+ def __call__(self, req):
+ try:
+ return req.get_response(self.application)
+ except Exception as ex:
+ LOG.exception(_("Caught error: %s"), unicode(ex))
+ exc = webob.exc.HTTPInternalServerError()
+ return wsgi.Fault(exc)
+
+
+class APIMapper(routes.Mapper):
+ def routematch(self, url=None, environ=None):
+ if url is "":
+ result = self._match("", environ)
+ return result[0], result[1]
+ return routes.Mapper.routematch(self, url, environ)
+
+
+class ProjectMapper(APIMapper):
+
+ def resource(self, member_name, collection_name, **kwargs):
+ if not ('parent_resource' in kwargs):
+ kwargs['path_prefix'] = '{project_id}/'
+ else:
+ parent_resource = kwargs['parent_resource']
+ p_collection = parent_resource['collection_name']
+ p_member = parent_resource['member_name']
+ kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection,
+ p_member)
+ routes.Mapper.resource(self, member_name,
+ collection_name,
+ **kwargs)
+
+
+class APIRouter(base_wsgi.Router):
+ """
+ Routes requests on the OpenStack API to the appropriate controller
+ and method.
+ """
+
+ @classmethod
+ def factory(cls, global_config, **local_config):
+ """Simple paste factory, :class:`nova.wsgi.Router` doesn't have one"""
+ return cls()
+
+ def __init__(self, ext_mgr=None):
+ self.server_members = {}
+ mapper = ProjectMapper()
+ self._setup_routes(mapper)
+ super(APIRouter, self).__init__(mapper)
+
+ def _setup_routes(self, mapper):
+ server_members = self.server_members
+ server_members['action'] = 'POST'
+ if FLAGS.allow_admin_api:
+ LOG.debug(_("Including admin operations in API."))
+
+ server_members['diagnostics'] = 'GET'
+ server_members['actions'] = 'GET'
+
+ mapper.resource("user", "users",
+ controller=users.create_resource(),
+ collection={'detail': 'GET'})
+
+ mapper.resource("account", "accounts",
+ controller=accounts.create_resource(),
+ collection={'detail': 'GET'})
+
+ mapper.resource("zone", "zones",
+ controller=zones.create_resource(),
+ collection={'detail': 'GET',
+ 'info': 'GET',
+ 'select': 'POST'})
+
+ mapper.connect("versions", "/",
+ controller=versions.create_resource(),
+ action='show')
+
+ mapper.redirect("", "/")
+
+ mapper.resource("console", "consoles",
+ controller=consoles.create_resource(),
+ parent_resource=dict(member_name='server',
+ collection_name='servers'))
+
+ mapper.resource("server", "servers",
+ controller=servers.create_resource(),
+ collection={'detail': 'GET'},
+ member=self.server_members)
+
+ mapper.resource("ip", "ips", controller=ips.create_resource(),
+ parent_resource=dict(member_name='server',
+ collection_name='servers'))
+
+ mapper.resource("image", "images",
+ controller=images.create_resource(),
+ collection={'detail': 'GET'})
+
+ mapper.resource("limit", "limits",
+ controller=limits.create_resource())
+
+ mapper.resource("flavor", "flavors",
+ controller=flavors.create_resource(),
+ collection={'detail': 'GET'})
+
+ image_metadata_controller = image_metadata.create_resource()
+
+ mapper.resource("image_meta", "metadata",
+ controller=image_metadata_controller,
+ parent_resource=dict(member_name='image',
+ collection_name='images'))
+
+ mapper.connect("metadata", "/{project_id}/images/{image_id}/metadata",
+ controller=image_metadata_controller,
+ action='update_all',
+ conditions={"method": ['PUT']})
+
+ server_metadata_controller = server_metadata.create_resource()
+
+ mapper.resource("server_meta", "metadata",
+ controller=server_metadata_controller,
+ parent_resource=dict(member_name='server',
+ collection_name='servers'))
+
+ mapper.connect("metadata",
+ "/{project_id}/servers/{server_id}/metadata",
+ controller=server_metadata_controller,
+ action='update_all',
+ conditions={"method": ['PUT']})
diff --git a/nova/api/openstack/accounts.py b/nova/api/openstack/v2/accounts.py
index 3a19d5c89..0f1584261 100644
--- a/nova/api/openstack/accounts.py
+++ b/nova/api/openstack/v2/accounts.py
@@ -15,18 +15,16 @@
import webob.exc
+from nova.api.openstack import wsgi
+from nova.api.openstack import xmlutil
+from nova.auth import manager
from nova import exception
from nova import flags
from nova import log as logging
-from nova.auth import manager
-from nova.api.openstack import faults
-from nova.api.openstack import wsgi
-from nova.api.openstack import xmlutil
-
FLAGS = flags.FLAGS
-LOG = logging.getLogger('nova.api.openstack')
+LOG = logging.getLogger('nova.api.openstack.v2.accounts')
def _translate_keys(account):
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/v2/auth.py
index d435f8318..c0ea30671 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/v2/auth.py
@@ -19,25 +19,25 @@ import hashlib
import os
import time
-import webob.exc
import webob.dec
+import webob.exc
+from nova.api.openstack import common
+from nova.api.openstack import wsgi
from nova import auth
from nova import context
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils
-from nova import wsgi
-from nova.api.openstack import common
-from nova.api.openstack import faults
+from nova import wsgi as base_wsgi
-LOG = logging.getLogger('nova.api.openstack')
+LOG = logging.getLogger('nova.api.openstack.v2.auth')
FLAGS = flags.FLAGS
flags.DECLARE('use_forwarded_for', 'nova.api.auth')
-class NoAuthMiddleware(wsgi.Middleware):
+class NoAuthMiddleware(base_wsgi.Middleware):
"""Return a fake token if one isn't specified."""
@webob.dec.wsgify(RequestClass=wsgi.Request)
@@ -73,7 +73,7 @@ class NoAuthMiddleware(wsgi.Middleware):
return self.application
-class AuthMiddleware(wsgi.Middleware):
+class AuthMiddleware(base_wsgi.Middleware):
"""Authorize the openstack API request or return an HTTP Forbidden."""
def __init__(self, application, db_driver=None):
@@ -92,12 +92,12 @@ class AuthMiddleware(wsgi.Middleware):
token = req.headers["X-Auth-Token"]
msg = _("%(user_id)s could not be found with token '%(token)s'")
LOG.warn(msg % locals())
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
# Get all valid projects for the user
projects = self.auth.get_projects(user_id)
if not projects:
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
project_id = ""
path_parts = req.path.split('/')
@@ -110,9 +110,9 @@ class AuthMiddleware(wsgi.Middleware):
try:
project = self.auth.get_project(project_id)
except exception.ProjectNotFound:
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
if project_id not in [p.id for p in projects]:
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
else:
# As a fallback, set project_id from the headers, which is the v1.0
# behavior. As a last resort, be forgiving to the user and set
@@ -137,7 +137,7 @@ class AuthMiddleware(wsgi.Middleware):
msg = _("%(user_id)s must be an admin or a "
"member of %(project_id)s")
LOG.warn(msg % locals())
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
return self.application
@@ -155,7 +155,7 @@ class AuthMiddleware(wsgi.Middleware):
msg = _("Authentication requests must be made against a version "
"root (e.g. /v1.0 or /v1.1).")
LOG.warn(msg)
- return faults.Fault(webob.exc.HTTPUnauthorized(explanation=msg))
+ return wsgi.Fault(webob.exc.HTTPUnauthorized(explanation=msg))
def _get_auth_header(key):
"""Ensures that the KeyError returned is meaningful."""
@@ -169,7 +169,7 @@ class AuthMiddleware(wsgi.Middleware):
except KeyError as ex:
msg = _("Could not find %s in request.") % ex
LOG.warn(msg)
- return faults.Fault(webob.exc.HTTPUnauthorized(explanation=msg))
+ return wsgi.Fault(webob.exc.HTTPUnauthorized(explanation=msg))
token, user = self._authorize_user(username, key, req)
if user and token:
@@ -184,7 +184,7 @@ class AuthMiddleware(wsgi.Middleware):
LOG.debug(_("Successfully authenticated '%s'") % username)
return res
else:
- return faults.Fault(webob.exc.HTTPUnauthorized())
+ return wsgi.Fault(webob.exc.HTTPUnauthorized())
def authorize_token(self, token_hash):
""" retrieves user information from the datastore given a token
diff --git a/nova/api/openstack/consoles.py b/nova/api/openstack/v2/consoles.py
index 7d8c0523e..ad0d8cbb4 100644
--- a/nova/api/openstack/consoles.py
+++ b/nova/api/openstack/v2/consoles.py
@@ -15,13 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-from webob import exc
import webob
+from webob import exc
-from nova import console
-from nova import exception
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
+from nova import console
+from nova import exception
def _translate_keys(cons):
diff --git a/nova/api/openstack/contrib/__init__.py b/nova/api/openstack/v2/contrib/__init__.py
index b3d4df69b..d361dac9c 100644
--- a/nova/api/openstack/contrib/__init__.py
+++ b/nova/api/openstack/v2/contrib/__init__.py
@@ -28,7 +28,7 @@ from nova import log as logging
from nova import utils
-LOG = logging.getLogger('nova.api.openstack.contrib')
+LOG = logging.getLogger('nova.api.openstack.v2.contrib')
def standard_extensions(ext_mgr):
diff --git a/nova/api/openstack/contrib/admin_actions.py b/nova/api/openstack/v2/contrib/admin_actions.py
index 81b23a8a0..632a8dc0e 100644
--- a/nova/api/openstack/contrib/admin_actions.py
+++ b/nova/api/openstack/v2/contrib/admin_actions.py
@@ -19,16 +19,16 @@ import traceback
import webob
from webob import exc
+from nova.api.openstack.v2 import extensions
from nova import compute
from nova import exception
from nova import flags
from nova import log as logging
-from nova.api.openstack import extensions
from nova.scheduler import api as scheduler_api
FLAGS = flags.FLAGS
-LOG = logging.getLogger("nova.api.openstack.contrib.admin_actions")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.admin_actions")
class Admin_actions(extensions.ExtensionDescriptor):
diff --git a/nova/api/openstack/contrib/createserverext.py b/nova/api/openstack/v2/contrib/createserverext.py
index 4e6556f5d..a207d1bc5 100644
--- a/nova/api/openstack/contrib/createserverext.py
+++ b/nova/api/openstack/v2/contrib/createserverext.py
@@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License
-from nova.api.openstack import extensions
-from nova.api.openstack import servers
-from nova.api.openstack import views
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import servers
+from nova.api.openstack.v2 import views
from nova.api.openstack import wsgi
diff --git a/nova/api/openstack/contrib/deferred_delete.py b/nova/api/openstack/v2/contrib/deferred_delete.py
index 8415ca4b3..95eb8f42c 100644
--- a/nova/api/openstack/contrib/deferred_delete.py
+++ b/nova/api/openstack/v2/contrib/deferred_delete.py
@@ -17,13 +17,13 @@
import webob
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import servers
from nova import compute
from nova import log as logging
-from nova.api.openstack import extensions
-from nova.api.openstack import servers
-LOG = logging.getLogger("nova.api.contrib.deferred-delete")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.deferred-delete")
class Deferred_delete(extensions.ExtensionDescriptor):
diff --git a/nova/api/openstack/contrib/disk_config.py b/nova/api/openstack/v2/contrib/disk_config.py
index 20da999a7..6e26c1daa 100644
--- a/nova/api/openstack/contrib/disk_config.py
+++ b/nova/api/openstack/v2/contrib/disk_config.py
@@ -16,11 +16,11 @@
"""Disk Config extension."""
-from webob import exc
from xml.dom import minidom
-from nova.api.openstack import extensions
-from nova.api.openstack import servers
+from webob import exc
+
+from nova.api.openstack.v2 import extensions
from nova.api.openstack import xmlutil
from nova import compute
from nova import log as logging
diff --git a/nova/api/openstack/contrib/extended_status.py b/nova/api/openstack/v2/contrib/extended_status.py
index 625f3ab2b..5e0a69780 100644
--- a/nova/api/openstack/contrib/extended_status.py
+++ b/nova/api/openstack/v2/contrib/extended_status.py
@@ -19,17 +19,16 @@ import traceback
import webob
from webob import exc
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack import xmlutil
from nova import compute
from nova import exception
from nova import flags
from nova import log as logging
-from nova.api.openstack import extensions
-from nova.api.openstack import faults
-from nova.api.openstack import xmlutil
FLAGS = flags.FLAGS
-LOG = logging.getLogger("nova.api.openstack.contrib.extendedstatus")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.extendedstatus")
class Extended_status(extensions.ExtensionDescriptor):
diff --git a/nova/api/openstack/contrib/flavorextradata.py b/nova/api/openstack/v2/contrib/flavorextradata.py
index f696d161b..0b0938054 100644
--- a/nova/api/openstack/contrib/flavorextradata.py
+++ b/nova/api/openstack/v2/contrib/flavorextradata.py
@@ -1,3 +1,5 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
# Copyright 2011 Canonical Ltd.
# All Rights Reserved.
#
@@ -22,7 +24,7 @@ attributes. This extension adds to that list:
swap
"""
-from nova.api.openstack import extensions
+from nova.api.openstack.v2 import extensions
class Flavorextradata(extensions.ExtensionDescriptor):
@@ -32,5 +34,3 @@ class Flavorextradata(extensions.ExtensionDescriptor):
alias = "os-flavor-extra-data"
namespace = "http://docs.openstack.org/ext/flavor_extra_data/api/v1.1"
updated = "2011-09-14T00:00:00+00:00"
-
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
diff --git a/nova/api/openstack/contrib/flavorextraspecs.py b/nova/api/openstack/v2/contrib/flavorextraspecs.py
index d71e9cf8b..bb38ea64e 100644
--- a/nova/api/openstack/contrib/flavorextraspecs.py
+++ b/nova/api/openstack/v2/contrib/flavorextraspecs.py
@@ -19,10 +19,9 @@
from webob import exc
+from nova.api.openstack.v2 import extensions
from nova import db
from nova import exception
-from nova.api.openstack import extensions
-from nova.api.openstack import wsgi
class FlavorExtraSpecsController(object):
diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/v2/contrib/floating_ips.py
index b64251e53..9689eac48 100644
--- a/nova/api/openstack/contrib/floating_ips.py
+++ b/nova/api/openstack/v2/contrib/floating_ips.py
@@ -15,17 +15,18 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License
+
import webob
+from nova.api.openstack.v2 import extensions
from nova import compute
from nova import exception
from nova import log as logging
from nova import network
from nova import rpc
-from nova.api.openstack import extensions
-LOG = logging.getLogger('nova.api.openstack.contrib.floating_ips')
+LOG = logging.getLogger('nova.api.openstack.v2.contrib.floating_ips')
def _translate_floating_ip_view(floating_ip):
diff --git a/nova/api/openstack/contrib/hosts.py b/nova/api/openstack/v2/contrib/hosts.py
index 736843c3d..eb5074520 100644
--- a/nova/api/openstack/contrib/hosts.py
+++ b/nova/api/openstack/v2/contrib/hosts.py
@@ -17,17 +17,16 @@
import webob.exc
+from nova.api.openstack import common
+from nova.api.openstack.v2 import extensions
from nova import compute
from nova import exception
from nova import flags
from nova import log as logging
-from nova.api.openstack import common
-from nova.api.openstack import extensions
-from nova.api.openstack import faults
from nova.scheduler import api as scheduler_api
-LOG = logging.getLogger("nova.api.hosts")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.hosts")
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/contrib/keypairs.py b/nova/api/openstack/v2/contrib/keypairs.py
index ee5cad530..e57d40001 100644
--- a/nova/api/openstack/contrib/keypairs.py
+++ b/nova/api/openstack/v2/contrib/keypairs.py
@@ -24,10 +24,10 @@ import tempfile
import webob
from webob import exc
+from nova.api.openstack.v2 import extensions
from nova import crypto
from nova import db
from nova import exception
-from nova.api.openstack import extensions
class KeypairController(object):
diff --git a/nova/api/openstack/contrib/multinic.py b/nova/api/openstack/v2/contrib/multinic.py
index 26968646d..561e246b5 100644
--- a/nova/api/openstack/contrib/multinic.py
+++ b/nova/api/openstack/v2/contrib/multinic.py
@@ -18,13 +18,13 @@
import webob
from webob import exc
-from nova.api.openstack import extensions
+from nova.api.openstack.v2 import extensions
from nova import compute
from nova import exception
from nova import log as logging
-LOG = logging.getLogger("nova.api.multinic")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.multinic")
# Note: The class name is as it has to be for this to be loaded as an
diff --git a/nova/api/openstack/contrib/quotas.py b/nova/api/openstack/v2/contrib/quotas.py
index 184b4d12f..7ad426c44 100644
--- a/nova/api/openstack/contrib/quotas.py
+++ b/nova/api/openstack/v2/contrib/quotas.py
@@ -17,10 +17,10 @@
import webob
+from nova.api.openstack.v2 import extensions
from nova import db
from nova import exception
from nova import quota
-from nova.api.openstack import extensions
class QuotaSetsController(object):
diff --git a/nova/api/openstack/contrib/rescue.py b/nova/api/openstack/v2/contrib/rescue.py
index d3f38b200..b63bf9ec5 100644
--- a/nova/api/openstack/contrib/rescue.py
+++ b/nova/api/openstack/v2/contrib/rescue.py
@@ -17,8 +17,7 @@
import webob
from webob import exc
-from nova.api.openstack import extensions as exts
-from nova.api.openstack import faults
+from nova.api.openstack.v2 import extensions as exts
from nova import compute
from nova import exception
from nova import flags
@@ -27,7 +26,7 @@ from nova import utils
FLAGS = flags.FLAGS
-LOG = logging.getLogger("nova.api.contrib.rescue")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.rescue")
class Rescue(exts.ExtensionDescriptor):
diff --git a/nova/api/openstack/contrib/security_groups.py b/nova/api/openstack/v2/contrib/security_groups.py
index fd1187629..50f129bd6 100644
--- a/nova/api/openstack/contrib/security_groups.py
+++ b/nova/api/openstack/v2/contrib/security_groups.py
@@ -16,25 +16,23 @@
"""The security groups extension."""
import urllib
+from xml.dom import minidom
+
from webob import exc
import webob
+from nova.api.openstack import common
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack import wsgi
from nova import compute
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
-from nova import rpc
from nova import utils
-from nova.api.openstack import common
-from nova.api.openstack import extensions
-from nova.api.openstack import wsgi
-from nova.compute import power_state
-
-from xml.dom import minidom
-LOG = logging.getLogger("nova.api.contrib.security_groups")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.security_groups")
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/contrib/simple_tenant_usage.py b/nova/api/openstack/v2/contrib/simple_tenant_usage.py
index 3399ac2be..e896371ed 100644
--- a/nova/api/openstack/contrib/simple_tenant_usage.py
+++ b/nova/api/openstack/v2/contrib/simple_tenant_usage.py
@@ -15,17 +15,18 @@
# License for the specific language governing permissions and limitations
# under the License.
+from datetime import datetime
import urlparse
+
import webob
+from webob import exc
-from datetime import datetime
-from nova import exception
-from nova import flags
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import views
from nova.compute import api
-from nova.api.openstack import extensions
-from nova.api.openstack import views
from nova.db.sqlalchemy.session import get_session
-from webob import exc
+from nova import exception
+from nova import flags
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/contrib/virtual_interfaces.py b/nova/api/openstack/v2/contrib/virtual_interfaces.py
index 0afd2119d..1975a8dc0 100644
--- a/nova/api/openstack/contrib/virtual_interfaces.py
+++ b/nova/api/openstack/v2/contrib/virtual_interfaces.py
@@ -15,14 +15,14 @@
"""The virtual interfaces extension."""
-from nova import log as logging
-from nova import network
from nova.api.openstack import common
-from nova.api.openstack import extensions
+from nova.api.openstack.v2 import extensions
from nova.api.openstack import wsgi
+from nova import log as logging
+from nova import network
-LOG = logging.getLogger("nova.api.virtual_interfaces")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.virtual_interfaces")
def _translate_vif_summary_view(_context, vif):
diff --git a/nova/api/openstack/contrib/virtual_storage_arrays.py b/nova/api/openstack/v2/contrib/virtual_storage_arrays.py
index a6bf72960..f3a7831d5 100644
--- a/nova/api/openstack/contrib/virtual_storage_arrays.py
+++ b/nova/api/openstack/v2/contrib/virtual_storage_arrays.py
@@ -21,25 +21,25 @@
import webob
from webob import exc
-from nova import vsa
-from nova import volume
+from nova.api.openstack import common
+from nova.api.openstack.v2.contrib import volumes
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import servers
+from nova.api.openstack import wsgi
from nova import compute
+from nova.compute import instance_types
from nova import network
from nova import db
from nova import quota
from nova import exception
+from nova import flags
from nova import log as logging
-from nova.api.openstack import common
-from nova.api.openstack import extensions
-from nova.api.openstack import wsgi
-from nova.api.openstack import servers
-from nova.api.openstack.contrib import volumes
-from nova.compute import instance_types
+from nova import vsa
+from nova import volume
-from nova import flags
FLAGS = flags.FLAGS
-LOG = logging.getLogger("nova.api.vsa")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.vsa")
def _vsa_view(context, vsa, details=False, instances=None):
diff --git a/nova/api/openstack/contrib/volumes.py b/nova/api/openstack/v2/contrib/volumes.py
index 917cfc61b..5d86282f2 100644
--- a/nova/api/openstack/contrib/volumes.py
+++ b/nova/api/openstack/v2/contrib/volumes.py
@@ -18,6 +18,9 @@
from webob import exc
import webob
+from nova.api.openstack import common
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import servers
from nova import compute
from nova import db
from nova import exception
@@ -26,12 +29,9 @@ from nova import log as logging
from nova import quota
from nova import volume
from nova.volume import volume_types
-from nova.api.openstack import common
-from nova.api.openstack import extensions
-from nova.api.openstack import servers
-LOG = logging.getLogger("nova.api.volumes")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.volumes")
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/contrib/volumetypes.py b/nova/api/openstack/v2/contrib/volumetypes.py
index 64a9e0f02..ca3866c99 100644
--- a/nova/api/openstack/contrib/volumetypes.py
+++ b/nova/api/openstack/v2/contrib/volumetypes.py
@@ -19,11 +19,11 @@
from webob import exc
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack import wsgi
from nova import db
from nova import exception
from nova.volume import volume_types
-from nova.api.openstack import extensions
-from nova.api.openstack import wsgi
class VolumeTypesController(object):
diff --git a/nova/api/openstack/contrib/zones.py b/nova/api/openstack/v2/contrib/zones.py
index 628b8182f..76a235713 100644
--- a/nova/api/openstack/contrib/zones.py
+++ b/nova/api/openstack/v2/contrib/zones.py
@@ -20,10 +20,10 @@
from nova import flags
from nova import log as logging
-from nova.api.openstack import extensions
+from nova.api.openstack.v2 import extensions
-LOG = logging.getLogger("nova.api.zones")
+LOG = logging.getLogger("nova.api.openstack.v2.contrib.zones")
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/v2/extensions.py
index 7da10513e..a5cf863ed 100644
--- a/nova/api/openstack/extensions.py
+++ b/nova/api/openstack/v2/extensions.py
@@ -27,18 +27,18 @@ import routes
import webob.dec
import webob.exc
+import nova.api.openstack.v2
+from nova.api.openstack import common
+from nova.api.openstack import wsgi
+from nova.api.openstack import xmlutil
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils
from nova import wsgi as base_wsgi
-import nova.api.openstack
-from nova.api.openstack import common
-from nova.api.openstack import wsgi
-from nova.api.openstack import xmlutil
-LOG = logging.getLogger('nova.api.openstack.extensions')
+LOG = logging.getLogger('nova.api.openstack.v2.extensions')
FLAGS = flags.FLAGS
@@ -273,7 +273,7 @@ class ExtensionMiddleware(base_wsgi.Middleware):
ext_mgr = ExtensionManager()
self.ext_mgr = ext_mgr
- mapper = nova.api.openstack.ProjectMapper()
+ mapper = nova.api.openstack.v2.ProjectMapper()
serializer = wsgi.ResponseSerializer(
{'application/xml': ExtensionsXMLSerializer()})
diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/v2/flavors.py
index 7680ef1ca..d5b673c7f 100644
--- a/nova/api/openstack/flavors.py
+++ b/nova/api/openstack/v2/flavors.py
@@ -15,10 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import webob
from lxml import etree
+import webob
-from nova.api.openstack.views import flavors as flavors_view
+from nova.api.openstack.v2.views import flavors as flavors_view
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.compute import instance_types
diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/v2/image_metadata.py
index adb6bee4b..e3cfac4e0 100644
--- a/nova/api/openstack/image_metadata.py
+++ b/nova/api/openstack/v2/image_metadata.py
@@ -17,12 +17,12 @@
from webob import exc
+from nova.api.openstack import common
+from nova.api.openstack import wsgi
from nova import exception
from nova import flags
from nova import image
from nova import utils
-from nova.api.openstack import common
-from nova.api.openstack import wsgi
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/images.py b/nova/api/openstack/v2/images.py
index f3ef63b49..84b7b17db 100644
--- a/nova/api/openstack/images.py
+++ b/nova/api/openstack/v2/images.py
@@ -18,20 +18,18 @@ import os.path
from lxml import etree
import webob.exc
+from nova.api.openstack import common
+from nova.api.openstack.v2.views import images as views_images
+from nova.api.openstack import wsgi
+from nova.api.openstack import xmlutil
from nova import compute
from nova import exception
from nova import flags
import nova.image
from nova import log
-from nova.api.openstack import common
-from nova.api.openstack import image_metadata
-from nova.api.openstack import servers
-from nova.api.openstack import wsgi
-from nova.api.openstack import xmlutil
-from nova.api.openstack.views import images as views_images
-LOG = log.getLogger('nova.api.openstack.images')
+LOG = log.getLogger('nova.api.openstack.v2.images')
FLAGS = flags.FLAGS
SUPPORTED_FILTERS = {
diff --git a/nova/api/openstack/ips.py b/nova/api/openstack/v2/ips.py
index 2bef453a2..705754665 100644
--- a/nova/api/openstack/ips.py
+++ b/nova/api/openstack/v2/ips.py
@@ -16,19 +16,18 @@
# under the License.
from lxml import etree
-
from webob import exc
import nova
from nova.api.openstack import common
+from nova.api.openstack.v2.views import addresses as view_addresses
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
-from nova.api.openstack.views import addresses as view_addresses
from nova import log as logging
from nova import flags
-LOG = logging.getLogger('nova.api.openstack.ips')
+LOG = logging.getLogger('nova.api.openstack.v2.ips')
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/v2/limits.py
index 56e839526..04ff9e647 100644
--- a/nova/api/openstack/limits.py
+++ b/nova/api/openstack/v2/limits.py
@@ -17,28 +17,26 @@
Module dedicated functions/classes dealing with rate limiting requests.
"""
+from collections import defaultdict
import copy
import httplib
import json
-from lxml import etree
import math
import re
import time
import urllib
-import webob.exc
-
-from collections import defaultdict
+from lxml import etree
from webob.dec import wsgify
+import webob.exc
-from nova import quota
-from nova import utils
-from nova import wsgi as base_wsgi
from nova.api.openstack import common
-from nova.api.openstack import faults
-from nova.api.openstack.views import limits as limits_views
+from nova.api.openstack.v2.views import limits as limits_views
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
+from nova import quota
+from nova import utils
+from nova import wsgi as base_wsgi
# Convenience constants for the limits dictionary passed to Limiter().
@@ -275,7 +273,7 @@ class RateLimitingMiddleware(base_wsgi.Middleware):
if delay:
msg = _("This request was rate-limited.")
retry = time.time() + delay
- return faults.OverLimitFault(msg, error, retry)
+ return wsgi.OverLimitFault(msg, error, retry)
req.environ["nova.limits"] = self._limiter.get_limits(username)
diff --git a/nova/api/openstack/ratelimiting/__init__.py b/nova/api/openstack/v2/ratelimiting/__init__.py
index 9ede548c2..78dc465a7 100644
--- a/nova/api/openstack/ratelimiting/__init__.py
+++ b/nova/api/openstack/v2/ratelimiting/__init__.py
@@ -20,11 +20,12 @@
import httplib
import time
import urllib
+
import webob.dec
import webob.exc
from nova import wsgi
-from nova.api.openstack import faults
+from nova.api.openstack import wsgi as os_wsgi
# Convenience constants for the limits dictionary passed to Limiter().
PER_SECOND = 1
@@ -83,7 +84,7 @@ class RateLimitingMiddleware(wsgi.Middleware):
exc = webob.exc.HTTPRequestEntityTooLarge(
explanation=('Too many requests.'),
headers={'Retry-After': time.time() + delay})
- raise faults.Fault(exc)
+ raise os_wsgi.Fault(exc)
return application
def get_delay(self, action_name, username):
diff --git a/nova/api/openstack/schemas/atom-link.rng b/nova/api/openstack/v2/schemas/atom-link.rng
index edba5eee6..edba5eee6 100644
--- a/nova/api/openstack/schemas/atom-link.rng
+++ b/nova/api/openstack/v2/schemas/atom-link.rng
diff --git a/nova/api/openstack/schemas/atom.rng b/nova/api/openstack/v2/schemas/atom.rng
index c2df4e410..c2df4e410 100644
--- a/nova/api/openstack/schemas/atom.rng
+++ b/nova/api/openstack/v2/schemas/atom.rng
diff --git a/nova/api/openstack/schemas/v1.1/addresses.rng b/nova/api/openstack/v2/schemas/v1.1/addresses.rng
index b498e8a63..b498e8a63 100644
--- a/nova/api/openstack/schemas/v1.1/addresses.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/addresses.rng
diff --git a/nova/api/openstack/schemas/v1.1/extension.rng b/nova/api/openstack/v2/schemas/v1.1/extension.rng
index 336659755..336659755 100644
--- a/nova/api/openstack/schemas/v1.1/extension.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/extension.rng
diff --git a/nova/api/openstack/schemas/v1.1/extensions.rng b/nova/api/openstack/v2/schemas/v1.1/extensions.rng
index 4d8bff646..4d8bff646 100644
--- a/nova/api/openstack/schemas/v1.1/extensions.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/extensions.rng
diff --git a/nova/api/openstack/schemas/v1.1/flavor.rng b/nova/api/openstack/v2/schemas/v1.1/flavor.rng
index 6d3adc8dc..6d3adc8dc 100644
--- a/nova/api/openstack/schemas/v1.1/flavor.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/flavor.rng
diff --git a/nova/api/openstack/schemas/v1.1/flavors.rng b/nova/api/openstack/v2/schemas/v1.1/flavors.rng
index b7a3acc01..b7a3acc01 100644
--- a/nova/api/openstack/schemas/v1.1/flavors.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/flavors.rng
diff --git a/nova/api/openstack/schemas/v1.1/flavors_index.rng b/nova/api/openstack/v2/schemas/v1.1/flavors_index.rng
index d1a4fedb1..d1a4fedb1 100644
--- a/nova/api/openstack/schemas/v1.1/flavors_index.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/flavors_index.rng
diff --git a/nova/api/openstack/schemas/v1.1/image.rng b/nova/api/openstack/v2/schemas/v1.1/image.rng
index 505081fba..505081fba 100644
--- a/nova/api/openstack/schemas/v1.1/image.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/image.rng
diff --git a/nova/api/openstack/schemas/v1.1/images.rng b/nova/api/openstack/v2/schemas/v1.1/images.rng
index 064d4d9cc..064d4d9cc 100644
--- a/nova/api/openstack/schemas/v1.1/images.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/images.rng
diff --git a/nova/api/openstack/schemas/v1.1/images_index.rng b/nova/api/openstack/v2/schemas/v1.1/images_index.rng
index 3db0b2672..3db0b2672 100644
--- a/nova/api/openstack/schemas/v1.1/images_index.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/images_index.rng
diff --git a/nova/api/openstack/schemas/v1.1/limits.rng b/nova/api/openstack/v2/schemas/v1.1/limits.rng
index 1af8108ec..1af8108ec 100644
--- a/nova/api/openstack/schemas/v1.1/limits.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/limits.rng
diff --git a/nova/api/openstack/schemas/v1.1/metadata.rng b/nova/api/openstack/v2/schemas/v1.1/metadata.rng
index b2f5d702a..b2f5d702a 100644
--- a/nova/api/openstack/schemas/v1.1/metadata.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/metadata.rng
diff --git a/nova/api/openstack/schemas/v1.1/server.rng b/nova/api/openstack/v2/schemas/v1.1/server.rng
index 2e86ccffe..2e86ccffe 100644
--- a/nova/api/openstack/schemas/v1.1/server.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/server.rng
diff --git a/nova/api/openstack/schemas/v1.1/servers.rng b/nova/api/openstack/v2/schemas/v1.1/servers.rng
index 4e2bb8853..4e2bb8853 100644
--- a/nova/api/openstack/schemas/v1.1/servers.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/servers.rng
diff --git a/nova/api/openstack/schemas/v1.1/servers_index.rng b/nova/api/openstack/v2/schemas/v1.1/servers_index.rng
index 023e4b66a..023e4b66a 100644
--- a/nova/api/openstack/schemas/v1.1/servers_index.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/servers_index.rng
diff --git a/nova/api/openstack/schemas/v1.1/version.rng b/nova/api/openstack/v2/schemas/v1.1/version.rng
index ae76270ba..ae76270ba 100644
--- a/nova/api/openstack/schemas/v1.1/version.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/version.rng
diff --git a/nova/api/openstack/schemas/v1.1/versions.rng b/nova/api/openstack/v2/schemas/v1.1/versions.rng
index 8b2cc7f71..8b2cc7f71 100644
--- a/nova/api/openstack/schemas/v1.1/versions.rng
+++ b/nova/api/openstack/v2/schemas/v1.1/versions.rng
diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/v2/server_metadata.py
index 4145898c1..47dbe2fbd 100644
--- a/nova/api/openstack/server_metadata.py
+++ b/nova/api/openstack/v2/server_metadata.py
@@ -17,9 +17,9 @@
from webob import exc
-from nova import compute
from nova.api.openstack import common
from nova.api.openstack import wsgi
+from nova import compute
from nova import exception
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/v2/servers.py
index 8b11b30f6..1ae7f80bf 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/v2/servers.py
@@ -23,13 +23,12 @@ from webob import exc
import webob
from xml.dom import minidom
-import nova.api.openstack
from nova.api.openstack import common
-from nova.api.openstack import ips
-from nova.api.openstack.views import addresses as views_addresses
-from nova.api.openstack.views import flavors as views_flavors
-from nova.api.openstack.views import images as views_images
-from nova.api.openstack.views import servers as views_servers
+from nova.api.openstack.v2 import ips
+from nova.api.openstack.v2.views import addresses as views_addresses
+from nova.api.openstack.v2.views import flavors as views_flavors
+from nova.api.openstack.v2.views import images as views_images
+from nova.api.openstack.v2.views import servers as views_servers
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
@@ -45,7 +44,7 @@ from nova.scheduler import api as scheduler_api
from nova import utils
-LOG = logging.getLogger('nova.api.openstack.servers')
+LOG = logging.getLogger('nova.api.openstack.v2.servers')
FLAGS = flags.FLAGS
diff --git a/nova/api/openstack/urlmap.py b/nova/api/openstack/v2/urlmap.py
index 199fa6130..bae69198e 100644
--- a/nova/api/openstack/urlmap.py
+++ b/nova/api/openstack/v2/urlmap.py
@@ -28,7 +28,7 @@ _option_header_piece_re = re.compile(r';\s*([^\s;=]+|%s)\s*'
r'(?:=\s*([^;]+|%s))?\s*' %
(_quoted_string_re, _quoted_string_re))
-LOG = logging.getLogger('nova.api.openstack.map')
+LOG = logging.getLogger('nova.api.openstack.v2.map')
def unquote_header_value(value):
diff --git a/nova/api/openstack/users.py b/nova/api/openstack/v2/users.py
index 9fac45763..9dba79e03 100644
--- a/nova/api/openstack/users.py
+++ b/nova/api/openstack/v2/users.py
@@ -15,17 +15,17 @@
from webob import exc
-from nova import exception
-from nova import flags
-from nova import log as logging
from nova.api.openstack import common
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.auth import manager
+from nova import exception
+from nova import flags
+from nova import log as logging
FLAGS = flags.FLAGS
-LOG = logging.getLogger('nova.api.openstack')
+LOG = logging.getLogger('nova.api.openstack.users')
def _translate_keys(user):
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/v2/versions.py
index 5461ffce2..3c3d4068c 100644
--- a/nova/api/openstack/versions.py
+++ b/nova/api/openstack/v2/versions.py
@@ -16,11 +16,12 @@
# under the License.
from datetime import datetime
+
from lxml import etree
import webob
import webob.dec
-import nova.api.openstack.views.versions
+from nova.api.openstack.v2.views import versions as views_versions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
@@ -84,7 +85,7 @@ class Versions(wsgi.Resource):
def dispatch(self, request, *args):
"""Respond to a request for all OpenStack API versions."""
- builder = nova.api.openstack.views.versions.get_view_builder(request)
+ builder = views_versions.get_view_builder(request)
if request.path == '/':
# List Versions
return builder.build_versions(VERSIONS)
@@ -95,7 +96,7 @@ class Versions(wsgi.Resource):
class VersionV11(object):
def show(self, req):
- builder = nova.api.openstack.views.versions.get_view_builder(req)
+ builder = views_versions.get_view_builder(req)
return builder.build_version(VERSIONS['v1.1'])
diff --git a/nova/api/openstack/views/__init__.py b/nova/api/openstack/v2/views/__init__.py
index e69de29bb..e69de29bb 100644
--- a/nova/api/openstack/views/__init__.py
+++ b/nova/api/openstack/v2/views/__init__.py
diff --git a/nova/api/openstack/views/addresses.py b/nova/api/openstack/v2/views/addresses.py
index 1dbcaffe0..6f518b11a 100644
--- a/nova/api/openstack/views/addresses.py
+++ b/nova/api/openstack/v2/views/addresses.py
@@ -23,7 +23,7 @@ from nova import log as logging
FLAGS = flags.FLAGS
-LOG = logging.getLogger('nova.api.openstack.views.addresses')
+LOG = logging.getLogger('nova.api.openstack.v2.views.addresses')
class ViewBuilder(common.ViewBuilder):
diff --git a/nova/api/openstack/views/flavors.py b/nova/api/openstack/v2/views/flavors.py
index f84ae5987..7b170a6b2 100644
--- a/nova/api/openstack/views/flavors.py
+++ b/nova/api/openstack/v2/views/flavors.py
@@ -17,7 +17,6 @@
import os.path
-
from nova.api.openstack import common
diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/v2/views/images.py
index c4cfe8031..c4cfe8031 100644
--- a/nova/api/openstack/views/images.py
+++ b/nova/api/openstack/v2/views/images.py
diff --git a/nova/api/openstack/views/limits.py b/nova/api/openstack/v2/views/limits.py
index 138a40cb8..138a40cb8 100644
--- a/nova/api/openstack/views/limits.py
+++ b/nova/api/openstack/v2/views/limits.py
diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/v2/views/servers.py
index e6f4bc2c4..979be930f 100644
--- a/nova/api/openstack/views/servers.py
+++ b/nova/api/openstack/v2/views/servers.py
@@ -17,19 +17,16 @@
# under the License.
import hashlib
-import os
from nova.api.openstack import common
-from nova.api.openstack.views import addresses as views_addresses
-from nova.api.openstack.views import flavors as views_flavors
-from nova.api.openstack.views import images as views_images
-from nova.compute import vm_states
-from nova import exception
+from nova.api.openstack.v2.views import addresses as views_addresses
+from nova.api.openstack.v2.views import flavors as views_flavors
+from nova.api.openstack.v2.views import images as views_images
from nova import log as logging
from nova import utils
-LOG = logging.getLogger('nova.api.openstack.views.servers')
+LOG = logging.getLogger('nova.api.openstack.v2.views.servers')
class ViewBuilder(common.ViewBuilder):
diff --git a/nova/api/openstack/views/versions.py b/nova/api/openstack/v2/views/versions.py
index 1ac398706..1ac398706 100644
--- a/nova/api/openstack/views/versions.py
+++ b/nova/api/openstack/v2/views/versions.py
diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/v2/zones.py
index 2a95cd0a4..8c5add2d1 100644
--- a/nova/api/openstack/zones.py
+++ b/nova/api/openstack/v2/zones.py
@@ -16,25 +16,23 @@
import json
import urlparse
+from nova.api.openstack import common
+from nova.api.openstack.v2 import servers
+from nova.api.openstack import xmlutil
+from nova.api.openstack import wsgi
+from nova.compute import api as compute
from nova import crypto
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
-
-from nova.compute import api as compute
from nova.scheduler import api
-from nova.api.openstack import common
-from nova.api.openstack import servers
-from nova.api.openstack import xmlutil
-from nova.api.openstack import wsgi
-
FLAGS = flags.FLAGS
-LOG = logging.getLogger('nova.api.openstack.zones')
+LOG = logging.getLogger('nova.api.openstack.v2.zones')
def _filter_keys(item, keys):
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 8c6b30ca9..7e4875066 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -15,13 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
from lxml import etree
import webob
from xml.dom import minidom
from xml.parsers import expat
-import faults
from nova import exception
from nova import log as logging
from nova import utils
@@ -528,7 +526,7 @@ class Resource(wsgi.Application):
serialized by requested content type.
Exceptions derived from webob.exc.HTTPException will be automatically
- wrapped in faults.Fault() to provide API friendly error responses.
+ wrapped in Fault() to provide API friendly error responses.
"""
@@ -556,10 +554,10 @@ class Resource(wsgi.Application):
action, args, accept = self.deserializer.deserialize(request)
except exception.InvalidContentType:
msg = _("Unsupported Content-Type")
- return faults.Fault(webob.exc.HTTPBadRequest(explanation=msg))
+ return Fault(webob.exc.HTTPBadRequest(explanation=msg))
except exception.MalformedRequestBody:
msg = _("Malformed request body")
- return faults.Fault(webob.exc.HTTPBadRequest(explanation=msg))
+ return Fault(webob.exc.HTTPBadRequest(explanation=msg))
project_id = args.pop("project_id", None)
if 'nova.context' in request.environ and project_id:
@@ -567,12 +565,12 @@ class Resource(wsgi.Application):
try:
action_result = self.dispatch(request, action, args)
- except faults.Fault as ex:
+ except Fault as ex:
LOG.info(_("Fault thrown: %s"), unicode(ex))
action_result = ex
except webob.exc.HTTPException as ex:
LOG.info(_("HTTP exception thrown: %s"), unicode(ex))
- action_result = faults.Fault(ex)
+ action_result = Fault(ex)
if type(action_result) is dict or action_result is None:
response = self.serializer.serialize(request,
@@ -601,7 +599,7 @@ class Resource(wsgi.Application):
return controller_method(req=request, **action_args)
except TypeError as exc:
LOG.exception(exc)
- return faults.Fault(webob.exc.HTTPBadRequest())
+ return Fault(webob.exc.HTTPBadRequest())
class Controller(object):
@@ -612,3 +610,96 @@ class Controller(object):
def __init__(self, view_builder=None):
"""Initialize controller with a view builder instance."""
self._view_builder = view_builder or self._view_builder_class()
+
+
+class Fault(webob.exc.HTTPException):
+ """Wrap webob.exc.HTTPException to provide API friendly response."""
+
+ _fault_names = {
+ 400: "badRequest",
+ 401: "unauthorized",
+ 403: "resizeNotAllowed",
+ 404: "itemNotFound",
+ 405: "badMethod",
+ 409: "inProgress",
+ 413: "overLimit",
+ 415: "badMediaType",
+ 501: "notImplemented",
+ 503: "serviceUnavailable"}
+
+ def __init__(self, exception):
+ """Create a Fault for the given webob.exc.exception."""
+ self.wrapped_exc = exception
+ self.status_int = exception.status_int
+
+ @webob.dec.wsgify(RequestClass=Request)
+ def __call__(self, req):
+ """Generate a WSGI response based on the exception passed to ctor."""
+ # Replace the body with fault details.
+ code = self.wrapped_exc.status_int
+ fault_name = self._fault_names.get(code, "cloudServersFault")
+ fault_data = {
+ fault_name: {
+ 'code': code,
+ 'message': self.wrapped_exc.explanation}}
+ if code == 413:
+ retry = self.wrapped_exc.headers['Retry-After']
+ fault_data[fault_name]['retryAfter'] = retry
+
+ # 'code' is an attribute on the fault tag itself
+ metadata = {'attributes': {fault_name: 'code'}}
+
+ xml_serializer = XMLDictSerializer(metadata, XMLNS_V11)
+
+ content_type = req.best_match_content_type()
+ serializer = {
+ 'application/xml': xml_serializer,
+ 'application/json': JSONDictSerializer(),
+ }[content_type]
+
+ self.wrapped_exc.body = serializer.serialize(fault_data)
+ self.wrapped_exc.content_type = content_type
+
+ return self.wrapped_exc
+
+ def __str__(self):
+ return self.wrapped_exc.__str__()
+
+
+class OverLimitFault(webob.exc.HTTPException):
+ """
+ Rate-limited request response.
+ """
+
+ def __init__(self, message, details, retry_time):
+ """
+ Initialize new `OverLimitFault` with relevant information.
+ """
+ self.wrapped_exc = webob.exc.HTTPRequestEntityTooLarge()
+ self.content = {
+ "overLimitFault": {
+ "code": self.wrapped_exc.status_int,
+ "message": message,
+ "details": details,
+ },
+ }
+
+ @webob.dec.wsgify(RequestClass=Request)
+ def __call__(self, request):
+ """
+ Return the wrapped exception with a serialized body conforming to our
+ error format.
+ """
+ content_type = request.best_match_content_type()
+ metadata = {"attributes": {"overLimitFault": "code"}}
+
+ xml_serializer = XMLDictSerializer(metadata, XMLNS_V11)
+ serializer = {
+ 'application/xml': xml_serializer,
+ 'application/json': JSONDictSerializer(),
+ }[content_type]
+
+ content = serializer.serialize(self.content)
+ self.wrapped_exc.body = content
+
+ return self.wrapped_exc
diff --git a/nova/api/openstack/xmlutil.py b/nova/api/openstack/xmlutil.py
index 5779849b3..db490e652 100644
--- a/nova/api/openstack/xmlutil.py
+++ b/nova/api/openstack/xmlutil.py
@@ -31,9 +31,9 @@ XMLNS_ATOM = 'http://www.w3.org/2005/Atom'
def validate_schema(xml, schema_name):
if type(xml) is str:
xml = etree.fromstring(xml)
- base_path = 'nova/api/openstack/schemas/v1.1/'
+ base_path = 'nova/api/openstack/v2/schemas/v1.1/'
if schema_name in ('atom', 'atom-link'):
- base_path = 'nova/api/openstack/schemas/'
+ base_path = 'nova/api/openstack/v2/schemas/'
schema_path = os.path.join(utils.novadir(),
'%s%s.rng' % (base_path, schema_name))
schema_doc = etree.parse(schema_path)
diff --git a/nova/flags.py b/nova/flags.py
index 32cec119f..c47c77ab1 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -369,7 +369,7 @@ DEFINE_integer('ec2_port', 8773, 'cloud controller port')
DEFINE_string('ec2_scheme', 'http', 'prefix for ec2')
DEFINE_string('ec2_path', '/services/Cloud', 'suffix for ec2')
DEFINE_multistring('osapi_extension',
- ['nova.api.openstack.contrib.standard_extensions'],
+ ['nova.api.openstack.v2.contrib.standard_extensions'],
'osapi extension to load')
DEFINE_string('osapi_host', '$my_ip', 'ip of api server')
DEFINE_string('osapi_scheme', 'http', 'prefix for openstack')
diff --git a/nova/tests/api/openstack/__init__.py b/nova/tests/api/openstack/__init__.py
index 00fcfbb00..e69de29bb 100644
--- a/nova/tests/api/openstack/__init__.py
+++ b/nova/tests/api/openstack/__init__.py
@@ -1,16 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index 0f58cf55b..c12ae5eab 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -23,25 +23,25 @@ import webob.request
from glance import client as glance_client
-from nova import context
-from nova import exception as exc
-from nova import utils
-from nova import wsgi
-import nova.api.openstack.auth
-from nova.api import openstack
+import nova.api.openstack.v2.auth
from nova.api import auth as api_auth
-from nova.api.openstack import auth
-from nova.api.openstack import extensions
-from nova.api.openstack import limits
-from nova.api.openstack import urlmap
-from nova.api.openstack import versions
+from nova.api.openstack import v2
+from nova.api.openstack.v2 import auth
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import limits
+from nova.api.openstack.v2 import urlmap
+from nova.api.openstack.v2 import versions
from nova.api.openstack import wsgi as os_wsgi
from nova.auth.manager import User, Project
from nova.compute import instance_types
from nova.compute import vm_states
+from nova import context
from nova.db.sqlalchemy import models
+from nova import exception as exc
import nova.image.fake
from nova.tests.glance import stubs as glance_stubs
+from nova import utils
+from nova import wsgi
class Context(object):
@@ -72,35 +72,36 @@ def fake_wsgi(self, req):
return self.application
-def wsgi_app(inner_app11=None, fake_auth=True, fake_auth_context=None,
+def wsgi_app(inner_app_v2=None, fake_auth=True, fake_auth_context=None,
serialization=os_wsgi.LazySerializationMiddleware,
use_no_auth=False):
- if not inner_app11:
- inner_app11 = openstack.APIRouter()
+ if not inner_app_v2:
+ inner_app_v2 = v2.APIRouter()
if fake_auth:
if fake_auth_context is not None:
ctxt = fake_auth_context
else:
ctxt = context.RequestContext('fake', 'fake', auth_token=True)
- api11 = openstack.FaultWrapper(api_auth.InjectContext(ctxt,
+ api_v2 = v2.FaultWrapper(api_auth.InjectContext(ctxt,
limits.RateLimitingMiddleware(
serialization(
- extensions.ExtensionMiddleware(inner_app11)))))
+ extensions.ExtensionMiddleware(inner_app_v2)))))
elif use_no_auth:
- api11 = openstack.FaultWrapper(auth.NoAuthMiddleware(
+ api_v2 = v2.FaultWrapper(auth.NoAuthMiddleware(
limits.RateLimitingMiddleware(
serialization(
- extensions.ExtensionMiddleware(inner_app11)))))
+ extensions.ExtensionMiddleware(inner_app_v2)))))
else:
- api11 = openstack.FaultWrapper(auth.AuthMiddleware(
+ api_v2 = v2.FaultWrapper(auth.AuthMiddleware(
limits.RateLimitingMiddleware(
serialization(
- extensions.ExtensionMiddleware(inner_app11)))))
+ extensions.ExtensionMiddleware(inner_app_v2)))))
Auth = auth
mapper = urlmap.URLMap()
- mapper['/v1.1'] = api11
- mapper['/'] = openstack.FaultWrapper(versions.Versions())
+ mapper['/v2'] = api_v2
+ mapper['/v1.1'] = api_v2
+ mapper['/'] = v2.FaultWrapper(versions.Versions())
return mapper
@@ -136,9 +137,9 @@ def stub_out_auth(stubs):
def fake_auth_init(self, app):
self.application = app
- stubs.Set(nova.api.openstack.auth.AuthMiddleware,
+ stubs.Set(nova.api.openstack.v2.auth.AuthMiddleware,
'__init__', fake_auth_init)
- stubs.Set(nova.api.openstack.auth.AuthMiddleware,
+ stubs.Set(nova.api.openstack.v2.auth.AuthMiddleware,
'__call__', fake_wsgi)
@@ -147,10 +148,10 @@ def stub_out_rate_limiting(stubs):
super(limits.RateLimitingMiddleware, self).__init__(app)
self.application = app
- stubs.Set(nova.api.openstack.limits.RateLimitingMiddleware,
+ stubs.Set(nova.api.openstack.v2.limits.RateLimitingMiddleware,
'__init__', fake_rate_init)
- stubs.Set(nova.api.openstack.limits.RateLimitingMiddleware,
+ stubs.Set(nova.api.openstack.v2.limits.RateLimitingMiddleware,
'__call__', fake_wsgi)
diff --git a/nova/tests/api/openstack/test_faults.py b/nova/tests/api/openstack/test_faults.py
index 18bd136df..87cb2d3fe 100644
--- a/nova/tests/api/openstack/test_faults.py
+++ b/nova/tests/api/openstack/test_faults.py
@@ -24,7 +24,6 @@ import webob.exc
from nova import test
from nova.api.openstack import common
-from nova.api.openstack import faults
from nova.api.openstack import wsgi
@@ -46,7 +45,7 @@ class TestFaults(test.TestCase):
]
for request in requests:
- fault = faults.Fault(webob.exc.HTTPBadRequest(explanation='scram'))
+ fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='scram'))
response = request.get_response(fault)
expected = {
@@ -69,7 +68,7 @@ class TestFaults(test.TestCase):
for request in requests:
exc = webob.exc.HTTPRequestEntityTooLarge
- fault = faults.Fault(exc(explanation='sorry',
+ fault = wsgi.Fault(exc(explanation='sorry',
headers={'Retry-After': 4}))
response = request.get_response(fault)
@@ -89,7 +88,7 @@ class TestFaults(test.TestCase):
"""Ensure the ability to raise `Fault`s in WSGI-ified methods."""
@webob.dec.wsgify
def raiser(req):
- raise faults.Fault(webob.exc.HTTPNotFound(explanation='whut?'))
+ raise wsgi.Fault(webob.exc.HTTPNotFound(explanation='whut?'))
req = webob.Request.blank('/.xml')
resp = req.get_response(raiser)
@@ -99,7 +98,7 @@ class TestFaults(test.TestCase):
def test_fault_has_status_int(self):
"""Ensure the status_int is set correctly on faults"""
- fault = faults.Fault(webob.exc.HTTPBadRequest(explanation='what?'))
+ fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='what?'))
self.assertEqual(fault.status_int, 400)
def test_xml_serializer(self):
@@ -107,7 +106,7 @@ class TestFaults(test.TestCase):
request = webob.Request.blank('/v1.1',
headers={"Accept": "application/xml"})
- fault = faults.Fault(webob.exc.HTTPBadRequest(explanation='scram'))
+ fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='scram'))
response = request.get_response(fault)
self.assertTrue(common.XML_NS_V11 in response.body)
diff --git a/nova/tests/api/openstack/v2/__init__.py b/nova/tests/api/openstack/v2/__init__.py
new file mode 100644
index 000000000..00fcfbb00
--- /dev/null
+++ b/nova/tests/api/openstack/v2/__init__.py
@@ -0,0 +1,16 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 OpenStack LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
diff --git a/nova/tests/api/openstack/contrib/__init__.py b/nova/tests/api/openstack/v2/contrib/__init__.py
index 848908a95..848908a95 100644
--- a/nova/tests/api/openstack/contrib/__init__.py
+++ b/nova/tests/api/openstack/v2/contrib/__init__.py
diff --git a/nova/tests/api/openstack/contrib/test_admin_actions.py b/nova/tests/api/openstack/v2/contrib/test_admin_actions.py
index 4b62c0ba7..4b62c0ba7 100644
--- a/nova/tests/api/openstack/contrib/test_admin_actions.py
+++ b/nova/tests/api/openstack/v2/contrib/test_admin_actions.py
diff --git a/nova/tests/api/openstack/contrib/test_createserverext.py b/nova/tests/api/openstack/v2/contrib/test_createserverext.py
index f7ee96917..5c9e0499a 100644
--- a/nova/tests/api/openstack/contrib/test_createserverext.py
+++ b/nova/tests/api/openstack/v2/contrib/test_createserverext.py
@@ -22,12 +22,12 @@ from xml.dom import minidom
import webob
+import nova
from nova import db
from nova import exception
from nova import flags
from nova import rpc
from nova import test
-import nova.api.openstack
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/contrib/test_disk_config.py b/nova/tests/api/openstack/v2/contrib/test_disk_config.py
index 40875cb84..ac2391a04 100644
--- a/nova/tests/api/openstack/contrib/test_disk_config.py
+++ b/nova/tests/api/openstack/v2/contrib/test_disk_config.py
@@ -14,19 +14,19 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+
import datetime
+from nova.api.openstack import v2
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack import wsgi
import nova.db.api
-import nova.rpc
-
from nova import flags
+import nova.rpc
from nova import test
-from nova import utils
-from nova.api import openstack
-from nova.api.openstack import extensions
-from nova.api.openstack import servers
-from nova.api.openstack import wsgi
from nova.tests.api.openstack import fakes
+from nova import utils
+
MANUAL_INSTANCE_UUID = fakes.FAKE_UUID
AUTO_INSTANCE_UUID = fakes.FAKE_UUID.replace('a', 'b')
@@ -113,7 +113,7 @@ class DiskConfigTestCase(test.TestCase):
self.stubs.Set(nova.db, 'instance_create', fake_instance_create)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
app = extensions.ExtensionMiddleware(app)
app = wsgi.LazySerializationMiddleware(app)
self.app = app
diff --git a/nova/tests/api/openstack/contrib/test_extendedstatus.py b/nova/tests/api/openstack/v2/contrib/test_extendedstatus.py
index 0065f6fde..54246727c 100644
--- a/nova/tests/api/openstack/contrib/test_extendedstatus.py
+++ b/nova/tests/api/openstack/v2/contrib/test_extendedstatus.py
@@ -14,6 +14,7 @@
# under the License.
import json
+
import webob
from nova import compute
diff --git a/nova/tests/api/openstack/contrib/test_flavors_extra_specs.py b/nova/tests/api/openstack/v2/contrib/test_flavors_extra_specs.py
index 5784743ee..5f9be886f 100644
--- a/nova/tests/api/openstack/contrib/test_flavors_extra_specs.py
+++ b/nova/tests/api/openstack/v2/contrib/test_flavors_extra_specs.py
@@ -16,15 +16,14 @@
# under the License.
import json
-import stubout
-import webob
import os.path
+import stubout
+import webob
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2.contrib import flavorextraspecs
from nova import test
-from nova.api import openstack
-from nova.api.openstack import extensions
-from nova.api.openstack.contrib import flavorextraspecs
from nova.tests.api.openstack import fakes
import nova.wsgi
diff --git a/nova/tests/api/openstack/contrib/test_floating_ips.py b/nova/tests/api/openstack/v2/contrib/test_floating_ips.py
index 63831f31f..ded363406 100644
--- a/nova/tests/api/openstack/contrib/test_floating_ips.py
+++ b/nova/tests/api/openstack/v2/contrib/test_floating_ips.py
@@ -15,8 +15,11 @@
import json
import stubout
+
import webob
+from nova.api.openstack.v2.contrib import floating_ips
+from nova.api.openstack.v2.contrib import floating_ips
from nova import compute
from nova import context
from nova import db
@@ -24,11 +27,7 @@ from nova import network
from nova import rpc
from nova import test
from nova.tests.api.openstack import fakes
-from nova.tests.api.openstack import test_servers
-
-
-from nova.api.openstack.contrib import floating_ips
-from nova.api.openstack.contrib.floating_ips import _translate_floating_ip_view
+from nova.tests.api.openstack.v2 import test_servers
def network_api_get_floating_ip(self, context, id):
@@ -143,7 +142,7 @@ class FloatingIpTest(test.TestCase):
floating_ip_address = self._create_floating_ip()
floating_ip = db.floating_ip_get_by_address(self.context,
floating_ip_address)
- view = _translate_floating_ip_view(floating_ip)
+ view = floating_ips._translate_floating_ip_view(floating_ip)
self.assertTrue('floating_ip' in view)
self.assertTrue(view['floating_ip']['id'])
self.assertEqual(view['floating_ip']['ip'], self.address)
@@ -152,7 +151,7 @@ class FloatingIpTest(test.TestCase):
def test_translate_floating_ip_view_dict(self):
floating_ip = {'id': 0, 'address': '10.0.0.10', 'fixed_ip': None}
- view = _translate_floating_ip_view(floating_ip)
+ view = floating_ips._translate_floating_ip_view(floating_ip)
self.assertTrue('floating_ip' in view)
def test_floating_ips_list(self):
diff --git a/nova/tests/api/openstack/contrib/test_keypairs.py b/nova/tests/api/openstack/v2/contrib/test_keypairs.py
index 92e401aac..b2f595e5e 100644
--- a/nova/tests/api/openstack/contrib/test_keypairs.py
+++ b/nova/tests/api/openstack/v2/contrib/test_keypairs.py
@@ -14,12 +14,13 @@
# under the License.
import json
+
import webob
+from nova.api.openstack.v2.contrib.keypairs import KeypairController
from nova import context
from nova import db
from nova import test
-from nova.api.openstack.contrib.keypairs import KeypairController
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/contrib/test_multinic_xs.py b/nova/tests/api/openstack/v2/contrib/test_multinic_xs.py
index 90999a384..68f99d363 100644
--- a/nova/tests/api/openstack/contrib/test_multinic_xs.py
+++ b/nova/tests/api/openstack/v2/contrib/test_multinic_xs.py
@@ -14,6 +14,7 @@
# under the License.
import json
+
import stubout
import webob
diff --git a/nova/tests/api/openstack/contrib/test_quotas.py b/nova/tests/api/openstack/v2/contrib/test_quotas.py
index 6374dfd93..15fb20f94 100644
--- a/nova/tests/api/openstack/contrib/test_quotas.py
+++ b/nova/tests/api/openstack/v2/contrib/test_quotas.py
@@ -18,12 +18,11 @@
import json
import webob
+from nova.api.openstack.v2.contrib.quotas import QuotaSetsController
from nova import context
from nova import test
from nova.tests.api.openstack import fakes
-from nova.api.openstack.contrib.quotas import QuotaSetsController
-
def quota_set(id):
return {'quota_set': {'id': id, 'metadata_items': 128, 'volumes': 10,
diff --git a/nova/tests/api/openstack/contrib/test_rescue.py b/nova/tests/api/openstack/v2/contrib/test_rescue.py
index f5b69865c..9058d101e 100644
--- a/nova/tests/api/openstack/contrib/test_rescue.py
+++ b/nova/tests/api/openstack/v2/contrib/test_rescue.py
@@ -13,6 +13,7 @@
# under the License.
import json
+
import webob
from nova import compute
diff --git a/nova/tests/api/openstack/contrib/test_security_groups.py b/nova/tests/api/openstack/v2/contrib/test_security_groups.py
index 1e7a439b0..fd4e0841d 100644
--- a/nova/tests/api/openstack/contrib/test_security_groups.py
+++ b/nova/tests/api/openstack/v2/contrib/test_security_groups.py
@@ -15,15 +15,16 @@
# under the License.
import json
-import mox
-import nova
import unittest
-import webob
from xml.dom import minidom
+import mox
+import webob
+
+from nova.api.openstack.v2.contrib import security_groups
+import nova.db
from nova import exception
from nova import test
-from nova.api.openstack.contrib import security_groups
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/contrib/test_simple_tenant_usage.py b/nova/tests/api/openstack/v2/contrib/test_simple_tenant_usage.py
index 2430b9d51..56e7be0d2 100644
--- a/nova/tests/api/openstack/contrib/test_simple_tenant_usage.py
+++ b/nova/tests/api/openstack/v2/contrib/test_simple_tenant_usage.py
@@ -19,10 +19,10 @@ import datetime
import json
import webob
+from nova.compute import api
from nova import context
from nova import flags
from nova import test
-from nova.compute import api
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/contrib/test_virtual_interfaces.py b/nova/tests/api/openstack/v2/contrib/test_virtual_interfaces.py
index 0e3b45c10..4285eaaaf 100644
--- a/nova/tests/api/openstack/contrib/test_virtual_interfaces.py
+++ b/nova/tests/api/openstack/v2/contrib/test_virtual_interfaces.py
@@ -14,13 +14,14 @@
# under the License.
import json
+
import webob
-from nova import test
+from nova.api.openstack.v2.contrib.virtual_interfaces import \
+ ServerVirtualInterfaceController
from nova import network
+from nova import test
from nova.tests.api.openstack import fakes
-from nova.api.openstack.contrib.virtual_interfaces import \
- ServerVirtualInterfaceController
def get_vifs_by_instance(self, context, server_id):
diff --git a/nova/tests/api/openstack/contrib/test_volume_types.py b/nova/tests/api/openstack/v2/contrib/test_volume_types.py
index ec1c44854..9da77349d 100644
--- a/nova/tests/api/openstack/contrib/test_volume_types.py
+++ b/nova/tests/api/openstack/v2/contrib/test_volume_types.py
@@ -14,18 +14,20 @@
# under the License.
import json
+
import stubout
import webob
+from nova.api.openstack.v2.contrib import volumetypes
from nova import exception
from nova import context
from nova import test
from nova import log as logging
-from nova.api.openstack.contrib import volumetypes
from nova.volume import volume_types
from nova.tests.api.openstack import fakes
-LOG = logging.getLogger('nova.tests.api.openstack.test_volume_types')
+LOG = logging.getLogger('nova.tests.api.openstack.v2.contrib.'
+ 'test_volume_types')
last_param = {}
diff --git a/nova/tests/api/openstack/contrib/test_volume_types_extra_specs.py b/nova/tests/api/openstack/v2/contrib/test_volume_types_extra_specs.py
index 796478838..9083d9d72 100644
--- a/nova/tests/api/openstack/contrib/test_volume_types_extra_specs.py
+++ b/nova/tests/api/openstack/v2/contrib/test_volume_types_extra_specs.py
@@ -18,15 +18,14 @@
# under the License.
import json
-import stubout
-import webob
import os.path
+import stubout
+import webob
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2.contrib import volumetypes
from nova import test
-from nova.api import openstack
-from nova.api.openstack import extensions
-from nova.api.openstack.contrib import volumetypes
from nova.tests.api.openstack import fakes
import nova.wsgi
diff --git a/nova/tests/api/openstack/contrib/test_volumes.py b/nova/tests/api/openstack/v2/contrib/test_volumes.py
index a130d1140..529abf225 100644
--- a/nova/tests/api/openstack/contrib/test_volumes.py
+++ b/nova/tests/api/openstack/v2/contrib/test_volumes.py
@@ -15,12 +15,13 @@
import datetime
import json
+
import webob
import nova
+from nova.compute import instance_types
from nova import flags
from nova import test
-from nova.compute import instance_types
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/contrib/test_vsa.py b/nova/tests/api/openstack/v2/contrib/test_vsa.py
index 6f6ea8e32..b4055a204 100644
--- a/nova/tests/api/openstack/contrib/test_vsa.py
+++ b/nova/tests/api/openstack/v2/contrib/test_vsa.py
@@ -14,27 +14,26 @@
# under the License.
import json
-import stubout
import unittest
+
+import stubout
import webob
+from nova.api.openstack.v2.contrib.virtual_storage_arrays import _vsa_view
from nova import context
-from nova import db
+import nova.db
from nova import exception
from nova import flags
from nova import log as logging
from nova import test
+from nova.tests.api.openstack import fakes
from nova import volume
from nova import vsa
-from nova.api import openstack
-from nova.tests.api.openstack import fakes
-import nova.wsgi
-from nova.api.openstack.contrib.virtual_storage_arrays import _vsa_view
FLAGS = flags.FLAGS
-LOG = logging.getLogger('nova.tests.api.openstack.vsa')
+LOG = logging.getLogger('nova.tests.api.openstack.v2.contrib.test_vsa')
last_param = {}
diff --git a/nova/tests/api/openstack/extensions/__init__.py b/nova/tests/api/openstack/v2/extensions/__init__.py
index 848908a95..848908a95 100644
--- a/nova/tests/api/openstack/extensions/__init__.py
+++ b/nova/tests/api/openstack/v2/extensions/__init__.py
diff --git a/nova/tests/api/openstack/extensions/foxinsocks.py b/nova/tests/api/openstack/v2/extensions/foxinsocks.py
index cbf101f47..05a995496 100644
--- a/nova/tests/api/openstack/extensions/foxinsocks.py
+++ b/nova/tests/api/openstack/v2/extensions/foxinsocks.py
@@ -18,7 +18,7 @@
import json
import webob.exc
-from nova.api.openstack import extensions
+from nova.api.openstack.v2 import extensions
class FoxInSocksController(object):
diff --git a/nova/tests/api/openstack/test_accounts.py b/nova/tests/api/openstack/v2/test_accounts.py
index ea96e1348..ab3ecafde 100644
--- a/nova/tests/api/openstack/test_accounts.py
+++ b/nova/tests/api/openstack/v2/test_accounts.py
@@ -20,7 +20,7 @@ from lxml import etree
import webob
from nova import test
-from nova.api.openstack import accounts
+from nova.api.openstack.v2 import accounts
from nova.auth.manager import User
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/test_api.py b/nova/tests/api/openstack/v2/test_api.py
index b7a0b01ef..318c03a88 100644
--- a/nova/tests/api/openstack/test_api.py
+++ b/nova/tests/api/openstack/v2/test_api.py
@@ -17,15 +17,14 @@
import json
+from lxml import etree
import webob.exc
import webob.dec
-
-from lxml import etree
from webob import Request
from nova import test
-from nova.api import openstack
-from nova.api.openstack import faults
+from nova.api.openstack import v2
+from nova.api.openstack.v2 import wsgi
from nova.tests.api.openstack import fakes
@@ -33,7 +32,7 @@ class APITest(test.TestCase):
def _wsgi_app(self, inner_app):
# simpler version of the app than fakes.wsgi_app
- return openstack.FaultWrapper(inner_app)
+ return v2.FaultWrapper(inner_app)
def test_malformed_json(self):
req = webob.Request.blank('/')
@@ -94,7 +93,7 @@ class APITest(test.TestCase):
@webob.dec.wsgify
def raise_api_fault(req):
exc = webob.exc.HTTPNotFound(explanation='Raised a webob.exc')
- return faults.Fault(exc)
+ return wsgi.Fault(exc)
#api.application = succeed
api = self._wsgi_app(succeed)
diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/v2/test_auth.py
index d6a52d4f0..05058c555 100644
--- a/nova/tests/api/openstack/test_auth.py
+++ b/nova/tests/api/openstack/v2/test_auth.py
@@ -20,8 +20,8 @@ import datetime
import webob
import webob.dec
-import nova.api
-import nova.api.openstack.auth
+import nova.api.openstack.v2
+import nova.api.openstack.v2.auth
import nova.auth.manager
from nova import context
from nova import db
@@ -33,7 +33,7 @@ class Test(test.TestCase):
def setUp(self):
super(Test, self).setUp()
- self.stubs.Set(nova.api.openstack.auth.AuthMiddleware,
+ self.stubs.Set(nova.api.openstack.v2.auth.AuthMiddleware,
'__init__', fakes.fake_auth_init)
self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
fakes.FakeAuthManager.clear_fakes()
@@ -80,7 +80,7 @@ class Test(test.TestCase):
self.assertEqual(result.headers['X-Storage-Url'], "")
token = result.headers['X-Auth-Token']
- self.stubs.Set(nova.api.openstack, 'APIRouter', fakes.FakeRouter)
+ self.stubs.Set(nova.api.openstack.v2, 'APIRouter', fakes.FakeRouter)
req = webob.Request.blank('/v1.1/user1_project')
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app(fake_auth=False))
@@ -125,7 +125,7 @@ class Test(test.TestCase):
self.assertEqual(result.status, '204 No Content')
token = result.headers['X-Auth-Token']
- self.stubs.Set(nova.api.openstack, 'APIRouter', fakes.FakeRouter)
+ self.stubs.Set(nova.api.openstack.v2, 'APIRouter', fakes.FakeRouter)
req = webob.Request.blank('/v1.1/user2_project')
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app(fake_auth=False))
@@ -178,7 +178,7 @@ class Test(test.TestCase):
self.assertEqual(result.status, '204 No Content')
token = result.headers['X-Auth-Token']
- self.stubs.Set(nova.api.openstack, 'APIRouter', fakes.FakeRouter)
+ self.stubs.Set(nova.api.openstack.v2, 'APIRouter', fakes.FakeRouter)
req = webob.Request.blank('/v1.1/user2_project')
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app(fake_auth=False))
@@ -201,7 +201,7 @@ class Test(test.TestCase):
self.assertEqual(result.status, '204 No Content')
token = result.headers['X-Auth-Token']
- self.stubs.Set(nova.api.openstack, 'APIRouter', fakes.FakeRouter)
+ self.stubs.Set(nova.api.openstack.v2, 'APIRouter', fakes.FakeRouter)
req = webob.Request.blank('/v1.1/user2_project')
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app(fake_auth=False))
@@ -238,7 +238,7 @@ class TestFunctional(test.TestCase):
class TestLimiter(test.TestCase):
def setUp(self):
super(TestLimiter, self).setUp()
- self.stubs.Set(nova.api.openstack.auth.AuthMiddleware,
+ self.stubs.Set(nova.api.openstack.v2.auth.AuthMiddleware,
'__init__', fakes.fake_auth_init)
self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
fakes.FakeAuthManager.clear_fakes()
@@ -262,7 +262,7 @@ class TestLimiter(test.TestCase):
self.assertEqual(len(result.headers['X-Auth-Token']), 40)
token = result.headers['X-Auth-Token']
- self.stubs.Set(nova.api.openstack, 'APIRouter', fakes.FakeRouter)
+ self.stubs.Set(nova.api.openstack.v2, 'APIRouter', fakes.FakeRouter)
req = webob.Request.blank('/v1.1/test')
req.method = 'POST'
req.headers['X-Auth-Token'] = token
diff --git a/nova/tests/api/openstack/test_consoles.py b/nova/tests/api/openstack/v2/test_consoles.py
index 0b682be0a..fc6479f91 100644
--- a/nova/tests/api/openstack/test_consoles.py
+++ b/nova/tests/api/openstack/v2/test_consoles.py
@@ -22,7 +22,7 @@ import json
from lxml import etree
import webob
-from nova.api.openstack import consoles
+from nova.api.openstack.v2 import consoles
from nova import console
from nova import db
from nova.compute import vm_states
diff --git a/nova/tests/api/openstack/test_extensions.py b/nova/tests/api/openstack/v2/test_extensions.py
index b4fe3e730..5d388ddd3 100644
--- a/nova/tests/api/openstack/test_extensions.py
+++ b/nova/tests/api/openstack/v2/test_extensions.py
@@ -17,19 +17,20 @@
import json
import os.path
+
import webob
from lxml import etree
+from nova.api.openstack import v2
+from nova.api.openstack.v2 import extensions
+from nova.api.openstack.v2 import flavors
+from nova.api.openstack import wsgi
+from nova.api.openstack import xmlutil
from nova import context
from nova import flags
from nova import test
-from nova import wsgi as base_wsgi
-from nova.api import openstack
-from nova.api.openstack import extensions
-from nova.api.openstack import flavors
-from nova.api.openstack import wsgi
-from nova.api.openstack import xmlutil
from nova.tests.api.openstack import fakes
+from nova import wsgi as base_wsgi
FLAGS = flags.FLAGS
@@ -88,7 +89,7 @@ class ExtensionTestCase(test.TestCase):
def setUp(self):
super(ExtensionTestCase, self).setUp()
ext_list = FLAGS.osapi_extension[:]
- ext_list.append('nova.tests.api.openstack.extensions.'
+ ext_list.append('nova.tests.api.openstack.v2.extensions.'
'foxinsocks.Foxinsocks')
self.flags(osapi_extension=ext_list)
@@ -123,7 +124,7 @@ class ExtensionControllerTest(ExtensionTestCase):
self.ext_list.sort()
def test_list_extensions_json(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/extensions")
@@ -150,7 +151,7 @@ class ExtensionControllerTest(ExtensionTestCase):
)
def test_get_extension_json(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/extensions/FOXNSOX")
@@ -167,14 +168,14 @@ class ExtensionControllerTest(ExtensionTestCase):
"links": []})
def test_get_non_existing_extension_json(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
request = webob.Request.blank("/123/extensions/4")
response = request.get_response(ext_midware)
self.assertEqual(404, response.status_int)
def test_list_extensions_xml(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/extensions")
@@ -202,7 +203,7 @@ class ExtensionControllerTest(ExtensionTestCase):
xmlutil.validate_schema(root, 'extensions')
def test_get_extension_xml(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/extensions/FOXNSOX")
@@ -229,7 +230,7 @@ class ResourceExtensionTest(ExtensionTestCase):
def test_no_extension_present(self):
manager = StubExtensionManager(None)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app, manager)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/blah")
@@ -240,7 +241,7 @@ class ResourceExtensionTest(ExtensionTestCase):
res_ext = extensions.ResourceExtension('tweedles',
StubController(response_body))
manager = StubExtensionManager(res_ext)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app, manager)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/tweedles")
@@ -252,7 +253,7 @@ class ResourceExtensionTest(ExtensionTestCase):
res_ext = extensions.ResourceExtension('tweedles',
StubController(response_body))
manager = StubExtensionManager(res_ext)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app, manager)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/tweedles")
@@ -264,7 +265,7 @@ class ResourceExtensionTest(ExtensionTestCase):
res_ext = extensions.ResourceExtension('tweedles',
StubController(response_body))
manager = StubExtensionManager(res_ext)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app, manager)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/tweedles")
@@ -285,7 +286,7 @@ class ResourceExtensionTest(ExtensionTestCase):
res_ext = extensions.ResourceExtension('tweedles',
StubController(response_body))
manager = StubExtensionManager(res_ext)
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app, manager)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/tweedles/1")
@@ -312,7 +313,7 @@ class ExtensionManagerTest(ExtensionTestCase):
response_body = "Try to say this Mr. Knox, sir..."
def test_get_resources(self):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank("/123/foxnsocks")
@@ -323,7 +324,7 @@ class ExtensionManagerTest(ExtensionTestCase):
def test_invalid_extensions(self):
# Don't need the serialization middleware here because we're
# not testing any serialization
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ext_mgr = ext_midware.ext_mgr
ext_mgr.register(InvalidExtension())
@@ -334,7 +335,7 @@ class ExtensionManagerTest(ExtensionTestCase):
class ActionExtensionTest(ExtensionTestCase):
def _send_server_action_request(self, url, body):
- app = openstack.APIRouter()
+ app = v2.APIRouter()
ext_midware = extensions.ExtensionMiddleware(app)
ser_midware = wsgi.LazySerializationMiddleware(ext_midware)
request = webob.Request.blank(url)
diff --git a/nova/tests/api/openstack/test_flavors.py b/nova/tests/api/openstack/v2/test_flavors.py
index 24d81ef67..c62291ad1 100644
--- a/nova/tests/api/openstack/test_flavors.py
+++ b/nova/tests/api/openstack/v2/test_flavors.py
@@ -20,7 +20,7 @@ import json
from lxml import etree
import webob
-from nova.api.openstack import flavors
+from nova.api.openstack.v2 import flavors
from nova.api.openstack import xmlutil
import nova.compute.instance_types
from nova import exception
diff --git a/nova/tests/api/openstack/test_image_metadata.py b/nova/tests/api/openstack/v2/test_image_metadata.py
index dc0cf1671..a4f2f155d 100644
--- a/nova/tests/api/openstack/test_image_metadata.py
+++ b/nova/tests/api/openstack/v2/test_image_metadata.py
@@ -18,11 +18,10 @@
import json
import webob
-
-from nova.tests.api.openstack import fakes
-from nova.api.openstack import image_metadata
+from nova.api.openstack.v2 import image_metadata
from nova import flags
from nova import test
+from nova.tests.api.openstack import fakes
FLAGS = flags.FLAGS
diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/v2/test_images.py
index eb200046f..b02b6ff2d 100644
--- a/nova/tests/api/openstack/test_images.py
+++ b/nova/tests/api/openstack/v2/test_images.py
@@ -20,14 +20,15 @@ Tests of the new image services, both as a service layer,
and as a WSGI layer
"""
+import urlparse
+
from lxml import etree
import stubout
-import urlparse
import webob
-from nova.api.openstack import images
+from nova.api.openstack.v2 import images
+from nova.api.openstack.v2.views import images as images_view
from nova.api.openstack import xmlutil
-from nova.api.openstack.views import images as images_view
from nova import test
from nova import utils
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/test_limits.py b/nova/tests/api/openstack/v2/test_limits.py
index 96e30f756..e167f450c 100644
--- a/nova/tests/api/openstack/test_limits.py
+++ b/nova/tests/api/openstack/v2/test_limits.py
@@ -19,19 +19,20 @@ Tests dealing with HTTP rate-limiting.
import httplib
import json
-from lxml import etree
import StringIO
-import stubout
import time
import unittest
-import webob
from xml.dom import minidom
-import nova.context
-from nova.api.openstack import limits
-from nova.api.openstack import views
+from lxml import etree
+import stubout
+import webob
+
+from nova.api.openstack.v2 import limits
+from nova.api.openstack.v2 import views
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
+import nova.context
from nova import test
diff --git a/nova/tests/api/openstack/test_server_actions.py b/nova/tests/api/openstack/v2/test_server_actions.py
index 9d50483b8..3adde3b7a 100644
--- a/nova/tests/api/openstack/test_server_actions.py
+++ b/nova/tests/api/openstack/v2/test_server_actions.py
@@ -1,3 +1,18 @@
+# Copyright 2011 OpenStack LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
import base64
import datetime
import json
@@ -5,17 +20,17 @@ import json
import stubout
import webob
-from nova import context
-from nova import utils
-from nova import exception
-from nova import flags
-from nova.api.openstack import servers
+from nova.api.openstack.v2 import servers
from nova.compute import vm_states
from nova.compute import instance_types
+from nova import context
import nova.db
+from nova import exception
+from nova import flags
from nova import test
from nova.tests.api.openstack import common
from nova.tests.api.openstack import fakes
+from nova import utils
FLAGS = flags.FLAGS
diff --git a/nova/tests/api/openstack/test_server_metadata.py b/nova/tests/api/openstack/v2/test_server_metadata.py
index 1e0cba541..49ff1bcd8 100644
--- a/nova/tests/api/openstack/test_server_metadata.py
+++ b/nova/tests/api/openstack/v2/test_server_metadata.py
@@ -18,13 +18,13 @@
import json
import webob
-from nova.api.openstack import server_metadata
+from nova.api.openstack.v2 import server_metadata
import nova.db
from nova import exception
from nova import flags
from nova import test
-from nova import utils
from nova.tests.api.openstack import fakes
+from nova import utils
FLAGS = flags.FLAGS
diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/v2/test_servers.py
index 7eaaaa489..34a5dfa51 100644
--- a/nova/tests/api/openstack/test_servers.py
+++ b/nova/tests/api/openstack/v2/test_servers.py
@@ -16,35 +16,28 @@
# License for the specific language governing permissions and limitations
# under the License.
-import base64
import datetime
import json
-import unittest
import urlparse
-from xml.dom import minidom
from lxml import etree
import webob
-import nova.api.openstack
-from nova.api.openstack import servers
-from nova.api.openstack import ips
+import nova.api.openstack.v2
+from nova.api.openstack.v2 import ips
+from nova.api.openstack.v2 import servers
from nova.api.openstack import xmlutil
import nova.compute.api
from nova.compute import instance_types
from nova.compute import task_states
from nova.compute import vm_states
-from nova import context
-from nova import db
import nova.db
from nova.db.sqlalchemy.models import InstanceMetadata
-from nova import exception
from nova import flags
import nova.image.fake
import nova.rpc
import nova.scheduler.api
from nova import test
-from nova.tests.api.openstack import common
from nova.tests.api.openstack import fakes
from nova import utils
@@ -2226,7 +2219,7 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase):
class TestAddressesXMLSerialization(test.TestCase):
- serializer = nova.api.openstack.ips.IPXMLSerializer()
+ serializer = nova.api.openstack.v2.ips.IPXMLSerializer()
def test_xml_declaration(self):
fixture = {
@@ -2304,7 +2297,7 @@ class ServersViewBuilderTest(test.TestCase):
include_fake_metadata=False)
self.uuid = self.instance['uuid']
- self.view_builder = nova.api.openstack.views.servers.ViewBuilder()
+ self.view_builder = nova.api.openstack.v2.views.servers.ViewBuilder()
self.request = fakes.HTTPRequest.blank("/v1.1")
def test_build_server(self):
diff --git a/nova/tests/api/openstack/test_urlmap.py b/nova/tests/api/openstack/v2/test_urlmap.py
index 3995765e5..61a237347 100644
--- a/nova/tests/api/openstack/test_urlmap.py
+++ b/nova/tests/api/openstack/v2/test_urlmap.py
@@ -16,11 +16,11 @@
import json
import webob
-from nova import test
from nova import log as logging
+from nova import test
from nova.tests.api.openstack import fakes
-LOG = logging.getLogger('nova.tests.api.openstack.test_urlmap')
+LOG = logging.getLogger('nova.tests.api.openstack.v2.test_urlmap')
class UrlmapTest(test.TestCase):
diff --git a/nova/tests/api/openstack/test_users.py b/nova/tests/api/openstack/v2/test_users.py
index 82fce68ff..454b7cae7 100644
--- a/nova/tests/api/openstack/test_users.py
+++ b/nova/tests/api/openstack/v2/test_users.py
@@ -20,7 +20,7 @@ import webob
from nova import test
from nova import utils
-from nova.api.openstack import users
+from nova.api.openstack.v2 import users
from nova.auth.manager import User, Project
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/test_versions.py b/nova/tests/api/openstack/v2/test_versions.py
index a6e30187b..392e31a46 100644
--- a/nova/tests/api/openstack/test_versions.py
+++ b/nova/tests/api/openstack/v2/test_versions.py
@@ -22,8 +22,8 @@ from lxml import etree
import stubout
import webob
-from nova.api.openstack import versions
-from nova.api.openstack import views
+from nova.api.openstack.v2 import versions
+from nova.api.openstack.v2 import views
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import context
diff --git a/nova/tests/api/openstack/test_zones.py b/nova/tests/api/openstack/v2/test_zones.py
index 496c3e8e6..4a3e3ed47 100644
--- a/nova/tests/api/openstack/test_zones.py
+++ b/nova/tests/api/openstack/v2/test_zones.py
@@ -20,15 +20,15 @@ from lxml import etree
import stubout
import webob
-import nova.db
+from nova.api.openstack.v2 import zones
+from nova.api.openstack import xmlutil
from nova import context
from nova import crypto
+import nova.db
from nova import flags
+from nova.scheduler import api
from nova import test
-from nova.api.openstack import xmlutil
-from nova.api.openstack import zones
from nova.tests.api.openstack import fakes
-from nova.scheduler import api
FLAGS = flags.FLAGS
diff --git a/nova/tests/integrated/test_extensions.py b/nova/tests/integrated/test_extensions.py
index 958f584ab..4318e30f2 100644
--- a/nova/tests/integrated/test_extensions.py
+++ b/nova/tests/integrated/test_extensions.py
@@ -30,7 +30,7 @@ class ExtensionsTest(integrated_helpers._IntegratedTestBase):
def _get_flags(self):
f = super(ExtensionsTest, self)._get_flags()
f['osapi_extension'] = FLAGS.osapi_extension[:]
- f['osapi_extension'].append('nova.tests.api.openstack.extensions.'
+ f['osapi_extension'].append('nova.tests.api.openstack.v2.extensions.'
'foxinsocks.Foxinsocks')
return f
diff --git a/nova/tests/test_hosts.py b/nova/tests/test_hosts.py
index becc74cdd..32fb5d2cf 100644
--- a/nova/tests/test_hosts.py
+++ b/nova/tests/test_hosts.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import stubout
import webob.exc
from nova import context
@@ -21,7 +20,7 @@ from nova import exception
from nova import flags
from nova import log as logging
from nova import test
-from nova.api.openstack.contrib import hosts as os_hosts
+from nova.api.openstack.v2.contrib import hosts as os_hosts
from nova.scheduler import api as scheduler_api