Skip to content

Commit 661ae8e

Browse files
committed
Added Cluster Name column to storage invoice
The `Cluster Name` column will contain the allocation's resource name.
1 parent cc6b1fa commit 661ae8e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class InvoiceRow:
4141
Project_Name: str = ""
4242
Project_ID: str = ""
4343
PI: str = ""
44+
Cluster_Name: str = ""
4445
Invoice_Email: str = ""
4546
Invoice_Address: str = ""
4647
Institution: str = ""
@@ -190,7 +191,7 @@ def upload_to_s3(s3_endpoint, s3_bucket, file_location, invoice_month):
190191
logger.info(f"Uploaded to {secondary_location}.")
191192

192193
def handle(self, *args, **options):
193-
def process_invoice_row(allocation, attrs, su_name, rate):
194+
def process_invoice_row(allocation, attrs, su_name, rate, cluster_name):
194195
"""Calculate the value and write the bill using the writer."""
195196
time = 0
196197
for attribute in attrs:
@@ -211,6 +212,7 @@ def process_invoice_row(allocation, attrs, su_name, rate):
211212
attributes.ALLOCATION_PROJECT_ID
212213
),
213214
PI=allocation.project.pi.email,
215+
Cluster_Name=cluster_name,
214216
Institution_Specific_Code=allocation.get_attribute(
215217
attributes.ALLOCATION_INSTITUTION_SPECIFIC_CODE
216218
)
@@ -273,6 +275,7 @@ def process_invoice_row(allocation, attrs, su_name, rate):
273275
csv_invoice_writer.writerow(InvoiceRow.get_headers())
274276

275277
for allocation in openstack_allocations:
278+
resource_name = allocation.resources.first().resource_type.name.lower()
276279
allocation_str = (
277280
f'{allocation.pk} of project "{allocation.project.title}"'
278281
)
@@ -284,9 +287,11 @@ def process_invoice_row(allocation, attrs, su_name, rate):
284287
[attributes.QUOTA_VOLUMES_GB, attributes.QUOTA_OBJECT_GB],
285288
"OpenStack Storage",
286289
openstack_storage_rate,
290+
resource_name,
287291
)
288292

289293
for allocation in openshift_allocations:
294+
resource_name = allocation.resources.first().resource_type.name.lower()
290295
allocation_str = (
291296
f'{allocation.pk} of project "{allocation.project.title}"'
292297
)
@@ -301,6 +306,7 @@ def process_invoice_row(allocation, attrs, su_name, rate):
301306
],
302307
"OpenShift Storage",
303308
openshift_storage_rate,
309+
resource_name,
304310
)
305311

306312
if options["upload_to_s3"]:

0 commit comments

Comments
 (0)