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
(cherry picked from commit ce098ccce9
)
This commit is contained in:
parent
0d8569e83c
commit
86db5354bc
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue