Search in sources :

Example 36 with Image

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.");
    }
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 37 with Image

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());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageNotFoundException(com.sequenceiq.freeipa.service.image.ImageNotFoundException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 38 with Image

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());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 39 with Image

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());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 40 with Image

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());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)32 Test (org.junit.jupiter.api.Test)28 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)27 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)21 Stack (com.sequenceiq.freeipa.entity.Stack)16 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 ImageInfoResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse)9 ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)7 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)4 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 FreeIpaVersions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions)3 List (java.util.List)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 Backup (com.sequenceiq.freeipa.api.model.Backup)2 Versions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions)2 UsedImagesListV1Response (com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response)2 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)2 ImageNotFoundException (com.sequenceiq.freeipa.service.image.ImageNotFoundException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1