use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeCcmService method checkPrerequsities.
public void checkPrerequsities(Long stackId) {
Stack stack = stackService.getStackById(stackId);
ImageEntity stackImage = imageService.getByStackId(stackId);
FreeIpaUpgradeOptions freeIpaUpgradeOptions = upgradeService.collectUpgradeOptions(stack.getAccountId(), stack.getEnvironmentCrn(), Objects.requireNonNullElse(stackImage.getImageCatalogName(), stackImage.getImageCatalogUrl()));
if (!freeIpaUpgradeOptions.getImages().isEmpty()) {
throw new CloudbreakServiceException("FreeIPA is not on the latest available image. Please upgrade that first. CCM upgrade is not possible yet.");
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDateAndNoImageFoundInCatalog.
@Test
public void testFindTargetImagesCurrentImageMissingDateAndNoImageFoundInCatalog() {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("reg");
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenThrow(new ImageNotFoundException("Image not found"));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setId("222-333");
currentImage.setCatalogName("cat");
currentImage.setOs("zOs");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
ImageSettingsRequest settingsRequest = captor.getValue();
assertEquals(currentImage.getCatalogName(), settingsRequest.getCatalog());
assertEquals(currentImage.getId(), settingsRequest.getId());
assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImages.
@Test
public void testFindTargetImages() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertEquals(1, targetImages.size());
ImageInfoResponse imageInfoResponse = targetImages.get(0);
assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
assertEquals(image.getDate(), imageInfoResponse.getDate());
assertEquals(image.getUuid(), imageInfoResponse.getId());
assertEquals(image.getOs(), imageInfoResponse.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesImageWithWrongDateFormatIgnored.
@Test
public void testFindTargetImagesImageWithWrongDateFormatIgnored() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
Image image2 = createImage("20210901");
ImageWrapper imageWrapper2 = new ImageWrapper(image2, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName"), Pair.of(imageWrapper2, "imageName2")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertEquals(1, targetImages.size());
ImageInfoResponse imageInfoResponse = targetImages.get(0);
assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
assertEquals(image.getDate(), imageInfoResponse.getDate());
assertEquals(image.getUuid(), imageInfoResponse.getId());
assertEquals(image.getOs(), imageInfoResponse.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDateAndNoDateFromCatalog.
@Test
public void testFindTargetImagesCurrentImageMissingDateAndNoDateFromCatalog() {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("reg");
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
Image currentImageFromCatalog = createImage(null);
ImageWrapper currentImageWrapperFromCatalog = new ImageWrapper(currentImageFromCatalog, "asdf", "Asdf");
when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenReturn(currentImageWrapperFromCatalog);
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setId("222-333");
currentImage.setCatalogName("cat");
currentImage.setOs("zOs");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
ImageSettingsRequest settingsRequest = captor.getValue();
assertEquals(currentImage.getCatalogName(), settingsRequest.getCatalog());
assertEquals(currentImage.getId(), settingsRequest.getId());
assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
Aggregations