use of com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage in project halyard by spinnaker.
the class BakeryController method setBaseImage.
@RequestMapping(value = "/defaults/baseImage/{baseImageId:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setBaseImage(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String baseImageId, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawBaseImage) {
BaseImage baseImage = objectMapper.convertValue(rawBaseImage, Providers.translateBaseImageType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> baseImage.stageLocalFiles(configPath));
builder.setUpdate(() -> bakeryService.setBaseImage(deploymentName, providerName, baseImageId, baseImage));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> bakeryService.validateBaseImage(deploymentName, providerName, baseImage.getBaseImage().getId());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + baseImageId + " base image");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage in project halyard by spinnaker.
the class BakeryService method getAllBaseImages.
public List<BaseImage> getAllBaseImages(String deploymentName, String providerName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName).setBakeryDefaults().withAnyBaseImage();
List<BaseImage> matchingBaseImages = lookupService.getMatchingNodesOfType(filter, BaseImage.class);
if (matchingBaseImages.size() == 0) {
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No base images could be found").build());
} else {
return matchingBaseImages;
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage in project halyard by spinnaker.
the class BakeryService method deleteBaseImage.
public void deleteBaseImage(String deploymentName, String bakeryDefaultsName, String baseImageId) {
BakeryDefaults bakeryDefaults = getBakeryDefaults(deploymentName, bakeryDefaultsName);
boolean removed = bakeryDefaults.getBaseImages().removeIf(baseImage -> ((BaseImage) baseImage).getBaseImage().getId().equals(baseImageId));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "BaseImage \"" + baseImageId + "\" wasn't found").build());
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage in project halyard by spinnaker.
the class AbstractListBaseImagesCommand method executeThis.
@Override
protected void executeThis() {
String providerName = getProviderName();
String currentDeployment = getCurrentDeployment();
BakeryDefaults bakeryDefaults = new OperationHandler<BakeryDefaults>().setFailureMesssage("Failed to get bakery defaults for " + providerName + "'s bakery.").setOperation(Daemon.getBakeryDefaults(currentDeployment, providerName, !noValidate)).get();
List<BaseImage> baseImages = bakeryDefaults.getBaseImages();
if (baseImages.isEmpty()) {
AnsiUi.success("No configured base images for " + getProviderName() + ".");
} else {
AnsiUi.success("Base images for " + getProviderName() + ":");
baseImages.forEach(baseImage -> AnsiUi.listItem(baseImage.getBaseImage().getId()));
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage in project halyard by spinnaker.
the class OpenstackAddBaseImageCommand method buildBaseImage.
@Override
protected BaseImage buildBaseImage(String baseImageId) {
OpenstackBaseImage baseImage = new OpenstackBaseImage();
OpenstackBaseImage.OpenstackImageSettings imageSettings = new OpenstackBaseImage.OpenstackImageSettings();
baseImage.setBaseImage(imageSettings);
// TODO(edwinavalos) Support multiple virtualization settings
List<OpenstackBaseImage.OpenstackVirtualizationSettings> vsList = new ArrayList<>();
OpenstackBaseImage.OpenstackVirtualizationSettings virtualizationSettings = new OpenstackBaseImage.OpenstackVirtualizationSettings();
virtualizationSettings.setSourceImageId(sourceImageId);
virtualizationSettings.setRegion(region);
virtualizationSettings.setInstanceType(instanceType);
virtualizationSettings.setSshUserName(sshUserName);
vsList.add(virtualizationSettings);
baseImage.setVirtualizationSettings(vsList);
return baseImage;
}
Aggregations