diff options
Diffstat (limited to 'controller-api/src/main/java/com')
18 files changed, 757 insertions, 56 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athenz/AthenzIdentityVerifier.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athenz/AthenzIdentityVerifier.java index 764ba9c2104..6f8ebc4c5db 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athenz/AthenzIdentityVerifier.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athenz/AthenzIdentityVerifier.java @@ -29,12 +29,16 @@ public class AthenzIdentityVerifier implements HostnameVerifier { public boolean verify(String hostname, SSLSession session) { try { X509Certificate cert = (X509Certificate) session.getPeerCertificates()[0]; - return allowedIdentities.contains(AthenzUtils.createAthenzIdentity(cert)); + return isTrusted(AthenzUtils.createAthenzIdentity(cert)); } catch (SSLPeerUnverifiedException e) { log.log(Level.WARNING, "Unverified client: " + hostname); return false; } } + public boolean isTrusted(AthenzIdentity identity) { + return allowedIdentities.contains(identity); + } + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java index 8c8b5fdf22e..086696fc6a4 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java @@ -67,12 +67,4 @@ public interface ConfigServerClient { */ EndpointStatus getGlobalRotationStatus(DeploymentId deployment, String endpoint) throws IOException; - /** - * The nodes allocated to the deployment - * - * @param deployment The application/zone pair - * @return The nodes for this deployment - * @throws IOException If unable to retrieve the node list - */ - NodeList getNodeList(DeploymentId deployment) throws IOException; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java deleted file mode 100644 index 0169bfec5fe..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.configserver;// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * @author smorgrav - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class NodeList { - - @JsonProperty("nodes") - public List<Node> nodes; - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Node { - @JsonProperty("hostname") - public String hostname; - @JsonProperty("flavor") - public String flavor; - @JsonProperty("membership") - public Membership membership; - @JsonProperty("cost") - public int cost; - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Membership { - @JsonProperty("clustertype") - public String clusterType; - @JsonProperty("clusterid") - public String clusterId; - } - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobList.java new file mode 100644 index 00000000000..db5037af4d2 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobList.java @@ -0,0 +1,17 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MaintenanceJobList { + @JsonProperty("jobs") + public List<MaintenanceJobName> jobs = new ArrayList<>(); + @JsonProperty("inactive") + public List<String> inactive = new ArrayList<>(); +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobName.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobName.java new file mode 100644 index 00000000000..ba54fed4cb1 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/MaintenanceJobName.java @@ -0,0 +1,11 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MaintenanceJobName { + @JsonProperty("name") + public String name; +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java new file mode 100644 index 00000000000..8510aacf3a8 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java @@ -0,0 +1,11 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +/** + * @author bjorncs + */ +public enum NodeEnvironment { + BARE_METAL, + VIRTUAL_MACHINE, + DOCKER_CONTAINER +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java new file mode 100644 index 00000000000..68696ac59df --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java @@ -0,0 +1,37 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Wire class for node-repository representation of the history of a node + * + * @author smorgrav + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NodeHistory { + @JsonProperty("at") + public Long at; + @JsonProperty("agent") + public Agent agent; + @JsonProperty("event") + public String event; + + public Long getAt() { + return at; + } + + public Agent getAgent() { + return agent; + } + + public String getEvent() { + return event; + } + + public enum Agent { system, application, operator, NodeRetirer } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeList.java new file mode 100644 index 00000000000..d707cdc5995 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeList.java @@ -0,0 +1,27 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * @author mortent + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeList { + @JsonProperty + List<NodeRepositoryNode> nodes; + + public NodeList() { + } + + public NodeList(List<NodeRepositoryNode> nodes) { + this.nodes = nodes; + } + + public List<NodeRepositoryNode> nodes() { + return nodes; + } +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeMembership.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeMembership.java new file mode 100644 index 00000000000..f567e27bdea --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeMembership.java @@ -0,0 +1,43 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author mpolden + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeMembership { + + @JsonProperty + public String clustertype; + @JsonProperty + public String clusterid; + @JsonProperty + public String group; + @JsonProperty + public Integer index; + @JsonProperty + public Boolean retired; + + public String getClustertype() { + return clustertype; + } + + public String getClusterid() { + return clusterid; + } + + public String getGroup() { + return group; + } + + public Integer getIndex() { + return index; + } + + public Boolean getRetired() { + return retired; + } +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeOwner.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeOwner.java new file mode 100644 index 00000000000..21c2c469077 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeOwner.java @@ -0,0 +1,33 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author mpolden + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeOwner { + + @JsonProperty + public String tenant; + @JsonProperty + public String application; + @JsonProperty + public String instance; + + public NodeOwner() {} + + public String getTenant() { + return tenant; + } + + public String getApplication() { + return application; + } + + public String getInstance() { + return instance; + } +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java new file mode 100644 index 00000000000..346c77bd316 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java @@ -0,0 +1,52 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; + +import java.io.IOException; +import java.util.Collection; + +/** + * @author smorgrav + * @author bjorncs + */ +public interface NodeRepositoryClientInterface { + + enum WantTo { + Retire, + Deprovision + } + + void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes) throws IOException; + + NodeRepositoryNode getNode(ZoneId zone, String hostname) throws IOException; + + void deleteNode(ZoneId zone, String hostname) throws IOException; + + NodeList listNodes(ZoneId zone, boolean recursive) throws IOException; + + NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) throws IOException; + + String resetFailureInformation(ZoneId zone, String nodename) throws IOException; + + String restart(ZoneId zone, String nodename) throws IOException; + + String reboot(ZoneId zone, String nodename) throws IOException; + + String cancelReboot(ZoneId zone, String nodename) throws IOException; + + String wantTo(ZoneId zone, String nodename, WantTo... actions) throws IOException; + + String cancelRestart(ZoneId zone, String nodename) throws IOException; + + String setHardwareFailureDescription(ZoneId zone, String nodename, String hardwareFailureDescription) throws IOException; + + void setState(ZoneId zone, NodeState nodeState, String nodename) throws IOException; + + String enableMaintenanceJob(ZoneId zone, String jobName) throws IOException; + + String disableMaintenanceJob(ZoneId zone, String jobName) throws IOException; + + MaintenanceJobList listMaintenanceJobs(ZoneId zone) throws IOException; + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java new file mode 100644 index 00000000000..7304daeee1d --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java @@ -0,0 +1,386 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Set; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NodeRepositoryNode { + + @JsonProperty("url") + private String url; + @JsonProperty("id") + private String id; + @JsonProperty("state") + private NodeState state; + @JsonProperty("hostname") + private String hostname; + @JsonProperty("ipAddresses") + private Set<String> ipAddresses; + @JsonProperty("additionalIpAddresses") + private Set<String> additionalIpAddresses; + @JsonProperty("openStackId") + private String openStackId; + @JsonProperty("flavor") + private String flavor; + @JsonProperty("canonicalFlavor") + private String canonicalFlavor; + @JsonProperty("membership") + private NodeMembership membership; + @JsonProperty("owner") + private NodeOwner owner; + @JsonProperty("restartGeneration") + private Integer restartGeneration; + @JsonProperty("rebootGeneration") + private Integer rebootGeneration; + @JsonProperty("currentRestartGeneration") + private Integer currentRestartGeneration; + @JsonProperty("currentRebootGeneration") + private Integer currentRebootGeneration; + @JsonProperty("vespaVersion") + private String vespaVersion; + @JsonProperty("wantedVespaVersion") + private String wantedVespaVersion; + @JsonProperty("failCount") + private Integer failCount; + @JsonProperty("hardwareFailure") + private Boolean hardwareFailure; + @JsonProperty("hardwareFailureDescription") + private String hardwareFailureDescription; + @JsonProperty("environment") + private NodeEnvironment environment; + @JsonProperty("type") + private NodeType type; + @JsonProperty("wantedDockerImage") + private String wantedDockerImage; + @JsonProperty("currentDockerImage") + private String currentDockerImage; + @JsonProperty("parentHostname") + private String parentHostname; + @JsonProperty("wantToRetire") + private Boolean wantToRetire; + @JsonProperty("wantToDeprovision") + private Boolean wantToDeprovision; + @JsonProperty("minDiskAvailableGb") + private Double minDiskAvailableGb; + @JsonProperty("minMainMemoryAvailableGb") + private Double minMainMemoryAvailableGb; + @JsonProperty("cost") + private Integer cost; + @JsonProperty("minCpuCores") + private Double minCpuCores; + @JsonProperty("description") + private String description; + @JsonProperty("history") + private NodeHistory[] history; + @JsonProperty("allowedToBeDown") + private Boolean allowedToBeDown; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public NodeState getState() { + return state; + } + + public void setState(NodeState state) { + this.state = state; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Set<String> getIpAddresses() { + return ipAddresses; + } + + public Set<String> getAdditionalIpAddresses() { + return additionalIpAddresses; + } + + public void setIpAddresses(Set<String> ipAddresses) { + this.ipAddresses = ipAddresses; + } + + public void setAdditionalIpAddresses(Set<String> additionalIpAddresses) { + this.additionalIpAddresses = additionalIpAddresses; + } + + public String getOpenStackId() { + return openStackId; + } + + public void setOpenStackId(String openStackId) { + this.openStackId = openStackId; + } + + public String getFlavor() { + return flavor; + } + + public void setFlavor(String flavor) { + this.flavor = flavor; + } + + public String getCanonicalFlavor() { + return canonicalFlavor; + } + + public void setCanonicalFlavor(String canonicalFlavor) { + this.canonicalFlavor = canonicalFlavor; + } + + public NodeMembership getMembership() { + return membership; + } + + public void setMembership(NodeMembership membership) { + this.membership = membership; + } + + public NodeOwner getOwner() { + return owner; + } + + public void setOwner(NodeOwner owner) { + this.owner = owner; + } + + public Integer getRestartGeneration() { + return restartGeneration; + } + + public void setRestartGeneration(Integer restartGeneration) { + this.restartGeneration = restartGeneration; + } + + public Integer getRebootGeneration() { + return rebootGeneration; + } + + public void setRebootGeneration(Integer rebootGeneration) { + this.rebootGeneration = rebootGeneration; + } + + public Integer getCurrentRestartGeneration() { + return currentRestartGeneration; + } + + public void setCurrentRestartGeneration(Integer currentRestartGeneration) { + this.currentRestartGeneration = currentRestartGeneration; + } + + public Integer getCurrentRebootGeneration() { + return currentRebootGeneration; + } + + public void setCurrentRebootGeneration(Integer currentRebootGeneration) { + this.currentRebootGeneration = currentRebootGeneration; + } + + public String getVespaVersion() { + return vespaVersion; + } + + public void setVespaVersion(String vespaVersion) { + this.vespaVersion = vespaVersion; + } + + public String getWantedVespaVersion() { + return wantedVespaVersion; + } + + public void setWantedVespaVersion(String wantedVespaVersion) { + this.wantedVespaVersion = wantedVespaVersion; + } + + public Integer getFailCount() { + return failCount; + } + + public void setFailCount(Integer failCount) { + this.failCount = failCount; + } + + public Boolean getHardwareFailure() { + return hardwareFailure; + } + + public void setHardwareFailure(Boolean hardwareFailure) { + this.hardwareFailure = hardwareFailure; + } + + public String getHardwareFailureDescription() { + return hardwareFailureDescription; + } + + public void setHardwareFailureDescription(String hardwareFailureDescription) { + this.hardwareFailureDescription = hardwareFailureDescription; + } + + public NodeEnvironment getEnvironment() { + return environment; + } + + public void setEnvironment(NodeEnvironment environment) { + this.environment = environment; + } + + public NodeType getType() { + return type; + } + + public void setType(NodeType type) { + this.type = type; + } + + public String getWantedDockerImage() { + return wantedDockerImage; + } + + public void setWantedDockerImage(String wantedDockerImage) { + this.wantedDockerImage = wantedDockerImage; + } + + public String getCurrentDockerImage() { + return currentDockerImage; + } + + public void setCurrentDockerImage(String currentDockerImage) { + this.currentDockerImage = currentDockerImage; + } + + public String getParentHostname() { + return parentHostname; + } + + public void setParentHostname(String parentHostname) { + this.parentHostname = parentHostname; + } + + public Boolean getWantToRetire() { + return wantToRetire; + } + + public Boolean getWantToDeprovision() { return wantToDeprovision; } + + public void setWantToRetire(Boolean wantToRetire) { + this.wantToRetire = wantToRetire; + } + + public void setWantToDeprovision(Boolean wantToDeprovision) { + this.wantToDeprovision = wantToDeprovision; + } + + public Double getMinDiskAvailableGb() { + return minDiskAvailableGb; + } + + public void setMinDiskAvailableGb(Double minDiskAvailableGb) { + this.minDiskAvailableGb = minDiskAvailableGb; + } + + public Double getMinMainMemoryAvailableGb() { + return minMainMemoryAvailableGb; + } + + public void setMinMainMemoryAvailableGb(Double minMainMemoryAvailableGb) { + this.minMainMemoryAvailableGb = minMainMemoryAvailableGb; + } + + public Integer getCost() { + return cost; + } + + public void setCost(Integer cost) { + this.cost = cost; + } + + public Double getMinCpuCores() { + return minCpuCores; + } + + public void setMinCpuCores(Double minCpuCores) { + this.minCpuCores = minCpuCores; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public NodeHistory[] getHistory() { + return history; + } + + public void setHistory(NodeHistory[] history) { + this.history = history; + } + + public Boolean getAllowedToBeDown() { + return allowedToBeDown; + } + + @Override + public String toString() { + return "NodeRepositoryNode{" + + "url='" + url + '\'' + + ", id='" + id + '\'' + + ", state=" + state + + ", hostname='" + hostname + '\'' + + ", ipAddresses='" + ipAddresses + '\'' + + ", additionalIpAddresses='" + additionalIpAddresses + '\'' + + ", openStackId='" + openStackId + '\'' + + ", flavor='" + flavor + '\'' + + ", canonicalFlavor='" + canonicalFlavor + '\'' + + ", membership=" + membership + + ", owner=" + owner + + ", restartGeneration=" + restartGeneration + + ", rebootGeneration=" + rebootGeneration + + ", currentRestartGeneration=" + currentRestartGeneration + + ", currentRebootGeneration=" + currentRebootGeneration + + ", vespaVersion='" + vespaVersion + '\'' + + ", wantedVespaVersion='" + wantedVespaVersion + '\'' + + ", failCount=" + failCount + + ", hardwareFailure=" + hardwareFailure + + ", hardwareFailureDescription='" + hardwareFailureDescription + '\'' + + ", environment=" + environment + + ", type=" + type + + ", wantedDockerImage='" + wantedDockerImage + '\'' + + ", currentDockerImage='" + currentDockerImage + '\'' + + ", wantToRetire='" + wantToRetire + '\'' + + ", wantToDeprovision='" + wantToDeprovision + '\'' + + ", minDiskAvailableGb='" + minDiskAvailableGb + '\'' + + ", minMainMemoryAvailableGb='" + minMainMemoryAvailableGb + '\'' + + ", cost='" + cost + '\'' + + ", minCpuCores='" + minCpuCores + '\'' + + ", description='" + description + '\'' + + ", allowedToBeDown='" + allowedToBeDown + '\'' + + '}'; + } +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeState.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeState.java new file mode 100644 index 00000000000..6271671ca2d --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeState.java @@ -0,0 +1,15 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +public enum NodeState { + + provisioned, + ready, + reserved, + active, + inactive, + dirty, + failed, + parked; + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeType.java new file mode 100644 index 00000000000..071cbe7100f --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeType.java @@ -0,0 +1,22 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +/** + * The possible types of nodes in the node repository + * + * @author bjorncs + */ +public enum NodeType { + + /** A host of a set of (docker) tenant nodes */ + host, + + /** Nodes running the shared proxy layer */ + proxy, + + /** A node to be assigned to a tenant to run application workloads */ + tenant, + + /** A config server */ + config +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ProvisionResource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ProvisionResource.java new file mode 100644 index 00000000000..ee808399637 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ProvisionResource.java @@ -0,0 +1,80 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import java.util.Collection; + +/** + * @author mortent + * @author mpolden + * @author smorgrav + */ +@Consumes(MediaType.APPLICATION_JSON) +public interface ProvisionResource { + + @POST + @Path("/node") + String addNodes(Collection<NodeRepositoryNode> node); + + @DELETE + @Path("/node/{hostname}") + String deleteNode(@PathParam("hostname") String hostname); + + @GET + @Path("/node/{hostname}") + NodeRepositoryNode getNode(@PathParam("hostname") String hostname); + + @POST + @Path("/node/{hostname}") + String patchNode(@PathParam("hostname") String hostname, + NodeRepositoryNode patchValues, + @HeaderParam("X-HTTP-Method-Override") String patchOverride); + + @GET + @Path("/node/") + NodeList listNodes(@QueryParam("recursive") boolean recursive); + + @GET + @Path("/node/") + NodeList listNodes(@QueryParam("application") String applicationString, + @QueryParam("recursive") boolean recursive); + + @GET + @Path("/node/") + NodeList listNodesWithParent(@QueryParam("recursive") boolean recursive, + @QueryParam("parentHost") String parentHostname); + + @PUT + @Path("/state/{state}/{hostname}") + String setState(@PathParam("state") NodeState state, @PathParam("hostname") String hostname); + + @POST + @Path("/command/reboot") + String reboot(@QueryParam("hostname") String hostname); + + @POST + @Path("/command/restart") + String restart(@QueryParam("hostname") String hostname); + + @GET + @Path("/maintenance/") + MaintenanceJobList listMaintenanceJobs(); + + @POST + @Path("/maintenance/inactive/{jobname}") + String disableMaintenanceJob(@PathParam("jobname") String jobname); + + @DELETE + @Path("/maintenance/inactive/{jobname}") + String enableMaintenanceJob(@PathParam("jobname") String jobname); +} + diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/package-info.java new file mode 100644 index 00000000000..08036880cd2 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/package-info.java @@ -0,0 +1,8 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +/** + * @author bjorncs + */ +@ExportPackage +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +import com.yahoo.osgi.annotation.ExportPackage;
\ No newline at end of file diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java index e68bf0ccc24..a7d51fa4d24 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java @@ -46,17 +46,17 @@ public class ZoneFilterMock implements ZoneList { } @Override - public ZoneList in(Environment environment) { - return filter(zoneId -> zoneId.environment() == environment); + public ZoneList in(Environment... environments) { + return filter(zoneId -> new HashSet<>(Arrays.asList(environments)).contains(zoneId.environment())); } @Override - public ZoneList in(RegionName region) { - return filter(zoneId -> zoneId.region().equals(region)); + public ZoneList in(RegionName... regions) { + return filter(zoneId -> new HashSet<>(Arrays.asList(regions)).contains(zoneId.region())); } @Override - public ZoneList zones(ZoneId... zones) { + public ZoneList among(ZoneId... zones) { return filter(zoneId -> new HashSet<>(Arrays.asList(zones)).contains(zoneId)); } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java index cd263769864..408168e41da 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java @@ -19,14 +19,14 @@ public interface ZoneList extends ZoneFilter { @Override ZoneList not(); - /** Zones in the given environment. */ - ZoneList in(Environment environment); + /** Zones in one of the given environments. */ + ZoneList in(Environment... environments); - /** Zones in the given region. */ - ZoneList in(RegionName region); + /** Zones in one of the given regions. */ + ZoneList in(RegionName... regions); /** Only the given zones — combine with not() for best effect! */ - ZoneList zones(ZoneId... zones); + ZoneList among(ZoneId... zones); /** Returns the id of all zones in this list as — you guessed it — a list. */ List<ZoneId> ids(); |