Skip to content

Commit d08dbd9

Browse files
authored
Merge pull request #238 from QuanMPhm/237/ibm_in_invoice
237/ibm in invoice
2 parents 0ab7910 + a8ff059 commit d08dbd9

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,22 @@ def add_arguments(self, parser):
113113
help="CSV file to write invoices to.",
114114
)
115115
parser.add_argument(
116-
"--openstack-gb-rate",
116+
"--openstack-nese-gb-rate",
117117
type=Decimal,
118118
required=False,
119-
help="Rate for OpenStack Volume and Object GB/hour.",
119+
help="Rate for OpenStack NESE Volume and Object GB/hour.",
120120
)
121121
parser.add_argument(
122-
"--openshift-gb-rate",
122+
"--openshift-nese-gb-rate",
123123
type=Decimal,
124124
required=False,
125-
help="Rate for OpenShift GB/hour.",
125+
help="Rate for OpenShift NESE Storage GB/hour.",
126+
)
127+
parser.add_argument(
128+
"--openshift-ibm-gb-rate",
129+
type=Decimal,
130+
required=False,
131+
help="Rate for OpenShift IBM Storage Scale GB/hour.",
126132
)
127133
parser.add_argument(
128134
"--s3-endpoint-url",
@@ -248,23 +254,30 @@ def process_invoice_row(allocation, attrs, su_name, rate):
248254
resources__in=openshift_resources
249255
)
250256

251-
if options["openstack_gb_rate"]:
252-
openstack_storage_rate = options["openstack_gb_rate"]
257+
if options["openstack_nese_gb_rate"]:
258+
openstack_nese_storage_rate = options["openstack_nese_gb_rate"]
253259
else:
254-
openstack_storage_rate = get_rates().get_value_at(
260+
openstack_nese_storage_rate = get_rates().get_value_at(
255261
"NESE Storage GB Rate", options["invoice_month"], Decimal
256262
)
257263

258-
if options["openshift_gb_rate"]:
259-
openshift_storage_rate = options["openshift_gb_rate"]
264+
if options["openshift_nese_gb_rate"]:
265+
openshift_nese_storage_rate = options["openshift_nese_gb_rate"]
260266
else:
261-
openshift_storage_rate = get_rates().get_value_at(
267+
openshift_nese_storage_rate = get_rates().get_value_at(
262268
"NESE Storage GB Rate", options["invoice_month"], Decimal
263269
)
264270

271+
if options["openshift_ibm_gb_rate"]:
272+
openshift_ibm_storage_rate = options["openshift_ibm_gb_rate"]
273+
else:
274+
openshift_ibm_storage_rate = get_rates().get_value_at(
275+
"IBM Spectrum Scale Storage GB Rate", options["invoice_month"], Decimal
276+
)
277+
265278
logger.info(
266-
f"Using storage rate {openstack_storage_rate} (Openstack) and "
267-
f"{openshift_storage_rate} (Openshift) for {options['invoice_month']}"
279+
f"Using storage rate {openstack_nese_storage_rate} (Openstack NESE), {openshift_nese_storage_rate} (Openshift NESE), and "
280+
f"{openshift_ibm_storage_rate} (Openshift IBM Scale) for {options['invoice_month']}"
268281
)
269282

270283
logger.info(f"Writing to {options['output']}.")
@@ -286,7 +299,7 @@ def process_invoice_row(allocation, attrs, su_name, rate):
286299
allocation,
287300
[attributes.QUOTA_VOLUMES_GB, attributes.QUOTA_OBJECT_GB],
288301
"OpenStack Storage",
289-
openstack_storage_rate,
302+
openstack_nese_storage_rate,
290303
)
291304

292305
for allocation in openshift_allocations:
@@ -303,7 +316,14 @@ def process_invoice_row(allocation, attrs, su_name, rate):
303316
attributes.QUOTA_REQUESTS_NESE_STORAGE,
304317
],
305318
"OpenShift NESE Storage",
306-
openshift_storage_rate,
319+
openshift_nese_storage_rate,
320+
)
321+
322+
process_invoice_row(
323+
allocation,
324+
[attributes.QUOTA_REQUESTS_IBM_STORAGE],
325+
"OpenShift IBM Scale Storage",
326+
openshift_ibm_storage_rate,
307327
)
308328

309329
if options["upload_to_s3"]:

src/coldfront_plugin_cloud/tests/unit/test_calculate_quota_unit_hours.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ def test_new_allocation_quota(self):
5353
"2020-03-01",
5454
"--end",
5555
"2020-03-31",
56-
"--openstack-gb-rate",
56+
"--openstack-nese-gb-rate",
5757
"0.0000087890625",
58-
"--openshift-gb-rate",
58+
"--openshift-nese-gb-rate",
5959
"0.0000087890625",
60+
"--openshift-ibm-gb-rate",
61+
"0.00001",
6062
"--invoice-month",
6163
"2020-03",
6264
)
@@ -73,10 +75,12 @@ def test_new_allocation_quota(self):
7375
"2020-03-01",
7476
"--end",
7577
"2020-03-31",
76-
"--openstack-gb-rate",
78+
"--openstack-nese-gb-rate",
7779
"0.0000087890625",
78-
"--openshift-gb-rate",
80+
"--openshift-nese-gb-rate",
7981
"0.0000087890625",
82+
"--openshift-ibm-gb-rate",
83+
"0.00001",
8084
"--invoice-month",
8185
"2020-03",
8286
"--excluded-time-ranges",

0 commit comments

Comments
 (0)