Creating new v2 namespace in nova.api.openstack
Related to blueprint separate-nova-adminapi Change-Id: Ida35372b7263c4a4efdafd35faa1325c4436459b
This commit is contained in:
parent
f14ec8a9e2
commit
de635fc882
|
@ -79,38 +79,39 @@ paste.app_factory = nova.api.ec2:Executor.factory
|
|||
#############
|
||||
|
||||
[composite:osapi]
|
||||
use = call:nova.api.openstack.urlmap:urlmap_factory
|
||||
use = call:nova.api.openstack.v2.urlmap:urlmap_factory
|
||||
/: osversions
|
||||
/v1.1: openstackapi11
|
||||
/v1.1: openstack_api_v2
|
||||
/v2: openstack_api_v2
|
||||
|
||||
[pipeline:openstackapi11]
|
||||
pipeline = faultwrap noauth ratelimit serialize extensions osapiapp11
|
||||
[pipeline:openstack_api_v2]
|
||||
pipeline = faultwrap noauth ratelimit serialize extensions osapi_app_v2
|
||||
# NOTE(vish): use the following pipeline for deprecated auth
|
||||
# pipeline = faultwrap auth ratelimit serialize extensions osapiapp11
|
||||
# pipeline = faultwrap auth ratelimit serialize extensions osapi_app_v2
|
||||
|
||||
[filter:faultwrap]
|
||||
paste.filter_factory = nova.api.openstack:FaultWrapper.factory
|
||||
paste.filter_factory = nova.api.openstack.v2:FaultWrapper.factory
|
||||
|
||||
[filter:auth]
|
||||
paste.filter_factory = nova.api.openstack.auth:AuthMiddleware.factory
|
||||
paste.filter_factory = nova.api.openstack.v2.auth:AuthMiddleware.factory
|
||||
|
||||
[filter:noauth]
|
||||
paste.filter_factory = nova.api.openstack.auth:NoAuthMiddleware.factory
|
||||
paste.filter_factory = nova.api.openstack.v2.auth:NoAuthMiddleware.factory
|
||||
|
||||
[filter:ratelimit]
|
||||
paste.filter_factory = nova.api.openstack.limits:RateLimitingMiddleware.factory
|
||||
paste.filter_factory = nova.api.openstack.v2.limits:RateLimitingMiddleware.factory
|
||||
|
||||
[filter:serialize]
|
||||
paste.filter_factory = nova.api.openstack.wsgi:LazySerializationMiddleware.factory
|
||||
|
||||
[filter:extensions]
|
||||
paste.filter_factory = nova.api.openstack.extensions:ExtensionMiddleware.factory
|
||||
paste.filter_factory = nova.api.openstack.v2.extensions:ExtensionMiddleware.factory
|
||||
|
||||
[app:osapiapp11]
|
||||
paste.app_factory = nova.api.openstack:APIRouter.factory
|
||||
[app:osapi_app_v2]
|
||||
paste.app_factory = nova.api.openstack.v2:APIRouter.factory
|
||||
|
||||
[pipeline:osversions]
|
||||
pipeline = faultwrap osversionapp
|
||||
|
||||
[app:osversionapp]
|
||||
paste.app_factory = nova.api.openstack.versions:Versions.factory
|
||||
paste.app_factory = nova.api.openstack.v2.versions:Versions.factory
|
||||
|
|
|
@ -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']})
|
|
@ -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
|
|
@ -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']})
|
|
@ -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):
|
|
@ -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
|
|
@ -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):
|
|
@ -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):
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -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):
|
|
@ -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
|
|
@ -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):
|
|
@ -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
|
|
@ -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):
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -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):
|
|
@ -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
|
|
@ -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):
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -15,17 +15,18 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import urlparse
|
||||
import webob
|
||||
|
||||
from datetime import datetime
|
||||
import urlparse
|
||||
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.v2 import extensions
|
||||
from nova.api.openstack.v2 import views
|
||||
from nova.compute import api
|
||||
from nova.db.sqlalchemy.session import get_session
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
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
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
|
@ -15,14 +15,14 @@
|
|||
|
||||
"""The virtual interfaces extension."""
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.v2 import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
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 import wsgi
|
||||
|
||||
|
||||
LOG = logging.getLogger("nova.api.virtual_interfaces")
|
||||
LOG = logging.getLogger("nova.api.openstack.v2.contrib.virtual_interfaces")
|
||||
|
||||
|
||||
def _translate_vif_summary_view(_context, vif):
|
|
@ -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 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 flags
|
||||
from nova import log as logging
|
||||
from nova import vsa
|
||||
from nova import volume
|
||||
|
||||
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):
|
|
@ -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
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -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()})
|
|
@ -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
|
|
@ -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
|
|
@ -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 = {
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
from lxml import etree
|
||||
from webob.dec import wsgify
|
||||
import webob.exc
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from webob.dec import wsgify
|
||||
|
||||
from nova.api.openstack import common
|
||||
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
|
||||
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 import wsgi
|
||||
from nova.api.openstack import xmlutil
|
||||
|
||||
|
||||
# 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)
|
||||
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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):
|
|
@ -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):
|
|
@ -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'])
|
||||
|
||||
|
|
@ -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):
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
import os.path
|
||||
|
||||
|
||||
from nova.api.openstack import common
|
||||
|
||||
|
|
@ -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):
|
|
@ -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):
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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.
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
import nova.db.api
|
||||
import nova.rpc
|
||||
|
||||
from nova import flags
|
||||
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 v2
|
||||
from nova.api.openstack.v2 import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
import nova.db.api
|
||||
from nova import flags
|
||||
import nova.rpc
|
||||
from nova import test
|
||||
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
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import webob
|
||||
|
||||
from nova import compute
|
|
@ -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
|
||||
|
|
@ -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):
|
|
@ -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
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import stubout
|
||||
import webob
|
||||
|
|
@ -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,
|
|
@ -13,6 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import webob
|
||||
|
||||
from nova import compute
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -14,13 +14,14 @@
|
|||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import webob
|
||||
|
||||
from nova import test
|
||||
from nova import network
|
||||
from nova.tests.api.openstack import fakes
|
||||
from nova.api.openstack.contrib.virtual_interfaces import \
|
||||
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
|
||||
|
||||
|
||||
def get_vifs_by_instance(self, context, server_id):
|
|
@ -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 = {}
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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 = {}
|
||||
|
|
@ -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):
|
|
@ -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
|
||||
|
|
@ -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)
|
|
@ -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
|
|
@ -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
|
|
@ -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)
|
|
@ -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
|
|
@ -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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue