summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-01-10 18:22:00 +0000
committerChris Behrens <cbehrens@codestud.com>2013-01-10 18:58:24 +0000
commit86db5354bce8b530dde74abce2e96afbf18a17fc (patch)
tree4615dd2ca9273d6788f42b7d7ed7a9d6057fd258
parent0d8569e83c3212b7b871a08aa0dc928134bd6338 (diff)
downloadnova-grizzly-2.tar.gz
Add user/tenant shim to RequestContextgrizzly-2
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 (cherry picked from commit ce098ccce9d67df8c243fa885640989a4703ac53)
-rw-r--r--nova/context.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/nova/context.py b/nova/context.py
index 094e2bffbc..1a566cb5a6 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,