diff options
author | Ola Aunrønning <olaa@verizonmedia.com> | 2021-04-12 15:43:52 +0200 |
---|---|---|
committer | Ola Aunrønning <olaa@verizonmedia.com> | 2021-04-12 15:43:52 +0200 |
commit | 5eed21519359724944bd886b25afbf6699876820 (patch) | |
tree | 59f56943273908578abc33bbba1eafc3a80cd57f /controller-api | |
parent | 64d09cf6b81565e82988507e2112d791e0fba33f (diff) |
Persist vcmrs
Diffstat (limited to 'controller-api')
4 files changed, 133 insertions, 2 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java index 31665c8ae0a..11adc1f7bb6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java @@ -16,7 +16,7 @@ public class ChangeRequest { private final Approval approval; private final Impact impact; - private ChangeRequest(String id, ChangeRequestSource changeRequestSource, List<String> impactedSwitches, List<String> impactedHosts, Approval approval, Impact impact) { + public ChangeRequest(String id, ChangeRequestSource changeRequestSource, List<String> impactedSwitches, List<String> impactedHosts, Approval approval, Impact impact) { this.id = Objects.requireNonNull(id); this.changeRequestSource = Objects.requireNonNull(changeRequestSource); this.impactedSwitches = Objects.requireNonNull(impactedSwitches); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java index 63f6c256766..632999ed1c3 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java @@ -17,7 +17,7 @@ public class ChangeRequestSource { private final ZonedDateTime plannedEndTime; - private ChangeRequestSource(String system, String id, String url, Status status, ZonedDateTime plannedStartTime, ZonedDateTime plannedEndTime) { + public ChangeRequestSource(String system, String id, String url, Status status, ZonedDateTime plannedStartTime, ZonedDateTime plannedEndTime) { this.system = Objects.requireNonNull(system); this.id = Objects.requireNonNull(id); this.url = Objects.requireNonNull(url); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/HostAction.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/HostAction.java new file mode 100644 index 00000000000..eeb7d89cbe7 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/HostAction.java @@ -0,0 +1,57 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.vcmr; + +import java.time.Instant; +import java.util.Objects; + +/** + * @author olaa + * + */ +public class HostAction { + + private final String hostname; + private final State state; + private final Instant lastUpdated; + + public HostAction(String hostname, State state, Instant lastUpdated) { + this.hostname = hostname; + this.state = state; + this.lastUpdated = lastUpdated; + } + + public String getHostname() { + return hostname; + } + + public State getState() { + return state; + } + + public Instant getLastUpdated() { + return lastUpdated; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + HostAction that = (HostAction) o; + return Objects.equals(hostname, that.hostname) && + state == that.state && + Objects.equals(lastUpdated, that.lastUpdated); + } + + @Override + public int hashCode() { + return Objects.hash(hostname, state, lastUpdated); + } + + public enum State { + REQUIRES_OPERATOR_ACTION, + PENDING_RETIREMENT, + RETIRING, + RETIRED, + COMPLETE + } +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VespaChangeRequest.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VespaChangeRequest.java new file mode 100644 index 00000000000..1dda6bb099c --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VespaChangeRequest.java @@ -0,0 +1,74 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.vcmr; + +import com.yahoo.config.provision.zone.ZoneId; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author olaa + */ +public class VespaChangeRequest extends ChangeRequest { + + private final Status status; + private final ZoneId zoneId; + // TODO: Create applicationActionPlan + private final List<HostAction> hostActionPlan; + + public VespaChangeRequest(String id, ChangeRequestSource changeRequestSource, List<String> impactedSwitches, List<String> impactedHosts, Approval approval, Impact impact, Status status, List<HostAction> hostActionPlan, ZoneId zoneId) { + super(id, changeRequestSource, impactedSwitches, impactedHosts, approval, impact); + this.status = status; + this.hostActionPlan = hostActionPlan; + this.zoneId = zoneId; + } + public VespaChangeRequest(ChangeRequest changeRequest, ZoneId zoneId) { + this(changeRequest.getId(), changeRequest.getChangeRequestSource(), changeRequest.getImpactedSwitches(), + changeRequest.getImpactedHosts(), changeRequest.getApproval(), changeRequest.getImpact(), Status.PENDING_ASSESSMENT, List.of(), zoneId); + } + + public Status getStatus() { + return status; + } + + public List<HostAction> getHostActionPlan() { + return hostActionPlan; + } + + public ZoneId getZoneId() { + return zoneId; + } + + public VespaChangeRequest withSource(ChangeRequestSource source) { + return new VespaChangeRequest(getId(), source, getImpactedSwitches(), getImpactedHosts(), getApproval(), getImpact(), status, hostActionPlan, zoneId); + } + + public VespaChangeRequest withImpactedHosts(List<String> hosts) { + return new VespaChangeRequest(getId(), getChangeRequestSource(), getImpactedSwitches(), new ArrayList<>(hosts), getApproval(), getImpact(), status, hostActionPlan, zoneId); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + VespaChangeRequest that = (VespaChangeRequest) o; + return status == that.status && + Objects.equals(hostActionPlan, that.hostActionPlan) && + Objects.equals(zoneId, that.zoneId); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), status, hostActionPlan, zoneId); + } + + public enum Status { + COMPLETED, + IN_PROGRESS, + PENDING_ACTION, + PENDING_ASSESSMENT, + REQUIRES_OPERATOR_ACTION + } +} |