use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testReadImageCatalogFromFileWithoutVersionsButWithAdvertisedFlag.
@Test
public void testReadImageCatalogFromFileWithoutVersionsButWithAdvertisedFlag() {
String path = getPath(IMAGE_CATALOG_WITHOUT_VERSIONS);
ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_CENTOS_7_FILTER);
ImageCatalog catalog = underTest.getImageCatalog(IMAGE_CATALOG_WITHOUT_VERSIONS);
List<com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image> images = catalog.getImages().getFreeipaImages();
assertEquals(2, images.size());
FreeIpaVersions freeIpaVersions = catalog.getVersions().getFreeIpaVersions().get(0);
assertEquals(1, freeIpaVersions.getImageIds().size());
assertEquals("91851893-8340-411d-afb7-e1b55107fb10", freeIpaVersions.getImageIds().get(0));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testReadImageCatalogFromFile.
@Test
public void testReadImageCatalogFromFile() {
String path = getPath(IMAGE_CATALOG_JSON);
ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
ImageCatalog catalog = underTest.getImageCatalog(IMAGE_CATALOG_JSON);
List<com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image> images = catalog.getImages().getFreeipaImages();
assertEquals(4, images.size());
assertEquals("61851893-8340-411d-afb7-e1b55107fb10", images.get(0).getUuid());
FreeIpaVersions freeIpaVersions = catalog.getVersions().getFreeIpaVersions().get(0);
assertEquals(2, freeIpaVersions.getImageIds().size());
assertEquals("61851893-8340-411d-afb7-e1b55107fb10", freeIpaVersions.getImageIds().get(0));
assertEquals(1, freeIpaVersions.getDefaults().size());
assertEquals(List.of("71851893-8340-411d-afb7-e1b55107fb10"), freeIpaVersions.getDefaults());
assertEquals(4, freeIpaVersions.getVersions().size());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions 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.FreeIpaVersions in project cloudbreak by hortonworks.
the class ImageCatalogProvider method getVersions.
private Versions getVersions(ImageCatalog catalog) {
if (catalog.getVersions() == null || catalog.getVersions().getFreeIpaVersions() == null) {
LOGGER.debug("FreeIPA versions are missing from the image catalog, generating it based on the current svc version and on advertised flags.");
List<String> advertisedImageUuids = catalog.getImages().getFreeipaImages().stream().filter(Image::isAdvertised).map(Image::getUuid).collect(Collectors.toList());
List<FreeIpaVersions> versionList = List.of(new FreeIpaVersions(List.of(freeIpaVersion), List.of(), advertisedImageUuids));
Versions versions = new Versions(versionList);
LOGGER.debug("Generated versions: '{}'", versions);
return versions;
} else {
return catalog.getVersions();
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions 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