summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Bill.java18
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java7
2 files changed, 23 insertions, 2 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Bill.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Bill.java
index 854413a4adb..9c29f5c30f4 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Bill.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Bill.java
@@ -116,6 +116,10 @@ public class Bill {
return sumResourceValues(LineItem::getDiskCost);
}
+ public BigDecimal sumGpuCost() {
+ return sumResourceValues(LineItem::getGpuCost);
+ }
+
public BigDecimal sumAdditionalCost() {
// anything that is not covered by the cost for resources is "additional" costs
var resourceCosts = sumCpuCost().add(sumMemoryCost()).add(sumDiskCost());
@@ -185,9 +189,11 @@ public class Bill {
private BigDecimal cpuHours;
private BigDecimal memoryHours;
private BigDecimal diskHours;
+ private BigDecimal gpuHours;
private BigDecimal cpuCost;
private BigDecimal memoryCost;
private BigDecimal diskCost;
+ private BigDecimal gpuCost;
private NodeResources.Architecture architecture;
private int majorVersion;
@@ -201,7 +207,7 @@ public class Bill {
}
public LineItem(String id, String description, BigDecimal amount, String plan, String agent, ZonedDateTime addedAt, ZonedDateTime startedAt, ZonedDateTime endedAt, ApplicationId applicationId, ZoneId zoneId,
- BigDecimal cpuHours, BigDecimal memoryHours, BigDecimal diskHours, BigDecimal cpuCost, BigDecimal memoryCost, BigDecimal diskCost, NodeResources.Architecture architecture, int majorVersion) {
+ BigDecimal cpuHours, BigDecimal memoryHours, BigDecimal diskHours, BigDecimal gpuHours, BigDecimal cpuCost, BigDecimal memoryCost, BigDecimal diskCost, BigDecimal gpuCost, NodeResources.Architecture architecture, int majorVersion) {
this(id, description, amount, plan, agent, addedAt);
this.startedAt = startedAt;
this.endedAt = endedAt;
@@ -214,11 +220,13 @@ public class Bill {
this.cpuHours = cpuHours;
this.memoryHours = memoryHours;
this.diskHours = diskHours;
+ this.gpuHours = gpuHours;
this.cpuCost = cpuCost;
this.memoryCost = memoryCost;
this.diskCost = diskCost;
this.architecture = architecture;
this.majorVersion = majorVersion;
+ this.gpuCost = gpuCost;
}
/** The opaque ID of this */
@@ -283,6 +291,10 @@ public class Bill {
return Optional.ofNullable(diskHours);
}
+ public Optional<BigDecimal> getGpuHours() {
+ return Optional.ofNullable(gpuHours);
+ }
+
public Optional<BigDecimal> getCpuCost() {
return Optional.ofNullable(cpuCost);
}
@@ -295,6 +307,10 @@ public class Bill {
return Optional.ofNullable(diskCost);
}
+ public Optional<BigDecimal> getGpuCost() {
+ return Optional.ofNullable(gpuCost);
+ }
+
public Optional<NodeResources.Architecture> getArchitecture() {
return Optional.ofNullable(architecture);
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java
index bc7dd4199c7..d29603c529c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java
@@ -433,6 +433,9 @@ public class BillingApiHandler extends ThreadedHttpRequestHandler {
lineItem.getDiskHours().ifPresent(diskHours ->
cursor.setString("diskHours", diskHours.toString())
);
+ lineItem.getGpuHours().ifPresent(gpuHours ->
+ cursor.setString("gpuHours", gpuHours.toString())
+ );
lineItem.getCpuCost().ifPresent(cpuCost ->
cursor.setString("cpuCost", cpuCost.toString())
);
@@ -442,7 +445,9 @@ public class BillingApiHandler extends ThreadedHttpRequestHandler {
lineItem.getDiskCost().ifPresent(diskCost ->
cursor.setString("diskCost", diskCost.toString())
);
-
+ lineItem.getGpuCost().ifPresent(gpuCost ->
+ cursor.setString("gpuCost", gpuCost.toString())
+ );
}
private HttpResponse deleteInstrument(String tenant, String userId, String instrument) {