use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2 in project cloudbreak by hortonworks.
the class ImageCatalogService method getImages.
public StatedImages getImages(String imageCatalogUrl, String imageCatalogName, Set<String> platforms, String cbVersion) throws CloudbreakImageCatalogException {
LOGGER.info("Determine images for imageCatalogUrl: '{}', platforms: '{}' and Cloudbreak version: '{}'.", imageCatalogUrl, platforms, cbVersion);
StatedImages images;
CloudbreakImageCatalogV2 imageCatalog = imageCatalogProvider.getImageCatalogV2(imageCatalogUrl);
if (imageCatalog != null) {
Set<String> vMImageUUIDs = new HashSet<>();
List<CloudbreakVersion> cloudbreakVersions = imageCatalog.getVersions().getCloudbreakVersions();
String cbv = UNSPECIFIED_VERSION.equals(cbVersion) ? latestCloudbreakVersion(cloudbreakVersions) : cbVersion;
List<CloudbreakVersion> exactMatchedImgs = cloudbreakVersions.stream().filter(cloudbreakVersion -> cloudbreakVersion.getVersions().contains(cbv)).collect(Collectors.toList());
if (!exactMatchedImgs.isEmpty()) {
exactMatchedImgs.forEach(cloudbreakVersion -> vMImageUUIDs.addAll(cloudbreakVersion.getImageIds()));
} else {
vMImageUUIDs.addAll(prefixMatchForCBVersion(cbVersion, cloudbreakVersions));
}
List<Image> baseImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getBaseImages(), vMImageUUIDs);
List<Image> hdpImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getHdpImages(), vMImageUUIDs);
List<Image> hdfImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getHdfImages(), vMImageUUIDs);
images = statedImages(new Images(baseImages, hdpImages, hdfImages), imageCatalogUrl, imageCatalogName);
} else {
images = statedImages(emptyImages(), imageCatalogUrl, imageCatalogName);
}
return images;
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2 in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testImageCatalogWithoutBaseImages.
@Test
public void testImageCatalogWithoutBaseImages() throws CloudbreakImageCatalogException, IOException {
String path = getPath(CB_IMAGE_CATALOG_WITHOUT_BASE_IMAGES);
underTest.setEtcConfigDir(path);
CloudbreakImageCatalogV2 imageCatalogV2 = underTest.getImageCatalogV2(CB_IMAGE_CATALOG_WITHOUT_BASE_IMAGES);
Assert.assertNotNull(imageCatalogV2.getImages().getBaseImages());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2 in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testImageCatalogWithoutHdfImages.
@Test
public void testImageCatalogWithoutHdfImages() throws CloudbreakImageCatalogException, IOException {
String path = getPath(CB_IMAGE_CATALOG_WITHOUT_HDF_IMAGES);
underTest.setEtcConfigDir(path);
CloudbreakImageCatalogV2 imageCatalogV2 = underTest.getImageCatalogV2(CB_IMAGE_CATALOG_WITHOUT_HDF_IMAGES);
Assert.assertNotNull(imageCatalogV2.getImages().getHdfImages());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2 in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testImageCatalogFilterNullImages.
@Test
public void testImageCatalogFilterNullImages() throws CloudbreakImageCatalogException, IOException {
String path = getPath(CB_IMAGE_CATALOG_FILTER_NULL_IMAGES_JSON);
underTest.setEtcConfigDir(path);
CloudbreakImageCatalogV2 imageCatalogV2 = underTest.getImageCatalogV2(CB_IMAGE_CATALOG_FILTER_NULL_IMAGES_JSON);
Assert.assertEquals(1, imageCatalogV2.getImages().getBaseImages().get(0).getImageSetsByProvider().values().size());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2 in project cloudbreak by hortonworks.
the class ImageCatalogServiceDefaultTest method beforeTest.
@Before
public void beforeTest() throws Exception {
MockitoAnnotations.initMocks(this);
String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
CloudbreakImageCatalogV2 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV2.class);
when(imageCatalogProvider.getImageCatalogV2("")).thenReturn(catalog);
IdentityUser user = getIdentityUser();
when(authenticatedUserService.getCbUser()).thenReturn(user);
when(userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername())).thenReturn(new UserProfile());
}
Aggregations