Merge ResourceV21 obj into Resource obj
In the past, we have two code bases for the v2.1 API and legacy v2 API. Then we need two Resource objects, the ResourceV21 object supports microversion, the Resource object doesn't. But now the old legacy v2 API code base is removed, then we only need one Resource object which support the microversion. Partial implement bp api-extensions-merge-queens Change-Id: I0cc0d5ad850e01f0c0d96d698ffdce7ae515faf8
This commit is contained in:
parent
365e876605
commit
51cd59f5fb
nova
@ -108,7 +108,7 @@ def _create_controller(main_controller, controller_list,
|
||||
same resource will be merged into single one controller.
|
||||
"""
|
||||
|
||||
controller = wsgi.ResourceV21(main_controller())
|
||||
controller = wsgi.Resource(main_controller())
|
||||
for ctl in controller_list:
|
||||
controller.register_extensions(ctl())
|
||||
for ctl in action_controller_list:
|
||||
|
@ -73,6 +73,10 @@ VERSIONS = {
|
||||
|
||||
|
||||
class Versions(wsgi.Resource):
|
||||
|
||||
# The root version API isn't under the microversion control.
|
||||
support_api_request_version = False
|
||||
|
||||
def __init__(self):
|
||||
super(Versions, self).__init__(None)
|
||||
|
||||
|
@ -436,7 +436,7 @@ class Resource(wsgi.Application):
|
||||
wrapped in Fault() to provide API friendly error responses.
|
||||
|
||||
"""
|
||||
support_api_request_version = False
|
||||
support_api_request_version = True
|
||||
|
||||
def __init__(self, controller, inherits=None):
|
||||
""":param controller: object that implement methods created by routes
|
||||
@ -741,10 +741,6 @@ class Resource(wsgi.Application):
|
||||
return Fault(webob.exc.HTTPNotFound())
|
||||
|
||||
|
||||
class ResourceV21(Resource):
|
||||
support_api_request_version = True
|
||||
|
||||
|
||||
def action(name):
|
||||
"""Mark a function as an action.
|
||||
|
||||
|
@ -273,15 +273,6 @@ class TestRouter(wsgi.Router):
|
||||
super(TestRouter, self).__init__(mapper)
|
||||
|
||||
|
||||
class TestRouterV21(wsgi.Router):
|
||||
def __init__(self, controller, mapper=None):
|
||||
if not mapper:
|
||||
mapper = routes.Mapper()
|
||||
mapper.resource("test", "tests",
|
||||
controller=os_wsgi.ResourceV21(controller))
|
||||
super(TestRouterV21, self).__init__(mapper)
|
||||
|
||||
|
||||
class FakeAuthDatabase(object):
|
||||
data = {}
|
||||
|
||||
|
@ -268,7 +268,7 @@ class ResourceTest(MicroversionedTest):
|
||||
raise webob.exc.HTTPInternalServerError()
|
||||
return 'success'
|
||||
|
||||
app = fakes.TestRouterV21(Controller())
|
||||
app = fakes.TestRouter(Controller())
|
||||
req = webob.Request.blank('/tests')
|
||||
response = req.get_response(app)
|
||||
self.assertEqual(b'success', response.body)
|
||||
@ -286,7 +286,7 @@ class ResourceTest(MicroversionedTest):
|
||||
raise webob.exc.HTTPInternalServerError()
|
||||
return 'success'
|
||||
|
||||
app = fakes.TestRouterV21(Controller())
|
||||
app = fakes.TestRouter(Controller())
|
||||
req = webob.Request.blank('/tests')
|
||||
req.headers = self._make_microversion_header(version)
|
||||
response = req.get_response(app)
|
||||
@ -300,7 +300,7 @@ class ResourceTest(MicroversionedTest):
|
||||
def index(self, req):
|
||||
return 'success'
|
||||
|
||||
app = fakes.TestRouterV21(Controller())
|
||||
app = fakes.TestRouter(Controller())
|
||||
req = webob.Request.blank('/tests')
|
||||
req.headers = self._make_microversion_header(invalid_version)
|
||||
response = req.get_response(app)
|
||||
|
Loading…
x
Reference in New Issue
Block a user