Added request_id and global_request_id to CADF notifications
Change-Id: I8d571d3414071c68b4fa565dec46cc2d2941331c Closes-Bug: #1803940
This commit is contained in:
parent
899aa07a64
commit
f2f5820c5f
@ -57,10 +57,15 @@ class PycadfAuditApiConfigError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class ClientResource(resource.Resource):
|
class ClientResource(resource.Resource):
|
||||||
def __init__(self, project_id=None, **kwargs):
|
def __init__(self, project_id=None, request_id=None,
|
||||||
|
global_request_id=None, **kwargs):
|
||||||
super(ClientResource, self).__init__(**kwargs)
|
super(ClientResource, self).__init__(**kwargs)
|
||||||
if project_id is not None:
|
if project_id is not None:
|
||||||
self.project_id = project_id
|
self.project_id = project_id
|
||||||
|
if request_id is not None:
|
||||||
|
self.request_id = request_id
|
||||||
|
if global_request_id is not None:
|
||||||
|
self.global_request_id = global_request_id
|
||||||
|
|
||||||
|
|
||||||
class KeystoneCredential(credential.Credential):
|
class KeystoneCredential(credential.Credential):
|
||||||
@ -297,7 +302,10 @@ class OpenStackAuditApi(object):
|
|||||||
token=req.environ.get('HTTP_X_AUTH_TOKEN', ''),
|
token=req.environ.get('HTTP_X_AUTH_TOKEN', ''),
|
||||||
identity_status=req.environ.get('HTTP_X_IDENTITY_STATUS',
|
identity_status=req.environ.get('HTTP_X_IDENTITY_STATUS',
|
||||||
taxonomy.UNKNOWN)),
|
taxonomy.UNKNOWN)),
|
||||||
project_id=req.environ.get('HTTP_X_PROJECT_ID', taxonomy.UNKNOWN))
|
project_id=req.environ.get('HTTP_X_PROJECT_ID', taxonomy.UNKNOWN),
|
||||||
|
request_id=req.environ.get('openstack.request_id'),
|
||||||
|
global_request_id=req.environ.get('openstack.global_request_id'))
|
||||||
|
|
||||||
target = self.get_target_resource(req)
|
target = self.get_target_resource(req)
|
||||||
|
|
||||||
event = factory.EventFactory().new_event(
|
event = factory.EventFactory().new_event(
|
||||||
|
@ -395,3 +395,25 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
|||||||
self.assertNotIn('reporterchain', payload)
|
self.assertNotIn('reporterchain', payload)
|
||||||
self.assertEqual(payload['observer']['id'], 'target')
|
self.assertEqual(payload['observer']['id'], 'target')
|
||||||
self.assertEqual(path, payload['requestPath'])
|
self.assertEqual(path, payload['requestPath'])
|
||||||
|
|
||||||
|
def test_request_and_global_request_id(self):
|
||||||
|
path = '/v1/' + str(uuid.uuid4())
|
||||||
|
url = 'https://23.253.72.207' + path
|
||||||
|
|
||||||
|
request_id = 'req-%s' % uuid.uuid4()
|
||||||
|
global_request_id = 'req-%s' % uuid.uuid4()
|
||||||
|
|
||||||
|
env_headers = self.get_environ_header('GET')
|
||||||
|
env_headers['openstack.request_id'] = request_id
|
||||||
|
env_headers['openstack.global_request_id'] = global_request_id
|
||||||
|
|
||||||
|
payload = self.get_payload('GET', url, environ=env_headers)
|
||||||
|
|
||||||
|
self.assertEqual(payload['initiator']['request_id'], request_id)
|
||||||
|
self.assertEqual(payload['initiator']['global_request_id'],
|
||||||
|
global_request_id)
|
||||||
|
|
||||||
|
payload = self.get_payload('GET', url)
|
||||||
|
|
||||||
|
self.assertNotIn('request_id', payload['initiator'])
|
||||||
|
self.assertNotIn('global_request_id', payload['initiator'])
|
||||||
|
5
releasenotes/notes/bug-1803940-9a39c66014763af0.yaml
Normal file
5
releasenotes/notes/bug-1803940-9a39c66014763af0.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- >
|
||||||
|
[`bug 1803940 <https://bugs.launchpad.net/keystonemiddleware/+bug/1803940>`_]
|
||||||
|
Request ID and global request ID have been added to CADF notifications.
|
Loading…
x
Reference in New Issue
Block a user