use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImagesGivenUuidInputFound.
@Test
public void testGetImagesGivenUuidInputFound() {
ImageSettingsRequest is = setupImageSettingsRequest(IMAGE_UUID, null, null);
List<ImageWrapper> images = underTest.getImages(is, DEFAULT_REGION, DEFAULT_PLATFORM);
assertEquals(1, images.size());
ImageWrapper imageWrapper = images.get(0);
assertEquals(DEFAULT_CATALOG_URL, imageWrapper.getCatalogUrl());
assertNull(imageWrapper.getCatalogName());
Image image = imageWrapper.getImage();
assertEquals(DEFAULT_OS, image.getOs());
assertEquals(LATEST_DATE, image.getDate());
assertEquals(IMAGE_UUID, image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImagesGivenAllInput.
@Test
public void testGetImagesGivenAllInput() {
ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, CUSTOM_IMAGE_CATALOG_URL, DEFAULT_OS);
List<ImageWrapper> images = underTest.getImages(is, DEFAULT_REGION, DEFAULT_PLATFORM);
assertEquals(1, images.size());
ImageWrapper imageWrapper = images.get(0);
assertEquals(CUSTOM_IMAGE_CATALOG_URL, imageWrapper.getCatalogUrl());
assertNull(imageWrapper.getCatalogName());
Image image = imageWrapper.getImage();
assertEquals(DEFAULT_OS, image.getOs());
assertEquals(LATEST_DATE, image.getDate());
assertEquals(IMAGE_UUID, image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images in project cloudbreak by hortonworks.
the class CoreImageProvider method getImages.
@Override
public List<ImageWrapper> getImages(ImageSettingsRequest imageSettings, String region, String platform) {
try {
ImagesV4Response imagesV4Response = imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), null, platform, null, null, false);
LOGGER.debug("Images received: {}", imagesV4Response);
return Optional.ofNullable(imagesV4Response.getFreeipaImages()).orElseGet(List::of).stream().map(this::convert).flatMap(Optional::stream).map(img -> new ImageWrapper(img, null, imageSettings.getCatalog())).collect(Collectors.toList());
} catch (WebApplicationException e) {
String errorMessage = messageExtractor.getErrorMessage(e);
LOGGER.warn("Fetching images failed with: {}", errorMessage, e);
return List.of();
} catch (Exception e) {
LOGGER.warn("Fetching images failed", e);
return List.of();
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images in project cloudbreak by hortonworks.
the class FreeIpaImageProvider method getImages.
public List<ImageWrapper> getImages(ImageSettingsRequest imageSettings, String region, String platform) {
String imageId = imageSettings.getId();
String catalogUrl = StringUtils.isNotBlank(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl;
String imageOs = StringUtils.isNotBlank(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs;
ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl);
List<Image> compatibleImages = findImage(imageId, imageOs, cachedImageCatalog.getImages().getFreeipaImages(), region, platform);
List<String> imagesInVersions = filterFreeIpaVersionsByAppVersion(cachedImageCatalog.getVersions().getFreeIpaVersions()).stream().map(FreeIpaVersions::getImageIds).flatMap(Collection::stream).distinct().collect(Collectors.toList());
LOGGER.debug("Compatible images: {} " + System.lineSeparator() + "Images in versions: {}", compatibleImages, imagesInVersions);
return compatibleImages.stream().filter(image -> imagesInVersions.contains(image.getUuid())).map(image -> new ImageWrapper(image, catalogUrl, null)).collect(Collectors.toList());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images in project cloudbreak by hortonworks.
the class ImageCatalogProvider method filterImagesByOsType.
private ImageCatalog filterImagesByOsType(ImageCatalog catalog) {
LOGGER.debug("Filtering images by OS type {}", getEnabledLinuxTypes());
if ((CollectionUtils.isEmpty(getEnabledLinuxTypes()) || Objects.isNull(catalog.getImages())) && Objects.nonNull(catalog.getVersions())) {
return catalog;
}
List<Image> catalogImages = catalog.getImages().getFreeipaImages();
List<Image> filterImages = filterImages(catalogImages, enabledOsPredicate());
List<FreeIpaVersions> filteredVersions = filterVersions(catalog, filterImages);
return new ImageCatalog(new Images(filterImages), new Versions(filteredVersions));
}
Aggregations