summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-05-12 15:48:22 +0200
committerMartin Polden <mpolden@mpolden.no>2022-05-13 14:46:35 +0200
commit8327b0e89d21a7122019a3e342baa880f23a9898 (patch)
tree0758c28acec995475a406a1dba21e7affabd008f /config-provisioning
parentc8671df2c8ca29a037e148f758e6092be6a6128c (diff)
Use cloud account from model in host provisioning
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
index 958a37e1432..70e88418fb7 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
@@ -1,6 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
+import java.util.Objects;
+import java.util.Optional;
+
/**
* A capacity request.
*
@@ -11,14 +14,12 @@ public final class Capacity {
/** Resources should stay between these values, inclusive */
private final ClusterResources min, max;
-
private final boolean required;
-
private final boolean canFail;
-
private final NodeType type;
+ private final Optional<CloudAccount> cloudAccount;
- private Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type) {
+ private Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type, Optional<CloudAccount> cloudAccount) {
validate(min);
validate(max);
if (max.smallerThan(min))
@@ -29,6 +30,7 @@ public final class Capacity {
this.required = required;
this.canFail = canFail;
this.type = type;
+ this.cloudAccount = Objects.requireNonNull(cloudAccount);
}
private static void validate(ClusterResources resources) {
@@ -58,8 +60,13 @@ public final class Capacity {
*/
public NodeType type() { return type; }
+ /** Returns the cloud account where this capacity is requested */
+ public Optional<CloudAccount> cloudAccount() {
+ return cloudAccount;
+ }
+
public Capacity withLimits(ClusterResources min, ClusterResources max) {
- return new Capacity(min, max, required, canFail, type);
+ return new Capacity(min, max, required, canFail, type, cloudAccount);
}
@Override
@@ -82,8 +89,13 @@ public final class Capacity {
return from(resources, required, canFail, NodeType.tenant);
}
+ // TODO(mpolden): Remove when config models < 7.590 are gone
public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail) {
- return new Capacity(min, max, required, canFail, NodeType.tenant);
+ return from(min, max, required, canFail, Optional.empty());
+ }
+
+ public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) {
+ return new Capacity(min, max, required, canFail, NodeType.tenant, cloudAccount);
}
/** Creates this from a node type */
@@ -92,7 +104,7 @@ public final class Capacity {
}
private static Capacity from(ClusterResources resources, boolean required, boolean canFail, NodeType type) {
- return new Capacity(resources, resources, required, canFail, type);
+ return new Capacity(resources, resources, required, canFail, type, Optional.empty());
}
}