Search in sources :

Example 1 with Master

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

the class AbstractAddMasterCommand method executeThis.

@Override
protected void executeThis() {
    String masterName = getMasterName();
    Master master = buildMaster(masterName);
    String ciName = getCiName();
    String currentDeployment = getCurrentDeployment();
    new OperationHandler<Void>().setOperation(Daemon.addMaster(currentDeployment, ciName, !noValidate, master)).setSuccessMessage("Added " + masterName + " for " + ciName + ".").setFailureMesssage("Failed to add " + masterName + " for " + ciName + ".").get();
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with Master

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

the class AbstractEditMasterCommand method executeThis.

@Override
protected void executeThis() {
    String masterName = getMasterName();
    String ciName = getCiName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    Master master = new OperationHandler<Master>().setOperation(Daemon.getMaster(currentDeployment, ciName, masterName, !noValidate)).setFailureMesssage("Failed to get " + masterName + " under " + ciName + ".").get();
    int originalHash = master.hashCode();
    master = editMaster((T) master);
    if (originalHash == master.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setMaster(currentDeployment, ciName, masterName, !noValidate, master)).setSuccessMessage("Edited " + masterName + " for " + ciName + ".").setFailureMesssage("Failed to edit " + masterName + " for " + ciName + ".").get();
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 3 with Master

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

the class JenkinsAddMasterCommand method buildMaster.

@Override
protected Master buildMaster(String masterName) {
    JenkinsMaster master = (JenkinsMaster) new JenkinsMaster().setName(masterName);
    master.setAddress(address).setPassword(password).setUsername(username).setCsrf(csrf);
    return master;
}
Also used : JenkinsMaster(com.netflix.spinnaker.halyard.config.model.v1.ci.jenkins.JenkinsMaster)

Example 4 with Master

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

the class MasterController method addMaster.

@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addMaster(@PathVariable String deploymentName, @PathVariable String ciName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMaster) {
    Master master = objectMapper.convertValue(rawMaster, Cis.translateMasterType(ciName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> master.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> masterService.addMaster(deploymentName, ciName, master));
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> masterService.validateMaster(deploymentName, ciName, master.getName());
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Add the " + master.getName() + " master");
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Master

use of com.netflix.spinnaker.halyard.config.model.v1.node.Master 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)

Aggregations

Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)7 Ci (com.netflix.spinnaker.halyard.config.model.v1.node.Ci)3 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)2 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)2 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)2 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)2 Path (java.nio.file.Path)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)1 JenkinsMaster (com.netflix.spinnaker.halyard.config.model.v1.ci.jenkins.JenkinsMaster)1 TravisMaster (com.netflix.spinnaker.halyard.config.model.v1.ci.travis.TravisMaster)1 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1