summaryrefslogtreecommitdiffstats
path: root/nova/context.py
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-01-10 18:22:00 +0000
committerRick Harris <rconradharris@gmail.com>2013-01-10 18:22:00 +0000
commitce098ccce9d67df8c243fa885640989a4703ac53 (patch)
tree5b9b33b798842bd36390e6393d49de17ec175a51 /nova/context.py
parent35d183456869e3502289a45fe0d6c2c2616922c5 (diff)
downloadnova-ce098ccce9d67df8c243fa885640989a4703ac53.tar.gz
nova-ce098ccce9d67df8c243fa885640989a4703ac53.tar.xz
nova-ce098ccce9d67df8c243fa885640989a4703ac53.zip
Add user/tenant shim to RequestContext
This is necessary because we pass the Nova context object to openstack-common/code (logging, for example), which expects the attributes to be named user/tenant not user_id/project_id. Fixes bug 1098278 Change-Id: Ic0dc49ef54515fc0ffaa0895cf4d88701afb1e16
Diffstat (limited to 'nova/context.py')
-rw-r--r--nova/context.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/nova/context.py b/nova/context.py
index 094e2bffb..1a566cb5a 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -124,7 +124,9 @@ class RequestContext(object):
'user_name': self.user_name,
'service_catalog': self.service_catalog,
'project_name': self.project_name,
- 'instance_lock_checked': self.instance_lock_checked}
+ 'instance_lock_checked': self.instance_lock_checked,
+ 'tenant': self.tenant,
+ 'user': self.user}
@classmethod
def from_dict(cls, values):
@@ -143,6 +145,19 @@ class RequestContext(object):
return context
+ # NOTE(sirp): the openstack/common version of RequestContext uses
+ # tenant/user whereas the Nova version uses project_id/user_id. We need
+ # this shim in order to use context-aware code from openstack/common, like
+ # logging, until we make the switch to using openstack/common's version of
+ # RequestContext.
+ @property
+ def tenant(self):
+ return self.project_id
+
+ @property
+ def user(self):
+ return self.user_id
+
def get_admin_context(read_deleted="no"):
return RequestContext(user_id=None,