From: Jay S. Bryant Date: Fri, 19 Dec 2014 21:06:19 +0000 (-0600) Subject: Sync the latest middleware module from oslo-incubator X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=30ec621dfd8d79be69e1789118210f04e2fbc2b6;p=openstack-build%2Fcinder-build.git Sync the latest middleware module from oslo-incubator Middleware hasn't had a sync from oslo-incubator since the middle of the icehouse development cycle. This sync brings us up to date with the latest changes. Current HEAD in OSLO: --------------------- commit 36b0e8570b449129d6d474c03b02ceb62edb78df Date: Thu Dec 11 11:27:08 2014 +0100 We shouldn't replace `oslo-incubator` in comments Changes being merged with this patch by file: --------------------- catch_errors.py - ce8f8fa4 - Add middleware.catch_errors shim for Kilo - 4504e4f4 - Remove middleware - 5d40e143 - Remove code that moved to oslo.i18n - 76183592 - add deprecation note to middleware - 463e6916 - remove oslo log from middleware - fcf517d7 - Update oslo log messages with translation domains - fdcae242 - Middleware to catch all error in WSGI pipeline request_id.py - 4ffc4c87 - Add middleware.request_id shim for Kilo - 4504e4f4 - Remove middleware - 76183592 - add deprecation note to middleware Change-Id: I572b4c186a8ba2f774ba840307b917f273c529ea --- diff --git a/cinder/openstack/common/middleware/catch_errors.py b/cinder/openstack/common/middleware/catch_errors.py new file mode 100644 index 000000000..727372bf1 --- /dev/null +++ b/cinder/openstack/common/middleware/catch_errors.py @@ -0,0 +1,23 @@ +# 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. + +"""Compatibility shim for Kilo, while operators migrate to oslo.middleware.""" + +from oslo.middleware import catch_errors + +from cinder.openstack.common import versionutils + + +@versionutils.deprecated(as_of=versionutils.deprecated.KILO, + in_favor_of='oslo.middleware.CatchErrors') +class CatchErrorsMiddleware(catch_errors.CatchErrors): + pass diff --git a/cinder/openstack/common/middleware/request_id.py b/cinder/openstack/common/middleware/request_id.py index e7e415776..d5d0bfc4c 100644 --- a/cinder/openstack/common/middleware/request_id.py +++ b/cinder/openstack/common/middleware/request_id.py @@ -1,6 +1,3 @@ -# Copyright (c) 2013 NEC Corporation -# 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 @@ -13,29 +10,18 @@ # License for the specific language governing permissions and limitations # under the License. -"""Middleware that ensures request ID. - -It ensures to assign request ID for each API request and set it to -request environment. The request ID is also added to API response. -""" +"""Compatibility shim for Kilo, while operators migrate to oslo.middleware.""" -import webob.dec +from oslo.middleware import request_id -from cinder.openstack.common import context -from cinder.openstack.common.middleware import base +from cinder.openstack.common import versionutils ENV_REQUEST_ID = 'openstack.request_id' HTTP_RESP_HEADER_REQUEST_ID = 'x-openstack-request-id' -class RequestIdMiddleware(base.Middleware): - - @webob.dec.wsgify - def __call__(self, req): - req_id = context.generate_request_id() - req.environ[ENV_REQUEST_ID] = req_id - response = req.get_response(self.application) - if HTTP_RESP_HEADER_REQUEST_ID not in response.headers: - response.headers.add(HTTP_RESP_HEADER_REQUEST_ID, req_id) - return response +@versionutils.deprecated(as_of=versionutils.deprecated.KILO, + in_favor_of='oslo.middleware.RequestId') +class RequestIdMiddleware(request_id.RequestId): + pass