From 3d3ef73681d5a358298f9a6026711d49dcaee7e9 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Mon, 29 Jul 2024 13:32:21 +0200 Subject: [PATCH 1/3] Fix Azure resource group exports --- nise/report.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nise/report.py b/nise/report.py index c48f5ebd..5fb2eef1 100644 --- a/nise/report.py +++ b/nise/report.py @@ -768,6 +768,7 @@ def azure_create_report(options): # noqa: C901 storage_account_name = options.get("azure_account_name") azure_prefix_name = options.get("azure_prefix_name") azure_report_name = options.get("azure_report_name") + resource_group = options.get("resource_group", False) write_monthly = options.get("write_monthly", False) for month in months: data = [] @@ -794,6 +795,7 @@ def azure_create_report(options): # noqa: C901 if attributes.get("meter_cache"): meter_cache.update(attributes.get("meter_cache")) # needed so that meter_cache can be defined in yaml attributes["meter_cache"] = meter_cache + attributes["resource_group"] = resource_group gen = generator_cls(gen_start_date, gen_end_date, currency, account_info, attributes) azure_columns = gen.azure_columns data += gen.generate_data() From 1a533ab6a34d2b421844d235d5b7b1155d476002 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Mon, 29 Jul 2024 13:59:47 +0200 Subject: [PATCH 2/3] rename rg param --- nise/__main__.py | 2 +- nise/generators/azure/azure_generator.py | 2 +- nise/report.py | 4 ++-- tests/test_azure_generator.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nise/__main__.py b/nise/__main__.py index 45e13a10..8a949b1c 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -198,7 +198,7 @@ def add_azure_parser_args(parser): parser.add_argument( "-rg", "--resource-group", - dest="resource_group", + dest="resource_group_export", action="store_true", required=False, help="Generate resource group based azure report.", diff --git a/nise/generators/azure/azure_generator.py b/nise/generators/azure/azure_generator.py index da2e1567..9095b3cc 100644 --- a/nise/generators/azure/azure_generator.py +++ b/nise/generators/azure/azure_generator.py @@ -253,7 +253,7 @@ def __init__(self, start_date, end_date, currency, account_info, attributes=None for key, value in attributes.items(): attr_name = "_" + key setattr(self, attr_name, value) - if attributes.get("resource_group"): + if attributes.get("resource_group_export"): self.azure_columns = AZURE_COLUMNS_V2_RESOURCE_GROUP super().__init__(start_date, end_date) diff --git a/nise/report.py b/nise/report.py index 5fb2eef1..45447147 100644 --- a/nise/report.py +++ b/nise/report.py @@ -768,7 +768,7 @@ def azure_create_report(options): # noqa: C901 storage_account_name = options.get("azure_account_name") azure_prefix_name = options.get("azure_prefix_name") azure_report_name = options.get("azure_report_name") - resource_group = options.get("resource_group", False) + resource_group_export = options.get("resource_group_export", False) write_monthly = options.get("write_monthly", False) for month in months: data = [] @@ -795,7 +795,7 @@ def azure_create_report(options): # noqa: C901 if attributes.get("meter_cache"): meter_cache.update(attributes.get("meter_cache")) # needed so that meter_cache can be defined in yaml attributes["meter_cache"] = meter_cache - attributes["resource_group"] = resource_group + attributes["resource_group_export"] = resource_group_export gen = generator_cls(gen_start_date, gen_end_date, currency, account_info, attributes) azure_columns = gen.azure_columns data += gen.generate_data() diff --git a/tests/test_azure_generator.py b/tests/test_azure_generator.py index 4da2b9d5..c46fd139 100644 --- a/tests/test_azure_generator.py +++ b/tests/test_azure_generator.py @@ -58,7 +58,7 @@ def setUp(self): self.one_hour = timedelta(minutes=60) self.account_info = _generate_azure_account_info() self.payer_account = self.account_info.get("subscription_guid") - self.resource_group_attribute = {"resource_group": True} + self.resource_group_attribute = {"resource_group_export": True} self.currency = "USD" def test_set_hours_invalid_start(self): @@ -222,7 +222,7 @@ def setUp(self): "usage_quantity": self.usage_quantity, "resource_rate": self.resource_rate, "pre_tax_cost": self.pre_tax_cost, - "resource_group": True, + "resource_group_export": True, } self.two_hours_ago = (self.now - self.one_hour) - self.one_hour From c29739e5bc2d858a035b3414fa328da15174cf0b Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Mon, 29 Jul 2024 14:12:02 +0200 Subject: [PATCH 3/3] nise version --- nise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nise/__init__.py b/nise/__init__.py index 3b538243..75fba08a 100644 --- a/nise/__init__.py +++ b/nise/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.6.2" +__version__ = "4.6.3" VERSION = __version__.split(".")