use of com.sequenceiq.common.api.type.ImageType in project cloudbreak by hortonworks.
the class DefaultImageCatalogService method getImageFromDefaultCatalog.
public StatedImage getImageFromDefaultCatalog(String type, ImageCatalogPlatform provider, String runtime) throws CloudbreakImageCatalogException, CloudbreakImageNotFoundException {
ImageType imageType = ImageType.valueOf(type);
StatedImage statedImage;
switch(imageType) {
case FREEIPA:
throw new BadRequestException(String.format("Runtime is not supported in case of '%s' image type", imageType));
case RUNTIME:
ImageCatalog imageCatalog = getCloudbreakDefaultImageCatalog();
ImageFilter imageFilter = new ImageFilter(imageCatalog, Set.of(provider), null, false, null, runtime);
statedImage = imageCatalogService.getImagePrewarmedDefaultPreferred(imageFilter, i -> true);
break;
default:
throw new BadRequestException(String.format("Image type '%s' is not supported.", type));
}
return statedImage;
}
use of com.sequenceiq.common.api.type.ImageType in project cloudbreak by hortonworks.
the class DefaultImageCatalogService method getImageFromDefaultCatalog.
public StatedImage getImageFromDefaultCatalog(String type, String provider) throws CloudbreakImageCatalogException, CloudbreakImageNotFoundException {
ImageType imageType = ImageType.valueOf(type);
StatedImage statedImage;
switch(imageType) {
case FREEIPA:
List<Image> images = imageCatalogProvider.getImageCatalogV3(defaultFreeIpaCatalogUrl).getImages().getFreeIpaImages();
Optional<Image> image = images.stream().filter(i -> i.getImageSetsByProvider().keySet().stream().anyMatch(key -> key.equalsIgnoreCase(provider))).max(getImageComparing(images));
statedImage = statedImage(image.orElseThrow(() -> new CloudbreakImageNotFoundException(String.format("Could not find any image with provider: '%s' in catalog: '%s'", provider, FREEIPA_DEFAULT_CATALOG_NAME))), defaultFreeIpaCatalogUrl, FREEIPA_DEFAULT_CATALOG_NAME);
break;
case RUNTIME:
throw new BadRequestException(String.format("Runtime is required in case of '%s' image type", imageType));
default:
throw new BadRequestException(String.format("Type '%s' is not supported.", type));
}
return statedImage;
}
Aggregations