Skip to content

Commit 6f10036

Browse files
authored
Merge pull request #107 from ImMin5/master
Fix update cost manager to use generator for data retrieval
2 parents e73ed0c + 18cbfae commit 6f10036

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/cloudforet/cost_analysis/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,13 @@ def __get_secret_data(secret_data: dict, task_options: dict) -> dict:
201201
if len(secrets) == 1:
202202
return secrets[0]
203203

204-
tenant_id = task_options.get(
205-
"billing_tenant_id",
206-
)
204+
tenant_id = task_options["billing_tenant_id"]
207205

208206
for _secret_data in secrets:
209207
if _secret_data["tenant_id"] == tenant_id:
210-
secret_data = _secret_data
208+
return _secret_data
209+
211210
elif _secret_data.get("subscription_id") == task_options.get("subscription_id"):
212-
secret_data = _secret_data
211+
return _secret_data
213212

214213
return secret_data

src/cloudforet/cost_analysis/manager/cost_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_data(
7070
schema: str,
7171
task_options: dict,
7272
domain_id: str,
73-
) -> list:
73+
) -> Generator[list, Any, None]:
7474
self.azure_cm_connector.create_session(options, secret_data, schema)
7575
self._check_task_options(task_options)
7676

@@ -132,7 +132,6 @@ def get_data(
132132
_LOGGER.info(
133133
f"[get_data] all collect is done in {int(end_time - start_time)} seconds"
134134
)
135-
yield []
136135

137136
def _make_cost_data(
138137
self,

0 commit comments

Comments
 (0)