Switch to use <user/project>_domain_id in context
Unreadable logs from oslo.context warnings. "Using the 'project_domain' argument is deprecated in version '2.18' and will be removed in version '3.0'" Change-Id: Icfe18a5d299da4b6b4024374791be53f2b3e41f2
This commit is contained in:
parent
de6b6dd024
commit
3cf6c575db
@ -91,18 +91,12 @@ class RequestContext(context.RequestContext):
|
||||
:param overwrite: Set to False to ensure that the greenthread local
|
||||
copy of the index is not overwritten.
|
||||
"""
|
||||
if user_domain_id:
|
||||
kwargs['user_domain'] = user_domain_id
|
||||
if project_domain_id:
|
||||
kwargs['project_domain'] = project_domain_id
|
||||
|
||||
super(RequestContext, self).__init__(is_admin=is_admin,
|
||||
read_only=read_only,
|
||||
show_deleted=show_deleted,
|
||||
request_id=request_id,
|
||||
roles=roles,
|
||||
overwrite=overwrite,
|
||||
**kwargs)
|
||||
super(RequestContext, self).__init__(
|
||||
is_admin=is_admin, read_only=read_only,
|
||||
show_deleted=show_deleted, request_id=request_id,
|
||||
roles=roles, user_domain_id=user_domain_id,
|
||||
project_domain_id=project_domain_id,
|
||||
overwrite=overwrite, **kwargs)
|
||||
|
||||
self.username = username
|
||||
self.password = password
|
||||
@ -185,8 +179,8 @@ class RequestContext(context.RequestContext):
|
||||
'show_deleted': self.show_deleted,
|
||||
'region_name': self.region_name,
|
||||
'user_identity': user_idt,
|
||||
'user_domain': self.user_domain,
|
||||
'project_domain': self.project_domain}
|
||||
'user_domain_id': self.user_domain_id,
|
||||
'project_domain_id': self.project_domain_id}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, values):
|
||||
@ -207,8 +201,8 @@ class RequestContext(context.RequestContext):
|
||||
request_id=values.get('request_id'),
|
||||
show_deleted=values.get('show_deleted', False),
|
||||
region_name=values.get('region_name'),
|
||||
user_domain_id=values.get('user_domain'),
|
||||
project_domain_id=values.get('project_domain')
|
||||
user_domain_id=values.get('user_domain_id'),
|
||||
project_domain_id=values.get('project_domain_id')
|
||||
)
|
||||
|
||||
def to_policy_values(self):
|
||||
@ -299,8 +293,8 @@ class StoredContext(RequestContext):
|
||||
auth_ref = self.auth_plugin.get_access(self.keystone_session)
|
||||
|
||||
self.roles = auth_ref.role_names
|
||||
self.user_domain = auth_ref.user_domain_id
|
||||
self.project_domain = auth_ref.project_domain_id
|
||||
self.user_domain_id = auth_ref.user_domain_id
|
||||
self.project_domain_id = auth_ref.project_domain_id
|
||||
|
||||
@property
|
||||
def roles(self):
|
||||
@ -313,24 +307,24 @@ class StoredContext(RequestContext):
|
||||
self._roles = roles
|
||||
|
||||
@property
|
||||
def user_domain(self):
|
||||
def user_domain_id(self):
|
||||
if not getattr(self, '_keystone_loaded', False):
|
||||
self._load_keystone_data()
|
||||
return self._user_domain_id
|
||||
|
||||
@user_domain.setter
|
||||
def user_domain(self, user_domain):
|
||||
self._user_domain_id = user_domain
|
||||
@user_domain_id.setter
|
||||
def user_domain_id(self, user_domain_id):
|
||||
self._user_domain_id = user_domain_id
|
||||
|
||||
@property
|
||||
def project_domain(self):
|
||||
def project_domain_id(self):
|
||||
if not getattr(self, '_keystone_loaded', False):
|
||||
self._load_keystone_data()
|
||||
return self._project_domain_id
|
||||
|
||||
@project_domain.setter
|
||||
def project_domain(self, project_domain):
|
||||
self._project_domain_id = project_domain
|
||||
@project_domain_id.setter
|
||||
def project_domain_id(self, project_domain_id):
|
||||
self._project_domain_id = project_domain_id
|
||||
|
||||
|
||||
def get_admin_context(show_deleted=False):
|
||||
@ -359,8 +353,8 @@ class ContextMiddleware(wsgi.Middleware):
|
||||
username = None
|
||||
password = None
|
||||
aws_creds = None
|
||||
user_domain = None
|
||||
project_domain = None
|
||||
user_domain_id = None
|
||||
project_domain_id = None
|
||||
|
||||
if headers.get('X-Auth-User') is not None:
|
||||
username = headers.get('X-Auth-User')
|
||||
@ -369,10 +363,10 @@ class ContextMiddleware(wsgi.Middleware):
|
||||
aws_creds = headers.get('X-Auth-EC2-Creds')
|
||||
|
||||
if headers.get('X-User-Domain-Id') is not None:
|
||||
user_domain = headers.get('X-User-Domain-Id')
|
||||
user_domain_id = headers.get('X-User-Domain-Id')
|
||||
|
||||
if headers.get('X-Project-Domain-Id') is not None:
|
||||
project_domain = headers.get('X-Project-Domain-Id')
|
||||
project_domain_id = headers.get('X-Project-Domain-Id')
|
||||
|
||||
project_name = headers.get('X-Project-Name')
|
||||
region_name = headers.get('X-Region-Name')
|
||||
@ -390,8 +384,8 @@ class ContextMiddleware(wsgi.Middleware):
|
||||
password=password,
|
||||
auth_url=auth_url,
|
||||
request_id=req_id,
|
||||
user_domain=user_domain,
|
||||
project_domain=project_domain,
|
||||
user_domain_id=user_domain_id,
|
||||
project_domain_id=project_domain_id,
|
||||
auth_token_info=token_info,
|
||||
region_name=region_name,
|
||||
auth_plugin=auth_plugin,
|
||||
|
@ -33,6 +33,7 @@ EXPECTED_ENV_RESPONSE = {
|
||||
'HTTP_X_PROJECT_ID': 'tenant_id1',
|
||||
'HTTP_X_PROJECT_NAME': 'tenant_name1',
|
||||
'HTTP_X_USER_ID': 'user_id1',
|
||||
'HTTP_X_USER_DOMAIN_ID': 'domain1',
|
||||
'HTTP_X_USER_NAME': 'user_name1',
|
||||
'HTTP_X_ROLES': 'role1,role2',
|
||||
'HTTP_X_AUTH_TOKEN': 'lalalalalala',
|
||||
|
@ -51,8 +51,8 @@ class TestRequestContext(common.HeatTestCase):
|
||||
'aws_creds': 'blah',
|
||||
'region_name': 'RegionOne',
|
||||
'user_identity': 'fooUser 456tenant',
|
||||
'user_domain': None,
|
||||
'project_domain': None}
|
||||
'user_domain_id': None,
|
||||
'project_domain_id': None}
|
||||
|
||||
super(TestRequestContext, self).setUp()
|
||||
|
||||
@ -73,8 +73,8 @@ class TestRequestContext(common.HeatTestCase):
|
||||
trustor_user_id=self.ctx.get('trustor_user_id'),
|
||||
trust_id=self.ctx.get('trust_id'),
|
||||
region_name=self.ctx.get('region_name'),
|
||||
user_domain_id=self.ctx.get('user_domain'),
|
||||
project_domain_id=self.ctx.get('project_domain'))
|
||||
user_domain_id=self.ctx.get('user_domain_id'),
|
||||
project_domain_id=self.ctx.get('project_domain_id'))
|
||||
ctx_dict = ctx.to_dict()
|
||||
del ctx_dict['request_id']
|
||||
del ctx_dict['project_id']
|
||||
@ -103,8 +103,8 @@ class TestRequestContext(common.HeatTestCase):
|
||||
'aws_creds': 'blah',
|
||||
'region_name': 'RegionOne',
|
||||
'user_identity': u'Gāo 456tenant',
|
||||
'user_domain': None,
|
||||
'project_domain': None}
|
||||
'user_domain_id': None,
|
||||
'project_domain_id': None}
|
||||
|
||||
ctx = context.RequestContext(
|
||||
auth_token=ctx_origin.get('auth_token'),
|
||||
@ -122,8 +122,8 @@ class TestRequestContext(common.HeatTestCase):
|
||||
trustor_user_id=ctx_origin.get('trustor_user_id'),
|
||||
trust_id=ctx_origin.get('trust_id'),
|
||||
region_name=ctx_origin.get('region_name'),
|
||||
user_domain_id=ctx_origin.get('user_domain'),
|
||||
project_domain_id=ctx_origin.get('project_domain'))
|
||||
user_domain_id=ctx_origin.get('user_domain_id'),
|
||||
project_domain_id=ctx_origin.get('project_domain_id'))
|
||||
ctx_dict = ctx.to_dict()
|
||||
del(ctx_dict['request_id'])
|
||||
self.assertEqual(ctx_origin, ctx_dict)
|
||||
|
Loading…
Reference in New Issue
Block a user