Skip to content

Commit 51ff0e9

Browse files
authored
Merge pull request #80 from ImMin5/feature-modify-cost-option
Modify result of get_tasks api job_task options
2 parents 4b1ebf9 + f83f0e2 commit 51ff0e9

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/cloudforet/cost_analysis/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __get_secret_data_with_tenant_id(secret_data: dict, tenant_id: str = None) -
187187
return secrets[0]
188188

189189
for _secret_data in secrets:
190-
if _secret_data["tenant_id"] == tenant_id:
190+
if _secret_data["billing_tenant_id"] == tenant_id:
191191
secret_data = _secret_data
192192

193193
return secret_data

src/cloudforet/cost_analysis/manager/job_manager.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_tasks(
6464
"account_agreement_type": billing_account_agreement_type,
6565
"collect_scope": "customer_tenant_id",
6666
"customer_tenants": divided_customer_tenant_info,
67-
"tenant_id": secret_data["tenant_id"],
67+
"billing_tenant_id": secret_data["tenant_id"],
6868
}
6969
}
7070
)
@@ -82,7 +82,7 @@ def get_tasks(
8282
"account_agreement_type": billing_account_agreement_type,
8383
"collect_scope": "customer_tenant_id",
8484
"customer_tenants": first_sync_tenants,
85-
"tenant_id": secret_data["tenant_id"],
85+
"billing_tenant_id": secret_data["tenant_id"],
8686
"is_sync": False,
8787
}
8888
}
@@ -98,20 +98,6 @@ def get_tasks(
9898
synced_accounts = self._extend_synced_accounts(
9999
synced_accounts, first_sync_tenants
100100
)
101-
# Benefit Job Task
102-
if options.get("cost_metric") == "AmortizedCost":
103-
tasks.append(
104-
{
105-
"task_options": {
106-
"start": start_month,
107-
"account_agreement_type": billing_account_agreement_type,
108-
"collect_scope": "billing_account_id",
109-
"tenant_id": secret_data["tenant_id"],
110-
"is_benefit_job": True,
111-
}
112-
}
113-
)
114-
115101
else:
116102
tasks = [
117103
{
@@ -125,6 +111,20 @@ def get_tasks(
125111
changed = [{"start": start_month}]
126112
synced_accounts = []
127113

114+
# Benefit Job Task
115+
if options.get("cost_metric") == "AmortizedCost":
116+
tasks.append(
117+
{
118+
"task_options": {
119+
"start": start_month,
120+
"account_agreement_type": billing_account_agreement_type,
121+
"collect_scope": "billing_account_id",
122+
"billing_tenant_id": secret_data["tenant_id"],
123+
"is_benefit_job": True,
124+
}
125+
}
126+
)
127+
128128
elif secret_type == "USE_SERVICE_ACCOUNT_SECRET":
129129
subscription_id = secret_data.get("subscription_id", "")
130130
tenant_id = secret_data.get("tenant_id")
@@ -134,7 +134,7 @@ def get_tasks(
134134
"collect_scope": "subscription_id",
135135
"start": start_month,
136136
"subscription_id": subscription_id,
137-
"tenant_id": tenant_id,
137+
"billing_tenant_id": tenant_id,
138138
}
139139
}
140140
]

0 commit comments

Comments
 (0)