Return x-openstack-request-id header to the caller

This commit adds request-id filter to paste config and adds support for
request_id to the ContextMiddleware. This would mean, that request-id,
generated for each particular request to api would be returned to the
caller in the form of 'x-openstack-request-id' header

Targets blueprint: murano-x-openstack-request-id-support

Change-Id: Id3d593c33fd31bae7226052b908750e5c000f730
This commit is contained in:
Kirill Zaitsev 2015-08-12 16:46:38 +03:00
parent b64b9d72ee
commit 741ee084b6
3 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,5 @@
[pipeline:murano]
pipeline = versionnegotiation faultwrap authtoken context rootapp
pipeline = request_id versionnegotiation faultwrap authtoken context rootapp
[filter:context]
paste.filter_factory = murano.api.middleware.context:ContextMiddleware.factory
@ -25,3 +25,7 @@ paste.filter_factory = murano.api.middleware.version_negotiation:VersionNegotiat
[filter:faultwrap]
paste.filter_factory = murano.api.middleware.fault:FaultWrapper.factory
# Middleware to set x-openstack-request-id in http response header
[filter:request_id]
paste.filter_factory = oslo_middleware.request_id:RequestId.factory

View File

@ -14,6 +14,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import request_id as oslo_request_id
from murano.common.i18n import _
from murano.common import wsgi
@ -48,6 +49,7 @@ class ContextMiddleware(wsgi.Middleware):
'auth_token': req.headers.get('X-Auth-Token'),
'session': req.headers.get('X-Configuration-Session'),
'is_admin': CONF.admin_role in roles,
'request_id': req.environ.get(oslo_request_id.ENV_REQUEST_ID),
'roles': roles
}
req.context = murano.context.RequestContext(**kwargs)

View File

@ -35,6 +35,7 @@ oslo.config>=2.1.0 # Apache-2.0
oslo.context>=0.2.0 # Apache-2.0
oslo.policy>=0.5.0 # Apache-2.0
oslo.messaging!=1.17.0,!=1.17.1,>=1.16.0 # Apache-2.0
oslo.middleware>=2.4.0 # Apache-2.0
oslo.serialization>=1.4.0 # Apache-2.0
oslo.service>=0.1.0 # Apache-2.0
oslo.utils>=1.9.0 # Apache-2.0