diff --git a/bin/run_invoicing.sh b/bin/run_invoicing.sh index 62e0986..f017b53 100755 --- a/bin/run_invoicing.sh +++ b/bin/run_invoicing.sh @@ -7,6 +7,7 @@ python -m openstack_billing_db.main \ --download-sql-dump-from-s3 True \ --convert-sql-dump-file-to-sqlite True \ --rate-cpu-su 0.013 \ + --rate-gpu-a100sxm4-su 2.078 \ --rate-gpu-a100-su 1.803 \ --rate-gpu-v100-su 1.214 \ --rate-gpu-k80-su 0.463 \ diff --git a/src/openstack_billing_db/billing.py b/src/openstack_billing_db/billing.py index 25e7b56..7ac2534 100644 --- a/src/openstack_billing_db/billing.py +++ b/src/openstack_billing_db/billing.py @@ -15,6 +15,7 @@ class Rates(object): cpu: Decimal gpu_a100: Decimal + gpu_a100sxm4: Decimal gpu_v100: Decimal gpu_a2: Decimal gpu_k80: Decimal @@ -23,6 +24,7 @@ class Rates(object): cpu_su_name: str = "OpenStack CPU" gpu_a100_su_name: str = "OpenStack GPUA100" + gpu_a100sxm4_su_name: str = "OpenStack GPUA100SXM4" gpu_v100_su_name: str = "OpenStack GPUV100" gpu_a2_su_name: str = "OpenStack GPUA2" gpu_k80_su_name: str = "OpenStack GPUK80" @@ -43,6 +45,7 @@ class ProjectInvoice(object): rates: Rates cpu_su_hours: int = 0 + gpu_a100sxm4_su_hours: int = 0 gpu_a100_su_hours: int = 0 gpu_v100_su_hours: int = 0 gpu_k80_su_hours: int = 0 @@ -99,6 +102,8 @@ def collect_invoice_data_from_openstack(database, billing_start, billing_end, ra if i.service_unit_type == "CPU": invoice.cpu_su_hours += su_hours + elif i.service_unit_type == "GPU A100SXM4": + invoice.gpu_a100sxm4_su_hours += su_hours elif i.service_unit_type == "GPU A100": invoice.gpu_a100_su_hours += su_hours elif i.service_unit_type == "GPU V100": @@ -173,7 +178,9 @@ def write(invoices, output, invoice_month=None): ) for invoice in invoices: - for invoice_type in ['cpu', 'gpu_a100', 'gpu_v100', 'gpu_k80', 'gpu_a2']: + for invoice_type in [ + 'cpu', 'gpu_a100sxm4', 'gpu_a100', 'gpu_v100', 'gpu_k80', 'gpu_a2' + ]: # Each project gets two rows, one for CPU and one for GPU hours = invoice.__getattribute__(f"{invoice_type}_su_hours") rate = invoice.rates.__getattribute__(invoice_type) diff --git a/src/openstack_billing_db/main.py b/src/openstack_billing_db/main.py index cc35219..348ddd2 100644 --- a/src/openstack_billing_db/main.py +++ b/src/openstack_billing_db/main.py @@ -101,6 +101,12 @@ def main(): type=Decimal, help="Rate of CPU SU/hr" ) + parser.add_argument( + "--rate-gpu-a100sxm4-su", + default=0, + type=Decimal, + help="Rate of GPU A100SXM4 SU/hr" + ) parser.add_argument( "--rate-gpu-a100-su", default=0, @@ -175,6 +181,7 @@ def main(): rates = billing.Rates( cpu=args.rate_cpu_su, + gpu_a100sxm4=args.rate_gpu_a100sxm4_su, gpu_a100=args.rate_gpu_a100_su, gpu_v100=args.rate_gpu_v100_su, gpu_k80=args.rate_gpu_k80_su, diff --git a/src/openstack_billing_db/model.py b/src/openstack_billing_db/model.py index 316acff..283b415 100644 --- a/src/openstack_billing_db/model.py +++ b/src/openstack_billing_db/model.py @@ -39,7 +39,9 @@ def service_units(self): def service_unit_type(self): if "gpu" not in self.name: return "CPU" - elif "a100" in self.name: + elif "a100-sxm4" in self.name: + return "GPU A100SXM4" + elif "a100" in self.name and "sxm4" not in self.name: return "GPU A100" elif "v100" in self.name: return "GPU V100"