Search in sources :

Example 6 with InternalUpgradeSettings

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

the class BlueprintBasedUpgradeValidatorTest method createImageFilterParams.

private ImageFilterParams createImageFilterParams(String blueprintName, StackType stackType) {
    Blueprint blueprint = new Blueprint();
    blueprint.setName(blueprintName);
    return new ImageFilterParams(null, true, null, stackType, blueprint, null, new InternalUpgradeSettings(true, true, true), null);
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 7 with InternalUpgradeSettings

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

the class UpgradeConverterTest method testConvertRequestWhenInternal.

@Test
public void testConvertRequestWhenInternal() {
    // GIVEN
    DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
    // WHEN
    UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(true, true, true));
    // THEN
    assertTrue(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 8 with InternalUpgradeSettings

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

the class DistroXUpgradeV1ControllerTest method testDryRun.

@Test
public void testDryRun() {
    DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
    UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
    upgradeV4Request.setDryRun(Boolean.TRUE);
    when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
    UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
    when(upgradeAvailabilityService.checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN)).thenReturn(upgradeV4Response);
    when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, distroxUpgradeRequest));
    verify(upgradeAvailabilityService).checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN);
    verifyNoInteractions(upgradeService);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test)

Example 9 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, InternalUpgradeSettings internalUpgradeSettings) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    UpgradeV4Request request = upgradeConverter.convert(distroxUpgradeRequest, internalUpgradeSettings);
    Long workspaceId = restRequestThreadLocalService.getRequestedWorkspaceId();
    if (request.isDryRun() || request.isShowAvailableImagesSet()) {
        LOGGER.info("Checking for upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
        UpgradeV4Response upgradeV4Response = upgradeAvailabilityService.checkForUpgrade(nameOrCrn, workspaceId, request, userCrn);
        return upgradeConverter.convert(upgradeV4Response);
    } else {
        LOGGER.info("Triggering upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
        UpgradeV4Response upgradeV4Response = upgradeService.triggerUpgrade(nameOrCrn, workspaceId, userCrn, request);
        return upgradeConverter.convert(upgradeV4Response);
    }
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)

Example 10 with InternalUpgradeSettings

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

the class DistroXUpgradeV1Controller method upgradeClusterByCrnInternal.

@Override
@InternalOnly
public DistroXUpgradeV1Response upgradeClusterByCrnInternal(@ResourceCrn String clusterCrn, @Valid DistroXUpgradeV1Request distroxUpgradeRequest, @InitiatorUserCrn String initiatorUserCrn) {
    NameOrCrn nameOrCrn = NameOrCrn.ofCrn(clusterCrn);
    boolean dataHubRuntimeUpgradeEnabled = upgradeAvailabilityService.isRuntimeUpgradeEnabledByUserCrn(initiatorUserCrn);
    boolean dataHubOsUpgradeEntitled = upgradeAvailabilityService.isOsUpgradeEnabledByUserCrn(initiatorUserCrn);
    return upgradeCluster(clusterCrn, 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)

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