Skip to content

Commit

Permalink
fix: fix plugin data access error (cloudforet-io#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Apr 24, 2024
1 parent bdd3101 commit f0f708e
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions src/spaceone/cost_analysis/service/job_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def get_cost_data(self, params):
is_canceled = False

for costs_data in self.ds_plugin_mgr.get_cost_data(
options, secret_data, schema, task_options, domain_id
options, secret_data, schema, task_options, domain_id
):
results = costs_data.get("results", [])
for cost_data in results:
Expand Down Expand Up @@ -434,11 +434,11 @@ def create_cost_job(self, data_source_vo: DataSource, job_options):
return job_vo

def _list_secret_ids_from_secret_type(
self,
data_source_vo: DataSource,
secret_type: str,
workspace_id: str,
domain_id: str,
self,
data_source_vo: DataSource,
secret_type: str,
workspace_id: str,
domain_id: str,
):
secret_ids = []

Expand All @@ -459,7 +459,7 @@ def _list_secret_ids_from_secret_type(
return secret_ids

def _list_secret_ids_from_secret_filter(
self, secret_filter, provider: str, workspace_id: str, domain_id: str
self, secret_filter, provider: str, workspace_id: str, domain_id: str
):
secret_manager: SecretManager = self.locator.get_manager(SecretManager)

Expand All @@ -474,7 +474,7 @@ def _list_secret_ids_from_secret_filter(

@staticmethod
def _set_secret_filter(
secret_filter, provider: str, workspace_id: str, domain_id: str
secret_filter, provider: str, workspace_id: str, domain_id: str
):
_filter = [{"k": "domain_id", "v": domain_id, "o": "eq"}]

Expand All @@ -489,8 +489,8 @@ def _set_secret_filter(
{"k": "secret_id", "v": secret_filter["secrets"], "o": "in"}
)
if (
"service_accounts" in secret_filter
and secret_filter["service_accounts"]
"service_accounts" in secret_filter
and secret_filter["service_accounts"]
):
_filter.append(
{
Expand Down Expand Up @@ -586,10 +586,10 @@ def _create_cost_data(self, cost_data, job_task_vo, cost_options):
self.cost_mgr.create_cost(cost_data, execute_rollback=False)

def _is_job_failed(
self,
job_id: str,
domain_id: str,
workspace_id: str,
self,
job_id: str,
domain_id: str,
workspace_id: str,
):
job_vo: Job = self.job_mgr.get_job(job_id, domain_id, workspace_id)

Expand All @@ -599,12 +599,12 @@ def _is_job_failed(
return False

def _close_job(
self,
job_id: str,
data_source_id: str,
domain_id: str,
data_keys: list,
workspace_id: str = None,
self,
job_id: str,
data_source_id: str,
domain_id: str,
data_keys: list,
workspace_id: str = None,
) -> None:
job_vo: Job = self.job_mgr.get_job(job_id, domain_id, workspace_id)
no_preload_cache = job_vo.options.get("no_preload_cache", False)
Expand Down Expand Up @@ -754,7 +754,7 @@ def _delete_old_cost_data(self, data_source_id, domain_id):
monthly_cost_vos.delete()

def _delete_changed_cost_data(
self, job_vo: Job, start, end, change_filter, domain_id
self, job_vo: Job, start, end, change_filter, domain_id
):
query = {
"filter": [
Expand Down Expand Up @@ -800,7 +800,7 @@ def _aggregate_cost_data(self, job_vo: Job, data_keys: list):

for job_task_id in job_task_ids:
for billed_month in self._distinct_billed_month(
data_source_id, domain_id, job_id, job_task_id
data_source_id, domain_id, job_id, job_task_id
):
self._aggregate_monthly_cost_data(
data_source_id,
Expand Down Expand Up @@ -832,14 +832,14 @@ def _distinct_billed_month(self, data_source_id, domain_id, job_id, job_task_id)
return values

def _aggregate_monthly_cost_data(
self,
data_source_id: str,
domain_id: str,
job_id: str,
job_task_id: str,
billed_month: str,
data_keys: list,
workspace_id: str = None,
self,
data_source_id: str,
domain_id: str,
job_id: str,
job_task_id: str,
billed_month: str,
data_keys: list,
workspace_id: str = None,
):
query = {
"group_by": [
Expand Down Expand Up @@ -906,7 +906,7 @@ def _get_all_data_sources(self):
)

def _check_duplicate_job(
self, data_source_id: str, domain_id: str, this_job_vo: Job
self, data_source_id: str, domain_id: str, this_job_vo: Job
):
query = {
"filter": [
Expand Down Expand Up @@ -952,11 +952,11 @@ def _get_job_task_ids(self, job_id, domain_id):
return job_task_ids

def _get_data_source_account_map(
self,
data_source_id: str,
domain_id: str,
workspace_id: str,
resource_group: str,
self,
data_source_id: str,
domain_id: str,
workspace_id: str,
resource_group: str,
) -> Dict[str, DataSourceAccount]:
data_source_account_map = {}
conditions = {
Expand All @@ -978,11 +978,11 @@ def _get_data_source_account_map(
return data_source_account_map

def _get_linked_accounts_from_data_source_vo(
self,
data_source_vo: DataSource,
options: dict,
secret_data: dict,
schema: dict = None,
self,
data_source_vo: DataSource,
options: dict,
secret_data: dict,
schema: dict = None,
) -> list:
linked_accounts = []

Expand Down Expand Up @@ -1046,7 +1046,7 @@ def _update_data_source_is_synced(self, job_vo: Job) -> None:

@staticmethod
def _check_use_account_routing(data_source_vo: DataSource) -> bool:
plugin_info = data_source_vo.plugin_info or {}
plugin_info = data_source_vo.plugin_info.to_dict() or {}
metadata = plugin_info.get("metadata", {})

if metadata.get("use_account_routing", False):
Expand Down

0 comments on commit f0f708e

Please sign in to comment.