remove tenant

Change-Id: I520d59b6639fc67a18b9ab9c8f00e8ffc4a4aa49
This commit is contained in:
songwenping 2022-11-06 11:02:15 +08:00
parent 83b1fb7d09
commit eab47a9e02
5 changed files with 24 additions and 24 deletions

View File

@ -73,14 +73,14 @@ class VenusKeystoneContext(base_wsgi.Middleware):
return webob.exc.HTTPUnauthorized()
# get the roles
roles = [r.strip() for r in req.headers.get('X_ROLE', '').split(',')]
if 'X_TENANT_ID' in req.headers:
if 'X_PROJECT_ID' in req.headers:
# This is the new header since Keystone went to ID/Name
project_id = req.headers['X_TENANT_ID']
project_id = req.headers['X_PROJECT_ID']
else:
# This is for legacy compatibility
project_id = req.headers['X_TENANT']
project_id = req.headers['X_PROJECT']
project_name = req.headers.get('X_TENANT_NAME')
project_name = req.headers.get('X_PROJECT_NAME')
req_id = req.environ.get(request_id.ENV_REQUEST_ID)

View File

@ -258,7 +258,7 @@ class URLMap(paste.urlmap.URLMap):
# 2) Accept header (eg application/json;q=0.8, application/xml;q=0.2)
# The API version is determined in one of three ways:
# 1) URL path prefix (eg /v1.1/tenant/servers/detail)
# 1) URL path prefix (eg /v1.1/project/servers/detail)
# 2) Content-Type header (eg application/json;version=1.1)
# 3) Accept header (eg application/json;q=0.8;version=1.1)

View File

@ -82,9 +82,9 @@ global_opts = [
help='Password associated with the OpenStack '
'privileged account.',
secret=True),
cfg.StrOpt('os_privileged_user_tenant',
cfg.StrOpt('os_privileged_user_project',
default=None,
help='Tenant name associated with the OpenStack '
help='Project name associated with the OpenStack '
'privileged account.'),
cfg.StrOpt('os_privileged_user_auth_url',
default=None,
@ -139,15 +139,15 @@ global_opts = [
cfg.BoolOpt('fatal_exception_format_errors',
default=False,
help='Make exception message format errors fatal.'),
cfg.StrOpt('venus_internal_tenant_project_id',
cfg.StrOpt('venus_internal_project_id',
default=None,
help='ID of the project which will be used as the Venus '
'internal tenant.'),
cfg.StrOpt('venus_internal_tenant_user_id',
'internal project.'),
cfg.StrOpt('venus_internal_user_id',
default=None,
help='ID of the user to be used'
' in venusmanager operations as the '
'Venus internal tenant.'),
'Venus internal project.'),
cfg.StrOpt('db_driver',
default='venus.db',
help='Driver to use for database access'),

View File

@ -49,7 +49,7 @@ class RequestContext(context.RequestContext):
super(RequestContext, self).__init__(auth_token=auth_token,
user=user_id,
tenant=project_id,
project_id=project_id,
domain=domain,
user_domain=user_domain,
project_domain=project_domain,
@ -134,18 +134,18 @@ class RequestContext(context.RequestContext):
return copy.deepcopy(self)
# NOTE(sirp): the openstack/common version of RequestContext uses
# tenant/user whereas the Venus version uses project_id/user_id.
# project_id/user whereas the Venus version uses project_id/user_id.
# NOTE(adrienverge): The Venus version of RequestContext now uses
# tenant/user internally, so it is compatible with context-aware code from
# openstack/common. We still need this shim for the rest of Venus's
# project_id/user internally, so it is compatible with context-aware code
# from openstack/common. We still need this shim for the rest of Venus's
# code.
@property
def project_id(self):
return self.tenant
return self.project_id
@project_id.setter
def project_id(self, value):
self.tenant = value
self.project_id = value
@property
def user_id(self):
@ -164,21 +164,21 @@ def get_admin_context(read_deleted="no"):
overwrite=False)
def get_internal_tenant_context():
"""Build and return the Venus internal tenant context object
def get_internal_project_context():
"""Build and return the Venus internal project context object
This request context will only work for internal Venus operations. It will
not be able to make requests to remote services. To do so it will need to
use the keystone client to get an auth_token.
"""
project_id = CONF.venus_internal_tenant_project_id
user_id = CONF.venus_internal_tenant_user_id
project_id = CONF.venus_internal_project_id
user_id = CONF.venus_internal_user_id
if project_id and user_id:
return RequestContext(user_id=user_id,
project_id=project_id,
is_admin=True)
else:
LOG.warning(_LW('Unable to get internal tenant context: Missing '
LOG.warning(_LW('Unable to get internal context: Missing '
'required config parameters.'))
return None

View File

@ -223,7 +223,7 @@ class SearchCore(object):
gen_params["user_id.keyword"] = user_id
if project_id:
gen_params["tenant_id.keyword"] = project_id
gen_params["project_id.keyword"] = project_id
must_params = self.generate_must(gen_params)
must_not_params = self.generate_must_not(gen_not_params)
@ -300,7 +300,7 @@ class SearchCore(object):
d["desc"] = _source.get("message", "")
d["program_name"] = _source.get("programname", "")
d["user_id"] = _source.get("user_id", "")
d["project_id"] = _source.get("tenant_id", "")
d["project_id"] = _source.get("project_id", "")
d["module_name"] = _source.get("Logger", "")
res_values.append(d)