Skip to content

Fix usage query error for ea agreement #88

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 26, 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 Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN pip install --upgrade pip && \

ARG CACHEBUST=1
RUN pip install --upgrade spaceone-api && \
pip install --upgrade --pre spaceone-cost-analysis==2.0.dev147
pip install --upgrade --pre spaceone-cost-analysis==2.0.dev150



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def query_usage_http(
else:
parameters["dataset"]["grouping"].extend(BENEFIT_GROUPING_MCA)

_LOGGER.debug(f"[query_usage] parameters: {parameters}")

while self.next_link:
url = self.next_link
headers = self._make_request_headers()
Expand Down
19 changes: 14 additions & 5 deletions src/cloudforet/cost_analysis/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import logging
from typing import Generator
from spaceone.cost_analysis.plugin.data_source.lib.server import DataSourcePluginServer

from .manager import CostManager, DataSourceManager, JobManager

app = DataSourcePluginServer()

_LOGGER = logging.getLogger("spaceone")


@app.route("DataSource.init")
def data_source_init(params: dict) -> dict:
Expand Down Expand Up @@ -159,14 +162,20 @@ def cost_get_data(params: dict) -> Generator[dict, None, None]:
secret_data, task_options.get("billing_tenant_id")
)

if options.get("cost_metric") == "AmortizedCost" and task_options.get(
"is_benefit_job", False
):
is_benefit_job = task_options.get("is_benefit_job", False)
cost_metric = options.get("cost_metric", "ActualCost")

if not is_benefit_job:
for cost_response in cost_mgr.get_data(**params):
yield {"results": cost_response}
elif cost_metric == "AmortizedCost" and is_benefit_job:
for cost_response in cost_mgr.get_benefit_data(**params):
yield {"results": cost_response}
else:
for cost_response in cost_mgr.get_data(**params):
yield {"results": cost_response}
_LOGGER.error(
f"[get_cost_data] Check options, options: {options} , task_options: {task_options}"
)
raise Exception("Invalid cost_metric or is_benefit_job")


def __remove_duplicate_list_of_dict(changed: list) -> list:
Expand Down
2 changes: 1 addition & 1 deletion src/cloudforet/cost_analysis/manager/cost_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_benefit_data(
domain_id: str,
):
self.azure_cm_connector.create_session(options, secret_data, schema)
account_agreement_type = task_options.get("agreement_type")
account_agreement_type = task_options.get("account_agreement_type")
start: datetime = self._get_first_date_of_month(task_options["start"])
end: datetime = datetime.utcnow()

Expand Down
Loading