use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeService method initUpgrade.
private UpgradeV4Response initUpgrade(UpgradeV4Request request, UpgradeV4Response upgradeV4Response, NameOrCrn cluster, Long workspaceId, String userCrn) {
ImageInfoV4Response image = imageSelector.determineImageId(request, upgradeV4Response.getUpgradeCandidates());
ImageChangeDto imageChangeDto = createImageChangeDto(cluster, workspaceId, image);
Stack stack = stackService.getByNameOrCrnInWorkspace(cluster, workspaceId);
boolean lockComponents = request.getLockComponents() != null ? request.getLockComponents() : isComponentsLocked(stack, image);
validateOsUpgradeEntitled(lockComponents, request);
boolean replaceVms = determineReplaceVmsParam(upgradeV4Response, lockComponents, stack);
String upgradeVariant = calculateUpgradeVariant(stack, userCrn);
FlowIdentifier flowIdentifier = reactorFlowManager.triggerDistroXUpgrade(stack.getId(), imageChangeDto, replaceVms, lockComponents, upgradeVariant);
UpgradeV4Response response = new UpgradeV4Response("Upgrade started with Image: " + image.getImageId(), flowIdentifier);
response.setReplaceVms(replaceVms);
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeService method triggerUpgrade.
public UpgradeV4Response triggerUpgrade(NameOrCrn cluster, Long workspaceId, String userCrn, UpgradeV4Request request) {
UpgradeV4Response upgradeV4Response = upgradeAvailabilityService.checkForUpgrade(cluster, workspaceId, request, userCrn);
validateUpgradeCandidates(cluster, upgradeV4Response);
verifyPaywallAccess(userCrn, request);
return initUpgrade(request, upgradeV4Response, cluster, workspaceId, userCrn);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsImageIdValid.
@Test
public void testFilterUpgradeOptionsImageIdValid() {
UpgradeV4Request request = new UpgradeV4Request();
request.setImageId(IMAGE_ID);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(1, response.getUpgradeCandidates().size());
assertEquals(IMAGE_ID, response.getUpgradeCandidates().get(0).getImageId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsUpgradeRequestEmpty.
@Test
public void testFilterUpgradeOptionsUpgradeRequestEmpty() {
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
when(entitlementService.runtimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(true);
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(1, response.getUpgradeCandidates().size());
assertEquals(IMAGE_ID_LAST, response.getUpgradeCandidates().get(0).getImageId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsRuntimeValid.
@Test
public void testFilterUpgradeOptionsRuntimeValid() {
UpgradeV4Request request = new UpgradeV4Request();
request.setRuntime(MATCHING_TARGET_RUNTIME);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(2, response.getUpgradeCandidates().size());
assertEquals(2, response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).collect(Collectors.toSet()).size());
}
Aggregations