Search in sources :

Example 11 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class DistroXUpgradeV1Controller method upgradeCluster.

private DistroXUpgradeV1Response upgradeCluster(String clusterNameOrCrn, DistroXUpgradeV1Request distroxUpgradeRequest, NameOrCrn nameOrCrn) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    boolean dataHubRuntimeUpgradeEnabled = upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(accountId);
    boolean dataHubOsUpgradeEntitled = upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(accountId);
    return upgradeCluster(clusterNameOrCrn, distroxUpgradeRequest, nameOrCrn, new InternalUpgradeSettings(false, dataHubRuntimeUpgradeEnabled, dataHubOsUpgradeEntitled));
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)

Example 12 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class DistroXUpgradeV1Controller method upgradeClusterByNameInternal.

@Override
@InternalOnly
public DistroXUpgradeV1Response upgradeClusterByNameInternal(@ResourceName String clusterName, @Valid DistroXUpgradeV1Request distroxUpgradeRequest, @InitiatorUserCrn String initiatorUserCrn) {
    NameOrCrn nameOrCrn = NameOrCrn.ofName(clusterName);
    boolean dataHubRuntimeUpgradeEnabled = upgradeAvailabilityService.isRuntimeUpgradeEnabledByUserCrn(initiatorUserCrn);
    boolean dataHubOsUpgradeEntitled = upgradeAvailabilityService.isOsUpgradeEnabledByUserCrn(initiatorUserCrn);
    return upgradeCluster(clusterName, distroxUpgradeRequest, nameOrCrn, new InternalUpgradeSettings(true, dataHubRuntimeUpgradeEnabled, dataHubOsUpgradeEntitled));
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) InternalOnly(com.sequenceiq.authorization.annotation.InternalOnly)

Example 13 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityService method checkForUpgrades.

private UpgradeV4Response checkForUpgrades(Stack stack, boolean lockComponents, InternalUpgradeSettings internalUpgradeSettings) {
    String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
    UpgradeV4Response upgradeOptions = new UpgradeV4Response();
    try {
        LOGGER.info(String.format("Retrieving images for upgrading stack %s", stack.getName()));
        com.sequenceiq.cloudbreak.cloud.model.Image currentImage = getImage(stack);
        CloudbreakImageCatalogV3 imageCatalog = getImagesFromCatalog(stack.getWorkspace(), currentImage.getImageCatalogName(), currentImage.getImageCatalogUrl());
        Image image = getCurrentImageFromCatalog(currentImage.getImageId(), imageCatalog);
        ImageFilterParams imageFilterParams = createImageFilterParams(image, lockComponents, stack, internalUpgradeSettings);
        ImageFilterResult imageFilterResult = filterImages(accountId, imageCatalog, imageFilterParams);
        LOGGER.info(String.format("%d possible image found for stack upgrade.", imageFilterResult.getImages().size()));
        upgradeOptions = createResponse(image, imageFilterResult, stack.getCloudPlatform(), stack.getRegion(), currentImage.getImageCatalogName());
    } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException | NotFoundException e) {
        LOGGER.warn("Failed to get images", e);
        upgradeOptions.setReason(String.format("Failed to retrieve image due to %s", e.getMessage()));
    }
    return upgradeOptions;
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)

Example 14 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class UpgradeConverterTest method testConvertRequest.

@Test
public void testConvertRequest() {
    DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
    source.setDryRun(Boolean.TRUE);
    source.setImageId("asdf");
    source.setShowAvailableImages(DistroXUpgradeShowAvailableImages.LATEST_ONLY);
    source.setLockComponents(Boolean.TRUE);
    source.setReplaceVms(DistroXUpgradeReplaceVms.DISABLED);
    source.setRuntime("runtime");
    UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(false, true, true));
    assertEquals(source.getDryRun(), result.getDryRun());
    assertEquals(source.getImageId(), result.getImageId());
    assertEquals(source.getShowAvailableImages().name(), result.getShowAvailableImages().name());
    assertEquals(source.getLockComponents(), result.getLockComponents());
    assertEquals(Boolean.FALSE, result.getReplaceVms());
    assertEquals(source.getRuntime(), result.getRuntime());
    assertFalse(result.getInternalUpgradeSettings().isSkipValidations());
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class UpgradeConverterTest method testConvertRequestWhenReplaceVmsParamIsNotGiven.

@Test
public void testConvertRequestWhenReplaceVmsParamIsNotGiven() {
    // GIVEN
    DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
    // WHEN
    UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(false, true, true));
    // THEN
    assertNull(result.getReplaceVms());
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)25 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)13 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)12 Test (org.junit.Test)12 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)11 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 DistroXUpgradeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)7 Test (org.junit.jupiter.api.Test)7 DistroXUpgradeV1Response (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)2 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1