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();
}
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();
}
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;
}
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");
}
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());
}
}
Aggregations