use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image 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.Image in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImageGivenNoInputWithInvalidAppVersion.
@Test
public void testGetImageGivenNoInputWithInvalidAppVersion() {
ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "freeIpaVersion", "2.21.0-dcv.1", null);
ImageSettingsRequest is = setupImageSettingsRequest(null, null, "centos7");
Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
assertEquals("centos7", image.getOs());
assertEquals("2019-05-09", image.getDate());
assertEquals("91851893-8340-411d-afb7-e1b55107fb10", image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class ImageServiceTest method testImageChange.
@Test
public void testImageChange() {
Stack stack = new Stack();
stack.setCloudPlatform(DEFAULT_PLATFORM);
stack.setRegion(DEFAULT_REGION);
ImageSettingsRequest imageRequest = new ImageSettingsRequest();
when(imageProviderFactory.getImageProvider(any())).thenReturn(imageProvider);
when(imageProvider.getImage(imageRequest, stack.getRegion(), stack.getCloudPlatform())).thenReturn(Optional.of(new ImageWrapper(image, IMAGE_CATALOG_URL, IMAGE_CATALOG)));
when(image.getImageSetsByProvider()).thenReturn(Collections.singletonMap(DEFAULT_PLATFORM, Collections.singletonMap(DEFAULT_REGION, EXISTING_ID)));
when(imageRepository.getByStack(stack)).thenReturn(new ImageEntity());
when(image.getUuid()).thenReturn(IMAGE_UUID);
when(imageRepository.save(any(ImageEntity.class))).thenAnswer(invocation -> invocation.getArgument(0, ImageEntity.class));
ImageEntity imageEntity = underTest.changeImage(stack, imageRequest);
assertEquals(EXISTING_ID, imageEntity.getImageName());
assertEquals(IMAGE_CATALOG_URL, imageEntity.getImageCatalogUrl());
assertEquals(IMAGE_CATALOG, imageEntity.getImageCatalogName());
assertEquals(IMAGE_UUID, imageEntity.getImageId());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image 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.Image in project cloudbreak by hortonworks.
the class ImageCatalogChangeService method getImageSettingsRequestForNewCatalogWithCurrentImageSettings.
private ImageSettingsRequest getImageSettingsRequestForNewCatalogWithCurrentImageSettings(String imageCatalog, ImageEntity image) {
final ImageSettingsRequest imageRequest = new ImageSettingsRequest();
imageRequest.setCatalog(imageCatalog);
imageRequest.setId(image.getImageId());
imageRequest.setOs(image.getOs());
return imageRequest;
}
Aggregations