Remove deprecated context usage

Remove the deprecated context usage in olso.context.
It incluedes: user, tenant, domain, user_domain, project_domain.

Change-Id: Iec7b7b67e4139987c8d0f6dbf85c04255d704231
This commit is contained in:
wangxiyuan 2017-08-28 16:34:38 +08:00 committed by gecong
parent 8cf44f278b
commit 6f79c5ece7
2 changed files with 19 additions and 18 deletions

View File

@ -243,12 +243,13 @@ def inject_context(req, resp, params):
""" """
client_id = req.get_header('Client-ID') client_id = req.get_header('Client-ID')
project_id = params.get('project_id') request_id = req.headers.get('X-Openstack-Request-ID')
request_id = req.headers.get('X-Openstack-Request-ID'),
auth_token = req.headers.get('X-AUTH-TOKEN') auth_token = req.headers.get('X-AUTH-TOKEN')
user = req.headers.get('X-USER-ID') project_id = params.get('project_id')
tenant = req.headers.get('X-TENANT-ID') user_id = req.headers.get('X-USER-ID')
domain_id = req.headers.get('X-DOMAIN-ID')
project_domain_id = req.headers.get('X-PROJECT-DOMAIN-ID')
user_domain_id = req.headers.get('X-USER-DOMAIN-ID')
roles = req.headers.get('X-ROLES') roles = req.headers.get('X-ROLES')
roles = roles and roles.split(',') or [] roles = roles and roles.split(',') or []
@ -256,7 +257,9 @@ def inject_context(req, resp, params):
client_id=client_id, client_id=client_id,
request_id=request_id, request_id=request_id,
auth_token=auth_token, auth_token=auth_token,
user=user, user_id=user_id,
tenant=tenant, roles=roles,
roles=roles) domain_id=domain_id,
project_domain_id=project_domain_id,
user_domain_id=user_domain_id)
req.env['zaqar.context'] = ctxt req.env['zaqar.context'] = ctxt

View File

@ -23,22 +23,20 @@ from oslo_context import context
class RequestContext(context.RequestContext): class RequestContext(context.RequestContext):
def __init__(self, project_id=None, client_id=None, overwrite=True, def __init__(self, project_id=None, client_id=None, overwrite=True,
auth_token=None, user=None, tenant=None, domain=None, auth_token=None, user_id=None, domain_id=None,
user_domain=None, project_domain=None, is_admin=False, user_domain_id=None, project_domain_id=None, is_admin=False,
read_only=False, show_deleted=False, request_id=None, read_only=False, request_id=None, roles=None, **kwargs):
instance_uuid=None, roles=None, **kwargs):
super(RequestContext, self).__init__(auth_token=auth_token, super(RequestContext, self).__init__(auth_token=auth_token,
user=user, user=user_id,
tenant=tenant, tenant=project_id,
domain=domain, domain=domain_id,
user_domain=user_domain, user_domain=user_domain_id,
project_domain=project_domain, project_domain=project_domain_id,
is_admin=is_admin, is_admin=is_admin,
read_only=read_only, read_only=read_only,
show_deleted=False, show_deleted=False,
request_id=request_id, request_id=request_id,
roles=roles) roles=roles)
self.project_id = project_id
self.client_id = client_id self.client_id = client_id
if overwrite or not hasattr(context._request_store, 'context'): if overwrite or not hasattr(context._request_store, 'context'):
self.update_store() self.update_store()