diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-12-02 11:16:47 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-12-02 12:17:02 +0100 |
commit | 3d33f25b291d4a4d7ba44847da85ef9ad1f5b62f (patch) | |
tree | 8750cbf8be4c4829f3aa9d45429de58df84e8d5d /controller-api | |
parent | 015ef9e6753931c0edffe80721e6647119950e9b (diff) |
Add host switch updater
Diffstat (limited to 'controller-api')
4 files changed, 35 insertions, 3 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java index 7d85c11789b..04f1448bec1 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java @@ -61,6 +61,7 @@ public class Node { private final List<NodeHistory> history; private final Set<String> additionalIpAddresses; private final String openStackId; + private final Optional<String> switchHostname; public Node(HostName hostname, Optional<HostName> parentHostname, State state, NodeType type, NodeResources resources, Optional<ApplicationId> owner, Version currentVersion, Version wantedVersion, Version currentOsVersion, Version wantedOsVersion, @@ -69,7 +70,7 @@ public class Node { int cost, String flavor, String clusterId, ClusterType clusterType, boolean wantToRetire, boolean wantToDeprovision, Optional<TenantName> reservedTo, Optional<ApplicationId> exclusiveTo, DockerImage wantedDockerImage, DockerImage currentDockerImage, Map<String, JsonNode> reports, List<NodeHistory> history, - Set<String> additionalIpAddresses, String openStackId) { + Set<String> additionalIpAddresses, String openStackId, Optional<String> switchHostname) { this.hostname = hostname; this.parentHostname = parentHostname; this.state = state; @@ -102,6 +103,7 @@ public class Node { this.history = history; this.openStackId = openStackId; this.additionalIpAddresses = additionalIpAddresses; + this.switchHostname = switchHostname; } public HostName hostname() { @@ -226,6 +228,10 @@ public class Node { return openStackId; } + public Optional<String> switchHostname() { + return switchHostname; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -302,6 +308,7 @@ public class Node { private List<NodeHistory> history = new ArrayList<>(); private Set<String> additionalIpAddresses = new HashSet<>(); private String openStackId; + private Optional<String> switchHostname = Optional.empty(); public Builder() { } @@ -338,6 +345,7 @@ public class Node { this.history = node.history; this.additionalIpAddresses = node.additionalIpAddresses; this.openStackId = node.openStackId; + this.switchHostname = node.switchHostname; } public Builder hostname(HostName hostname) { @@ -495,12 +503,17 @@ public class Node { return this; } + public Builder switchHostname(String switchHostname) { + this.switchHostname = Optional.ofNullable(switchHostname); + return this; + } + public Node build() { return new Node(hostname, parentHostname, state, type, resources, owner, currentVersion, wantedVersion, currentOsVersion, wantedOsVersion, currentFirmwareCheck, wantedFirmwareCheck, serviceState, suspendedSince, restartGeneration, wantedRestartGeneration, rebootGeneration, wantedRebootGeneration, cost, flavor, clusterId, clusterType, wantToRetire, wantToDeprovision, reservedTo, exclusiveTo, - wantedDockerImage, currentDockerImage, reports, history, additionalIpAddresses, openStackId); + wantedDockerImage, currentDockerImage, reports, history, additionalIpAddresses, openStackId, switchHostname); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index af1b3fa53fc..7bbf0fb0578 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java @@ -137,7 +137,8 @@ public interface NodeRepository { node.getReports(), node.getHistory(), node.getAdditionalIpAddresses(), - node.getOpenStackId()); + node.getOpenStackId(), + Optional.ofNullable(node.getSwitchHostname())); } private static String clusterIdOf(NodeMembership nodeMembership) { diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java index b9adbf2c742..59a1f589eb0 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.entity; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -17,6 +18,9 @@ public interface EntityService { /** List all properties known by the service */ Map<PropertyId, Property> listProperties(); + /** List all nodes owned by this system's property */ + List<NodeEntity> listNodes(); + Optional<NodeEntity> findNode(String hostname); } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java index 7b8176c29de..0174f24c6d1 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java @@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -13,6 +15,8 @@ import java.util.Optional; */ public class MemoryEntityService implements EntityService { + private final Map<String, NodeEntity> nodeEntities = new HashMap<>(); + @Override public Map<PropertyId, Property> listProperties() { return ImmutableMap.of(new PropertyId("1234"), new Property("foo"), @@ -20,8 +24,18 @@ public class MemoryEntityService implements EntityService { } @Override + public List<NodeEntity> listNodes() { + return List.copyOf(nodeEntities.values()); + } + + @Override public Optional<NodeEntity> findNode(String hostname) { return Optional.empty(); } + public MemoryEntityService addNodeEntity(NodeEntity nodeEntity) { + nodeEntities.put(nodeEntity.hostname(), nodeEntity); + return this; + } + } |