@@ -260,7 +260,7 @@ def get_cost_data(self, params):
260
260
is_canceled = False
261
261
262
262
for costs_data in self .ds_plugin_mgr .get_cost_data (
263
- options , secret_data , schema , task_options , domain_id
263
+ options , secret_data , schema , task_options , domain_id
264
264
):
265
265
results = costs_data .get ("results" , [])
266
266
for cost_data in results :
@@ -370,7 +370,12 @@ def create_cost_job(self, data_source_vo: DataSource, job_options):
370
370
)
371
371
tasks .extend (single_tasks )
372
372
changed .extend (single_changed )
373
- synced_accounts .extend (single_synced_accounts )
373
+ synced_accounts .extend (
374
+ [
375
+ single_synced_account .get ("account_id" )
376
+ for single_synced_account in single_synced_accounts
377
+ ]
378
+ )
374
379
except Exception as e :
375
380
_LOGGER .error (f"[create_cost_job] get_tasks error: { e } " , exc_info = True )
376
381
@@ -436,11 +441,11 @@ def create_cost_job(self, data_source_vo: DataSource, job_options):
436
441
return job_vo
437
442
438
443
def _list_secret_ids_from_secret_type (
439
- self ,
440
- data_source_vo : DataSource ,
441
- secret_type : str ,
442
- workspace_id : str ,
443
- domain_id : str ,
444
+ self ,
445
+ data_source_vo : DataSource ,
446
+ secret_type : str ,
447
+ workspace_id : str ,
448
+ domain_id : str ,
444
449
):
445
450
secret_ids = []
446
451
@@ -461,7 +466,7 @@ def _list_secret_ids_from_secret_type(
461
466
return secret_ids
462
467
463
468
def _list_secret_ids_from_secret_filter (
464
- self , secret_filter , provider : str , workspace_id : str , domain_id : str
469
+ self , secret_filter , provider : str , workspace_id : str , domain_id : str
465
470
):
466
471
secret_manager : SecretManager = self .locator .get_manager (SecretManager )
467
472
@@ -476,7 +481,7 @@ def _list_secret_ids_from_secret_filter(
476
481
477
482
@staticmethod
478
483
def _set_secret_filter (
479
- secret_filter , provider : str , workspace_id : str , domain_id : str
484
+ secret_filter , provider : str , workspace_id : str , domain_id : str
480
485
):
481
486
_filter = [{"k" : "domain_id" , "v" : domain_id , "o" : "eq" }]
482
487
@@ -491,8 +496,8 @@ def _set_secret_filter(
491
496
{"k" : "secret_id" , "v" : secret_filter ["secrets" ], "o" : "in" }
492
497
)
493
498
if (
494
- "service_accounts" in secret_filter
495
- and secret_filter ["service_accounts" ]
499
+ "service_accounts" in secret_filter
500
+ and secret_filter ["service_accounts" ]
496
501
):
497
502
_filter .append (
498
503
{
@@ -588,10 +593,10 @@ def _create_cost_data(self, cost_data, job_task_vo, cost_options):
588
593
self .cost_mgr .create_cost (cost_data , execute_rollback = False )
589
594
590
595
def _is_job_failed (
591
- self ,
592
- job_id : str ,
593
- domain_id : str ,
594
- workspace_id : str ,
596
+ self ,
597
+ job_id : str ,
598
+ domain_id : str ,
599
+ workspace_id : str ,
595
600
):
596
601
job_vo : Job = self .job_mgr .get_job (job_id , domain_id , workspace_id )
597
602
@@ -601,14 +606,14 @@ def _is_job_failed(
601
606
return False
602
607
603
608
def _close_job (
604
- self ,
605
- job_id : str ,
606
- data_source_id : str ,
607
- domain_id : str ,
608
- data_keys : list ,
609
- additional_info_keys : list ,
610
- tag_keys : list ,
611
- workspace_id : str = None ,
609
+ self ,
610
+ job_id : str ,
611
+ data_source_id : str ,
612
+ domain_id : str ,
613
+ data_keys : list ,
614
+ additional_info_keys : list ,
615
+ tag_keys : list ,
616
+ workspace_id : str = None ,
612
617
) -> None :
613
618
job_vo : Job = self .job_mgr .get_job (job_id , domain_id , workspace_id )
614
619
no_preload_cache = job_vo .options .get ("no_preload_cache" , False )
@@ -762,7 +767,7 @@ def _delete_old_cost_data(self, data_source_id: str, domain_id: str):
762
767
monthly_cost_vos .delete ()
763
768
764
769
def _delete_changed_cost_data (
765
- self , job_vo : Job , start , end , change_filter , domain_id
770
+ self , job_vo : Job , start , end , change_filter , domain_id
766
771
):
767
772
query = {
768
773
"filter" : [
@@ -798,7 +803,7 @@ def _delete_changed_cost_data(
798
803
)
799
804
800
805
def _aggregate_cost_data (
801
- self , job_vo : Job , data_keys : list , additional_info_keys : list , tag_keys : list
806
+ self , job_vo : Job , data_keys : list , additional_info_keys : list , tag_keys : list
802
807
):
803
808
data_source_id = job_vo .data_source_id
804
809
domain_id = job_vo .domain_id
@@ -807,7 +812,7 @@ def _aggregate_cost_data(
807
812
808
813
for job_task_id in job_task_ids :
809
814
for billed_month in self ._distinct_billed_month (
810
- domain_id , data_source_id , job_id , job_task_id
815
+ domain_id , data_source_id , job_id , job_task_id
811
816
):
812
817
self ._aggregate_monthly_cost_data (
813
818
data_source_id ,
@@ -821,7 +826,7 @@ def _aggregate_cost_data(
821
826
)
822
827
823
828
def _distinct_billed_month (
824
- self , domain_id : str , data_source_id : str , job_id : str , job_task_id : str
829
+ self , domain_id : str , data_source_id : str , job_id : str , job_task_id : str
825
830
):
826
831
query = {
827
832
"distinct" : "billed_month" ,
@@ -842,15 +847,15 @@ def _distinct_billed_month(
842
847
return values
843
848
844
849
def _aggregate_monthly_cost_data (
845
- self ,
846
- data_source_id : str ,
847
- domain_id : str ,
848
- job_id : str ,
849
- job_task_id : str ,
850
- billed_month : str ,
851
- data_keys : list ,
852
- additional_info_keys : list ,
853
- tag_keys : list ,
850
+ self ,
851
+ data_source_id : str ,
852
+ domain_id : str ,
853
+ job_id : str ,
854
+ job_task_id : str ,
855
+ billed_month : str ,
856
+ data_keys : list ,
857
+ additional_info_keys : list ,
858
+ tag_keys : list ,
854
859
):
855
860
query = {
856
861
"group_by" : [
@@ -946,7 +951,7 @@ def _get_all_data_sources(self):
946
951
)
947
952
948
953
def _check_duplicate_job (
949
- self , data_source_id : str , domain_id : str , this_job_vo : Job
954
+ self , data_source_id : str , domain_id : str , this_job_vo : Job
950
955
):
951
956
query = {
952
957
"filter" : [
@@ -984,11 +989,11 @@ def _get_job_task_ids(self, job_id, domain_id):
984
989
return job_task_ids
985
990
986
991
def _get_data_source_account_map (
987
- self ,
988
- data_source_id : str ,
989
- domain_id : str ,
990
- workspace_id : str ,
991
- resource_group : str ,
992
+ self ,
993
+ data_source_id : str ,
994
+ domain_id : str ,
995
+ workspace_id : str ,
996
+ resource_group : str ,
992
997
) -> Dict [str , DataSourceAccount ]:
993
998
data_source_account_map = {}
994
999
conditions = {
@@ -1010,11 +1015,11 @@ def _get_data_source_account_map(
1010
1015
return data_source_account_map
1011
1016
1012
1017
def _get_linked_accounts_from_data_source_vo (
1013
- self ,
1014
- data_source_vo : DataSource ,
1015
- options : dict ,
1016
- secret_data : dict ,
1017
- schema : dict = None ,
1018
+ self ,
1019
+ data_source_vo : DataSource ,
1020
+ options : dict ,
1021
+ secret_data : dict ,
1022
+ schema : dict = None ,
1018
1023
) -> list :
1019
1024
linked_accounts = []
1020
1025
0 commit comments