From d3e26b50dadaf067d472d6a51800dc016b7cf562 Mon Sep 17 00:00:00 2001 From: zhangbailin Date: Mon, 14 Mar 2022 16:39:14 +0800 Subject: [PATCH] Using project* instead of tenant* Implements: blueprint remove-tenant Change-Id: If75f96f7daa6ec38596db302e05148109a256df8 --- cyborg/api/hooks.py | 4 ++-- cyborg/db/sqlalchemy/api.py | 2 +- cyborg/quota.py | 6 +++--- cyborg/tests/unit/api/base.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cyborg/api/hooks.py b/cyborg/api/hooks.py index 097e0d83..76857dd4 100644 --- a/cyborg/api/hooks.py +++ b/cyborg/api/hooks.py @@ -57,10 +57,10 @@ class ContextHook(hooks.PecanHook): The following HTTP request headers are used: X-User-Id or X-User: - Used for context.user. + Used for context.user_id. X-Tenant-Id or X-Tenant: - Used for context.tenant. + Used for context.project_id. X-Auth-Token: Used for context.auth_token. diff --git a/cyborg/db/sqlalchemy/api.py b/cyborg/db/sqlalchemy/api.py index b09c50cb..bae58b2d 100644 --- a/cyborg/db/sqlalchemy/api.py +++ b/cyborg/db/sqlalchemy/api.py @@ -76,7 +76,7 @@ def model_query(context, model, *args, **kwargs): """ if kwargs.pop("project_only", False): - kwargs["project_id"] = context.tenant + kwargs["project_id"] = context.project_id with _session_for_read() as session: query = sqlalchemyutils.model_query( diff --git a/cyborg/quota.py b/cyborg/quota.py index 68e15bd5..21c00950 100644 --- a/cyborg/quota.py +++ b/cyborg/quota.py @@ -97,7 +97,7 @@ class QuotaEngine(object): value will be treated as a number of seconds). :param project_id: Specify the project_id if current context is admin and admin wants to impact on - common user's tenant. + common user's project. """ if not project_id: project_id = context.project_id @@ -117,7 +117,7 @@ class QuotaEngine(object): returned by the reserve() method. :param project_id: Specify the project_id if current context is admin and admin wants to impact on - common user's tenant. + common user's project. """ project_id = context.project_id try: @@ -173,7 +173,7 @@ class DbQuotaDriver(object): returned by the reserve() method. :param project_id: Specify the project_id if current context is admin and admin wants to impact on - common user's tenant. + common user's project. """ try: diff --git a/cyborg/tests/unit/api/base.py b/cyborg/tests/unit/api/base.py index 0d09425f..df788bcc 100644 --- a/cyborg/tests/unit/api/base.py +++ b/cyborg/tests/unit/api/base.py @@ -136,10 +136,10 @@ class BaseApiTest(base.DbTestCase): headers = { 'X-User-Name': ct.get("user_name") or "user", 'X-User-Id': - ct.get("user") or "1d6d686bc2c949ddb685ffb4682e0047", + ct.get("user_id") or "1d6d686bc2c949ddb685ffb4682e0047", 'X-Project-Name': ct.get("project_name") or "no_project_name", 'X-Project-Id': - ct.get("tenant") or "86f64f561b6d4f479655384572727f70", + ct.get("project_id") or "86f64f561b6d4f479655384572727f70", 'X-User-Domain-Id': ct.get("domain_id") or "bd5eeb7d0fb046daaf694b36f4df5518", 'X-User-Domain-Name': ct.get("domain_name") or "no_domain",