Search in sources :

Example 1 with FreeIpaUpgradeOptions

use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.

the class UpgradeServiceTest method testUpgradeOptionsCatalogNameFromCurrentImage.

@Test
public void testUpgradeOptionsCatalogNameFromCurrentImage() {
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setCatalogName("catName");
    when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    ImageInfoResponse targetImage = new ImageInfoResponse();
    when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
    FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, null);
    assertEquals(currentImage, result.getCurrentImage());
    assertEquals(1, result.getImages().size());
    assertEquals(targetImage, result.getImages().get(0));
    ImageSettingsRequest imageSettingsRequest = captor.getValue();
    assertEquals("catName", imageSettingsRequest.getCatalog());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with FreeIpaUpgradeOptions

use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.

the class UpgradeServiceTest method testUpgradeOptionsCatalogFromCurrentImage.

@Test
public void testUpgradeOptionsCatalogFromCurrentImage() {
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setCatalog("cat2");
    currentImage.setCatalogName("catName");
    when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    ImageInfoResponse targetImage = new ImageInfoResponse();
    when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
    FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, null);
    assertEquals(currentImage, result.getCurrentImage());
    assertEquals(1, result.getImages().size());
    assertEquals(targetImage, result.getImages().get(0));
    ImageSettingsRequest imageSettingsRequest = captor.getValue();
    assertEquals("cat2", imageSettingsRequest.getCatalog());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with FreeIpaUpgradeOptions

use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.

the class UpgradeService method createFreeIpaUpgradeOptions.

private FreeIpaUpgradeOptions createFreeIpaUpgradeOptions(List<ImageInfoResponse> targetImages, ImageInfoResponse currentImage) {
    FreeIpaUpgradeOptions freeIpaUpgradeOptions = new FreeIpaUpgradeOptions();
    freeIpaUpgradeOptions.setImages(targetImages);
    freeIpaUpgradeOptions.setCurrentImage(currentImage);
    return freeIpaUpgradeOptions;
}
Also used : FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions)

Example 4 with FreeIpaUpgradeOptions

use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions 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 5 with FreeIpaUpgradeOptions

use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.

the class UpgradeServiceTest method testUpgradeOptionsWithCatalogSet.

@Test
public void testUpgradeOptionsWithCatalogSet() {
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setCatalog("cat2");
    currentImage.setCatalogName("catName");
    when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    ImageInfoResponse targetImage = new ImageInfoResponse();
    when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
    FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, "cat");
    assertEquals(currentImage, result.getCurrentImage());
    assertEquals(1, result.getImages().size());
    assertEquals(targetImage, result.getImages().get(0));
    ImageSettingsRequest imageSettingsRequest = captor.getValue();
    assertEquals("cat", imageSettingsRequest.getCatalog());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpaUpgradeOptions (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions)5 Stack (com.sequenceiq.freeipa.entity.Stack)5 ImageInfoResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse)4 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)3 Test (org.junit.jupiter.api.Test)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)1