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));
}
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));
}
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;
}
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());
}
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());
}
Aggregations