Skip to content

Modify result of get_tasks api job_task options #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cloudforet/cost_analysis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __get_secret_data_with_tenant_id(secret_data: dict, tenant_id: str = None) -
return secrets[0]

for _secret_data in secrets:
if _secret_data["tenant_id"] == tenant_id:
if _secret_data["billing_tenant_id"] == tenant_id:
secret_data = _secret_data

return secret_data
34 changes: 17 additions & 17 deletions src/cloudforet/cost_analysis/manager/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_tasks(
"account_agreement_type": billing_account_agreement_type,
"collect_scope": "customer_tenant_id",
"customer_tenants": divided_customer_tenant_info,
"tenant_id": secret_data["tenant_id"],
"billing_tenant_id": secret_data["tenant_id"],
}
}
)
Expand All @@ -82,7 +82,7 @@ def get_tasks(
"account_agreement_type": billing_account_agreement_type,
"collect_scope": "customer_tenant_id",
"customer_tenants": first_sync_tenants,
"tenant_id": secret_data["tenant_id"],
"billing_tenant_id": secret_data["tenant_id"],
"is_sync": False,
}
}
Expand All @@ -98,20 +98,6 @@ def get_tasks(
synced_accounts = self._extend_synced_accounts(
synced_accounts, first_sync_tenants
)
# Benefit Job Task
if options.get("cost_metric") == "AmortizedCost":
tasks.append(
{
"task_options": {
"start": start_month,
"account_agreement_type": billing_account_agreement_type,
"collect_scope": "billing_account_id",
"tenant_id": secret_data["tenant_id"],
"is_benefit_job": True,
}
}
)

else:
tasks = [
{
Expand All @@ -125,6 +111,20 @@ def get_tasks(
changed = [{"start": start_month}]
synced_accounts = []

# Benefit Job Task
if options.get("cost_metric") == "AmortizedCost":
tasks.append(
{
"task_options": {
"start": start_month,
"account_agreement_type": billing_account_agreement_type,
"collect_scope": "billing_account_id",
"billing_tenant_id": secret_data["tenant_id"],
"is_benefit_job": True,
}
}
)

elif secret_type == "USE_SERVICE_ACCOUNT_SECRET":
subscription_id = secret_data.get("subscription_id", "")
tenant_id = secret_data.get("tenant_id")
Expand All @@ -134,7 +134,7 @@ def get_tasks(
"collect_scope": "subscription_id",
"start": start_month,
"subscription_id": subscription_id,
"tenant_id": tenant_id,
"billing_tenant_id": tenant_id,
}
}
]
Expand Down
Loading