From 6f79c5ece724370973ae986d77154907ebd4fcf6 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Mon, 28 Aug 2017 16:34:38 +0800 Subject: [PATCH] Remove deprecated context usage Remove the deprecated context usage in olso.context. It incluedes: user, tenant, domain, user_domain, project_domain. Change-Id: Iec7b7b67e4139987c8d0f6dbf85c04255d704231 --- zaqar/common/transport/wsgi/helpers.py | 19 +++++++++++-------- zaqar/context.py | 18 ++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/zaqar/common/transport/wsgi/helpers.py b/zaqar/common/transport/wsgi/helpers.py index aa8a87b55..9bc397574 100644 --- a/zaqar/common/transport/wsgi/helpers.py +++ b/zaqar/common/transport/wsgi/helpers.py @@ -243,12 +243,13 @@ def inject_context(req, resp, params): """ 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') - user = req.headers.get('X-USER-ID') - tenant = req.headers.get('X-TENANT-ID') - + project_id = params.get('project_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 = roles and roles.split(',') or [] @@ -256,7 +257,9 @@ def inject_context(req, resp, params): client_id=client_id, request_id=request_id, auth_token=auth_token, - user=user, - tenant=tenant, - roles=roles) + user_id=user_id, + roles=roles, + domain_id=domain_id, + project_domain_id=project_domain_id, + user_domain_id=user_domain_id) req.env['zaqar.context'] = ctxt diff --git a/zaqar/context.py b/zaqar/context.py index 339b091ef..e3aba11a7 100644 --- a/zaqar/context.py +++ b/zaqar/context.py @@ -23,22 +23,20 @@ from oslo_context import context class RequestContext(context.RequestContext): def __init__(self, project_id=None, client_id=None, overwrite=True, - auth_token=None, user=None, tenant=None, domain=None, - user_domain=None, project_domain=None, is_admin=False, - read_only=False, show_deleted=False, request_id=None, - instance_uuid=None, roles=None, **kwargs): + auth_token=None, user_id=None, domain_id=None, + user_domain_id=None, project_domain_id=None, is_admin=False, + read_only=False, request_id=None, roles=None, **kwargs): super(RequestContext, self).__init__(auth_token=auth_token, - user=user, - tenant=tenant, - domain=domain, - user_domain=user_domain, - project_domain=project_domain, + user=user_id, + tenant=project_id, + domain=domain_id, + user_domain=user_domain_id, + project_domain=project_domain_id, is_admin=is_admin, read_only=read_only, show_deleted=False, request_id=request_id, roles=roles) - self.project_id = project_id self.client_id = client_id if overwrite or not hasattr(context._request_store, 'context'): self.update_store()