From 302d9dc2194c93a9a9571dfd20a80056c782cb29 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Thu, 19 Oct 2023 11:56:04 +0900 Subject: [PATCH] feat: modify get region code method Signed-off-by: ImMin5 --- src/cloudforet/cost_analysis/manager/cost_manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cloudforet/cost_analysis/manager/cost_manager.py b/src/cloudforet/cost_analysis/manager/cost_manager.py index 1972550..6bc83de 100644 --- a/src/cloudforet/cost_analysis/manager/cost_manager.py +++ b/src/cloudforet/cost_analysis/manager/cost_manager.py @@ -73,7 +73,7 @@ def _make_data_info(self, result, billed_date, options, tenant_id=None): usage_quantity = self._convert_str_to_float_format(result.get('quantity', 0)) usage_type = result.get('metername', '') usage_unit = result.get('unitofmeasure', '') - region_code = result.get('resourcelocation', '') + region_code = self._get_region_code(result.get('resourcelocation', '')) product = result.get('metercategory', '') tags = self._convert_tags_str_to_dict(result.get('tags', {})) @@ -153,6 +153,10 @@ def _get_additional_info(self, result, options, tenant_id=None): return additional_info + @staticmethod + def _get_region_code(resource_location): + return resource_location.lower() if resource_location else resource_location + @staticmethod def _make_parameters(start, end, options): parameters = { @@ -190,7 +194,7 @@ def _make_scope(secret_data, task_options, collect_scope, customer_tenant_id=Non return scope @staticmethod - def _convert_tags_str_to_dict(tags_str: str): + def _convert_tags_str_to_dict(tags_str): try: if tags_str is None: return {}