Merge "API calls to Registry now maintain Request IDs"

This commit is contained in:
Jenkins 2015-04-29 14:04:06 +00:00 committed by Gerrit Code Review
commit 02cf262293
3 changed files with 9 additions and 0 deletions

View File

@ -119,6 +119,7 @@ class ContextMiddleware(BaseContextMiddleware):
'owner_is_tenant': CONF.owner_is_tenant,
'service_catalog': service_catalog,
'policy_enforcer': self.policy_enforcer,
'request_id': req.headers.get('X-Openstack-Request-ID'),
}
return glance.context.RequestContext(**kwargs)

View File

@ -138,6 +138,9 @@ def get_registry_client(cxt):
'X-Service-Catalog': jsonutils.dumps(cxt.service_catalog),
}
kwargs['identity_headers'] = identity_headers
kwargs['request_id'] = cxt.request_id
return client.RegistryClient(_CLIENT_HOST, _CLIENT_PORT,
_METADATA_ENCRYPTION_KEY, **kwargs)

View File

@ -48,6 +48,8 @@ class RegistryClient(BaseClient):
# settings when using keystone. configure_via_auth=False disables
# this behaviour to ensure we still send requests to the Registry API
self.identity_headers = identity_headers
# store available passed request id for do_request call
self._passed_request_id = kwargs.pop('request_id', None)
BaseClient.__init__(self, host, port, configure_via_auth=False,
**kwargs)
@ -112,6 +114,9 @@ class RegistryClient(BaseClient):
try:
kwargs['headers'] = kwargs.get('headers', {})
kwargs['headers'].update(self.identity_headers or {})
if self._passed_request_id:
kwargs['headers']['X-Openstack-Request-ID'] = \
self._passed_request_id
res = super(RegistryClient, self).do_request(method,
action,
**kwargs)