Set id for services in catalog

currently enabling audit middleware results in every request producing
warning in the log 'Invalid uuid: ' from pycadf,
due to audit middleware not being able find a uuid to set as a
service/target id because auth_token middleware no longer passes ids
of the endpoints to the catalog it sets on request.

This patch adds service id to the catalog being set by auth_token,
and uses it in audit middleware too. This will hopefully not
dramatically increase the size of the catalog.

Change-Id: I8417bd29b129f4afdd8b43e4f74ea126ee8fae4f
This commit is contained in:
Pavlo Shchelokovskyy 2023-04-04 18:18:19 +00:00
parent 92cdf8a0a5
commit 9243654022
3 changed files with 3 additions and 1 deletions

View File

@ -196,7 +196,7 @@ class OpenStackAuditApi(object):
endp['type'],
taxonomy.UNKNOWN),
name=endp['name'],
id=endp['endpoints'][0].get('id', endp['name']),
id=endp.get('id', endp['name']),
admin_endp=endpoint.Endpoint(
name='admin',
url=endp['endpoints'][0].get('adminURL', taxonomy.UNKNOWN)),

View File

@ -24,6 +24,7 @@ def _normalize_catalog(catalog):
service = {'type': v3_service['type']}
try:
service['name'] = v3_service['name']
service['id'] = v3_service['id']
except KeyError: # nosec
# v3 service doesn't have a name, move on.
pass

View File

@ -78,6 +78,7 @@ class BaseAuditMiddlewareTest(utils.MiddlewareTestCase):
"internalURL":
"http://internal_host:8774",
"id": "resource_id"}],
"id": "resource_id",
"type": "compute",
"name": "nova"}]''',
'HTTP_X_USER_ID': 'user_id',