Ignore all failures removing catalog when logging token
Operations could fail if the response was logged and had a 'token' field that's not a dict. The fix is to ignore all errors when trying to remove the service catalog from the response. Also, enhanced the service catalog removal code to support V2 tokens. Closes-Bug: 1420080 Change-Id: I35b971415744825e8e5f00f30dcf193d04ee699a
This commit is contained in:
parent
f82f274f6b
commit
9ceb44c612
|
@ -57,16 +57,21 @@ def request(url, method='GET', **kwargs):
|
|||
def remove_service_catalog(body):
|
||||
try:
|
||||
data = jsonutils.loads(body)
|
||||
except ValueError:
|
||||
return body
|
||||
try:
|
||||
if 'catalog' in data['token']:
|
||||
|
||||
# V3 token
|
||||
if 'token' in data and 'catalog' in data['token']:
|
||||
data['token']['catalog'] = '<removed>'
|
||||
return jsonutils.dumps(data)
|
||||
else:
|
||||
return body
|
||||
except KeyError:
|
||||
return body
|
||||
|
||||
# V2 token
|
||||
if 'serviceCatalog' in data['access']:
|
||||
data['access']['serviceCatalog'] = '<removed>'
|
||||
return jsonutils.dumps(data)
|
||||
|
||||
except Exception:
|
||||
# Don't fail trying to clean up the request body.
|
||||
pass
|
||||
return body
|
||||
|
||||
|
||||
class Session(object):
|
||||
|
|
Loading…
Reference in New Issue