use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackCommonService method putStopInWorkspace.
public FlowIdentifier putStopInWorkspace(NameOrCrn nameOrCrn, Long workspaceId) {
Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
MDCBuilder.buildMdcContext(stack);
if (!cloudParameterCache.isStartStopSupported(stack.cloudPlatform())) {
throw new BadRequestException(String.format("Stop is not supported on %s cloudplatform", stack.cloudPlatform()));
}
UpdateStackV4Request updateStackJson = new UpdateStackV4Request();
updateStackJson.setStatus(StatusRequest.STOPPED);
updateStackJson.setWithClusterEvent(true);
return put(stack, updateStackJson);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackService method getStackRequestByNameOrCrnInWorkspaceId.
public StackV4Request getStackRequestByNameOrCrnInWorkspaceId(NameOrCrn nameOrCrn, Long workspaceId) {
try {
return transactionService.required(() -> {
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByNameOrCrnAndWorkspaceIdWithLists(nameOrCrn, workspaceId);
if (stack.isEmpty()) {
throw new NotFoundException(format(STACK_NOT_FOUND_BY_NAME_OR_CRN_EXCEPTION_MESSAGE, nameOrCrn));
}
StackV4Request request = stackToStackV4RequestConverter.convert(stack.get());
request.getCluster().setName(null);
request.setName(stack.get().getName());
return request;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn 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.dto.NameOrCrn in project cloudbreak by hortonworks.
the class DistroXUpgradeService method createImageChangeDto.
private ImageChangeDto createImageChangeDto(NameOrCrn cluster, Long workspaceId, ImageInfoV4Response image) {
StackImageChangeV4Request stackImageChangeRequest = new StackImageChangeV4Request();
stackImageChangeRequest.setImageId(image.getImageId());
stackImageChangeRequest.setImageCatalogName(image.getImageCatalogName());
return stackCommonService.createImageChangeDto(cluster, workspaceId, stackImageChangeRequest);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn 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);
}
Aggregations