Skip to content

Commit 53ed105

Browse files
refactor: remove debug print statements and update token handling in cost report management
1 parent 3e088f5 commit 53ed105

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

src/spaceone/cost_analysis/interface/task/v1/cost_report_run_scheduler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from datetime import datetime, timezone
33

4-
from spaceone.core.auth.jwt.jwt_util import JWTUtil
54
from spaceone.core.error import ERROR_CONFIGURATION
65
from spaceone.core import config
76
from spaceone.core import utils
@@ -47,8 +46,6 @@ def _create_cost_report_run_task(self):
4746
}
4847
],
4948
}
50-
print("scheduler token exists:", self._token is not None)
51-
print("scheduler token type:", JWTUtil.get_value_from_token(self._token, "typ"))
5249
print(
5350
f"{utils.datetime_to_iso8601(datetime.now(timezone.utc))} [INFO] [create_task] create_cost_report_by_cost_report_config => START"
5451
)

src/spaceone/cost_analysis/manager/cost_report_manager.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import logging
2-
from multiprocessing.pool import worker
32
from typing import Tuple
43
from mongoengine import QuerySet
54

6-
from spaceone.core.auth.jwt.jwt_util import JWTUtil
75
from spaceone.core import queue, utils
86
from spaceone.core.manager import BaseManager
97
from spaceone.cost_analysis.model.cost_report.database import CostReport
@@ -82,8 +80,6 @@ def stat_cost_reports(self, query: dict) -> dict:
8280

8381
def push_creating_cost_report_job(self, params: dict) -> None:
8482
token = self.transaction.meta.get("token")
85-
print("worker token exists :", token is not None)
86-
print("worker token type :", JWTUtil.get_value_from_token(token, "typ"))
8783
task = {
8884
"name": "create_cost_report_job",
8985
"version": "v1",

src/spaceone/cost_analysis/manager/identity_manager.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import logging
2-
from time import sleep
3-
from typing import Union
42

53
from spaceone.core import cache
64
from spaceone.core import config
@@ -114,19 +112,17 @@ def get_workspace(self, workspace_id: str, domain_id: str) -> str:
114112
return workspace_id
115113

116114
def list_workspaces(self, params: dict, domain_id: str, token: str = None) -> dict:
117-
print("request token type:", self.token_type)
118115
if self.token_type == "SYSTEM_TOKEN" or token:
119116
return self.identity_conn.dispatch(
120117
"Workspace.list", params, x_domain_id=domain_id, token=token
121118
)
122119
else:
123-
print("else in")
124120
return self.identity_conn.dispatch("Workspace.list", params)
125121

126-
def list_workspace_users(self, params: dict, domain_id: str) -> dict:
127-
if self.token_type == "SYSTEM_TOKEN":
122+
def list_workspace_users(self, params: dict, domain_id: str, token: str = None) -> dict:
123+
if self.token_type == "SYSTEM_TOKEN" or token:
128124
return self.identity_conn.dispatch(
129-
"WorkspaceUser.list", params, x_domain_id=domain_id
125+
"WorkspaceUser.list", params, x_domain_id=domain_id, token=token
130126
)
131127
else:
132128
return self.identity_conn.dispatch("WorkspaceUser.list", params)

src/spaceone/cost_analysis/service/cost_report_serivce.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def get_email_verified_workspace_owner_users(
440440
return []
441441

442442
# list users in workspace
443+
system_token = config.get_global("TOKEN")
443444
users_info = self.identity_mgr.list_workspace_users(
444445
params={
445446
"workspace_id": workspace_id,
@@ -452,6 +453,7 @@ def get_email_verified_workspace_owner_users(
452453
},
453454
},
454455
domain_id=domain_id,
456+
token=system_token,
455457
).get("results", [])
456458

457459
return users_info
@@ -469,9 +471,11 @@ def get_start_cost_report_number(
469471
def _get_workspace_name_map(self, domain_id: str) -> list:
470472
workspace_ids = []
471473

474+
system_token = config.get_global("TOKEN")
472475
workspaces = self.identity_mgr.list_workspaces(
473476
{"query": {"filter": [{"k": "state", "v": "ENABLED", "o": "eq"}]}},
474477
domain_id,
478+
token=system_token,
475479
)
476480

477481
for workspace in workspaces.get("results", []):

0 commit comments

Comments
 (0)