Skip to content

Commit

Permalink
Fix Azure resource-group param (#520)
Browse files Browse the repository at this point in the history
* Fix Azure resource group exports

* rename rg param

* nise version
  • Loading branch information
esebesto authored Jul 29, 2024
1 parent e7295d0 commit b0f4815
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "4.6.2"
__version__ = "4.6.3"

VERSION = __version__.split(".")
2 changes: 1 addition & 1 deletion nise/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion nise/generators/azure/azure_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions nise/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_export = options.get("resource_group_export", False)
write_monthly = options.get("write_monthly", False)
for month in months:
data = []
Expand All @@ -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_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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_azure_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b0f4815

Please sign in to comment.