summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-06-01 23:12:56 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2012-06-07 21:25:57 +0000
commit197a424bb43c57c6362d3df4c0d1c9528e823b5d (patch)
tree2a7eca9009e9031ab8218b039e68baa5c0e36954 /nova/api
parent089300fd4bcecaacd2ea3fa345a1b6b2c5b2ab61 (diff)
downloadnova-197a424bb43c57c6362d3df4c0d1c9528e823b5d.tar.gz
nova-197a424bb43c57c6362d3df4c0d1c9528e823b5d.tar.xz
nova-197a424bb43c57c6362d3df4c0d1c9528e823b5d.zip
Add user_name project_name and color option to log
* adds project_name and user_name to context for logging * adds color argument to logging which allows for colored log output based on the log level Change-Id: If37d646fdba77d4214f72b19e5df02da5f7dbac6
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/auth.py4
-rw-r--r--nova/api/ec2/__init__.py4
2 files changed, 8 insertions, 0 deletions
diff --git a/nova/api/auth.py b/nova/api/auth.py
index 7106bee7f..72eba1d9c 100644
--- a/nova/api/auth.py
+++ b/nova/api/auth.py
@@ -84,6 +84,8 @@ class NovaKeystoneContext(wsgi.Middleware):
else:
# This is for legacy compatibility
project_id = req.headers['X_TENANT']
+ project_name = req.headers.get('X_TENANT_NAME')
+ user_name = req.headers.get('X_USER_NAME')
# Get the auth token
auth_token = req.headers.get('X_AUTH_TOKEN',
@@ -95,6 +97,8 @@ class NovaKeystoneContext(wsgi.Middleware):
remote_address = req.headers.get('X-Forwarded-For', remote_address)
ctx = context.RequestContext(user_id,
project_id,
+ user_name=user_name,
+ project_name=project_name,
roles=roles,
auth_token=auth_token,
remote_address=remote_address)
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index 8f0666d82..c9dbd36f8 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -247,6 +247,8 @@ class EC2KeystoneAuth(wsgi.Middleware):
token_id = result['access']['token']['id']
user_id = result['access']['user']['id']
project_id = result['access']['token']['tenant']['id']
+ user_name = result['access']['user'].get('name')
+ project_name = result['access']['token']['tenant'].get('name')
roles = [role['name'] for role
in result['access']['user']['roles']]
except (AttributeError, KeyError), e:
@@ -260,6 +262,8 @@ class EC2KeystoneAuth(wsgi.Middleware):
remote_address)
ctxt = context.RequestContext(user_id,
project_id,
+ user_name=user_name,
+ project_name=project_name,
roles=roles,
auth_token=token_id,
remote_address=remote_address)