Merge "operation_log: Expose IP address of the user"

This commit is contained in:
Jenkins 2017-05-18 09:48:00 +00:00 committed by Gerrit Code Review
commit a31aa072a3
3 changed files with 6 additions and 2 deletions

View File

@ -1820,6 +1820,7 @@ This setting controls the behavior of the operation log.
Currently you can use the following keywords.
The default value contains all keywords.
* %(client_ip)s
* %(domain_name)s
* %(domain_id)s
* %(project_name)s

View File

@ -60,7 +60,8 @@ class OperationLogMiddleware(object):
_available_methods = ['POST', 'GET', 'PUT', 'DELETE']
_methods = _log_option.get("target_methods", ['POST'])
_default_format = (
"[%(domain_name)s] [%(domain_id)s] [%(project_name)s]"
"[%(client_ip)s] [%(domain_name)s]"
" [%(domain_id)s] [%(project_name)s]"
" [%(project_id)s] [%(user_name)s] [%(user_id)s]"
" [%(request_scheme)s] [%(referer_url)s] [%(request_url)s]"
" [%(message)s] [%(method)s] [%(http_status)s] [%(param)s]")
@ -134,6 +135,7 @@ class OperationLogMiddleware(object):
except Exception:
pass
return {
'client_ip': request.META.get('REMOTE_ADDR', None),
'domain_name': getattr(user, 'domain_name', None),
'domain_id': getattr(user, 'domain_id', None),
'project_name': getattr(user, 'project_name', None),

View File

@ -798,7 +798,8 @@ REST_API_REQUIRED_SETTINGS = ['OPENSTACK_HYPERVISOR_FEATURES',
#OPERATION_LOG_OPTIONS = {
# 'mask_fields': ['password'],
# 'target_methods': ['POST'],
# 'format': ("[%(domain_name)s] [%(domain_id)s] [%(project_name)s]"
# 'format': ("[%(client_ip)s] [%(domain_name)s]"
# " [%(domain_id)s] [%(project_name)s]"
# " [%(project_id)s] [%(user_name)s] [%(user_id)s] [%(request_scheme)s]"
# " [%(referer_url)s] [%(request_url)s] [%(message)s] [%(method)s]"
# " [%(http_status)s] [%(param)s]"),