Merge "Rename zone > domain for errors in V1"

This commit is contained in:
Jenkins 2016-01-25 16:46:32 +00:00 committed by Gerrit Code Review
commit e2061af49c
2 changed files with 21 additions and 2 deletions

View File

@ -272,6 +272,9 @@ class FaultWrapperMiddleware(base.Middleware):
# Handle all other exception types
return self._handle_exception(request, e)
def _format_error(self, data):
pass
def _handle_exception(self, request, e, status=500, response=None):
response = response or {}
@ -292,6 +295,8 @@ class FaultWrapperMiddleware(base.Middleware):
if 'type' not in response:
response['type'] = 'unknown'
self._format_error(response)
# Return the new response
if 'context' in request.environ:
response['request_id'] = request.environ['context'].request_id
@ -307,6 +312,17 @@ class FaultWrapperMiddleware(base.Middleware):
response=json.dumps(response))
class FaultWrapperMiddlewareV1(FaultWrapperMiddleware):
def _format_error(self, data):
replace_map = [
("zone", "domain",)
]
for i in replace_map:
data["type"] = data["type"].replace(i[0], i[1])
print(data)
class ValidationErrorMiddleware(base.Middleware):
def __init__(self, application):

View File

@ -15,8 +15,8 @@ paste.app_factory = designate.api.versions:factory
[composite:osapi_dns_v1]
use = call:designate.api.middleware:auth_pipeline_factory
noauth = http_proxy_to_wsgi cors request_id noauthcontext maintenance validation_API_v1 faultwrapper normalizeuri osapi_dns_app_v1
keystone = http_proxy_to_wsgi cors request_id authtoken keystonecontext maintenance validation_API_v1 faultwrapper normalizeuri osapi_dns_app_v1
noauth = http_proxy_to_wsgi cors request_id noauthcontext maintenance validation_API_v1 faultwrapper_v1 normalizeuri osapi_dns_app_v1
keystone = http_proxy_to_wsgi cors request_id authtoken keystonecontext maintenance validation_API_v1 faultwrapper_v1 normalizeuri osapi_dns_app_v1
[app:osapi_dns_app_v1]
@ -66,6 +66,9 @@ paste.filter_factory = designate.api.middleware:NormalizeURIMiddleware.factory
[filter:faultwrapper]
paste.filter_factory = designate.api.middleware:FaultWrapperMiddleware.factory
[filter:faultwrapper_v1]
paste.filter_factory = designate.api.middleware:FaultWrapperMiddlewareV1.factory
[filter:validation_API_v1]
paste.filter_factory = designate.api.middleware:APIv1ValidationErrorMiddleware.factory