Search in sources :

Example 1 with Ci

use of com.netflix.spinnaker.halyard.config.model.v1.node.Ci in project halyard by spinnaker.

the class CiService method getAllCis.

public List<Ci> getAllCis(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyCi();
    List<Ci> matching = lookupService.getMatchingNodesOfType(filter, Ci.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No cis could be found").build());
    } else {
        return matching;
    }
}
Also used : Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 2 with Ci

use of com.netflix.spinnaker.halyard.config.model.v1.node.Ci in project halyard by spinnaker.

the class CiService method getCi.

public Ci getCi(String deploymentName, String ciName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCi(ciName);
    List<Ci> matching = lookupService.getMatchingNodesOfType(filter, Ci.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No Continuous Integration service with name \"" + ciName + "\" could be found").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one CI with name \"" + ciName + "\" found").build());
    }
}
Also used : Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 3 with Ci

use of com.netflix.spinnaker.halyard.config.model.v1.node.Ci in project halyard by spinnaker.

the class MasterService method deleteMaster.

public void deleteMaster(String deploymentName, String ciName, String masterName) {
    Ci ci = ciService.getCi(deploymentName, ciName);
    boolean removed = ci.getMasters().removeIf(master -> ((Master) master).getName().equals(masterName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Master \"" + masterName + "\" wasn't found").build());
    }
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 4 with Ci

use of com.netflix.spinnaker.halyard.config.model.v1.node.Ci in project halyard by spinnaker.

the class MasterService method addMaster.

public void addMaster(String deploymentName, String ciName, Master newMaster) {
    Ci ci = ciService.getCi(deploymentName, ciName);
    ci.getMasters().add(newMaster);
}
Also used : Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci)

Example 5 with Ci

use of com.netflix.spinnaker.halyard.config.model.v1.node.Ci in project halyard by spinnaker.

the class AbstractListMastersCommand method executeThis.

@Override
protected void executeThis() {
    Ci ci = getCi();
    List<Master> masters = ci.getMasters();
    if (masters.isEmpty()) {
        AnsiUi.success("No configured masters for " + getCiName() + ".");
    } else {
        AnsiUi.success("Masters for " + getCiName() + ":");
        masters.forEach(master -> AnsiUi.listItem(master.getName()));
    }
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci)

Aggregations

Ci (com.netflix.spinnaker.halyard.config.model.v1.node.Ci)6 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)3 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)2 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)2 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1