Search in sources :

Example 6 with DownscaleRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleRequest in project cloudbreak by hortonworks.

the class FreeIpaDownscaleAction method action.

@Override
public FreeIpaDownscaleTestDto action(TestContext testContext, FreeIpaDownscaleTestDto testDto, FreeIpaClient client) throws Exception {
    Log.whenJson(LOGGER, format(" FreeIPA downscale request:%n"), testDto.getRequest());
    DownscaleRequest downscaleRequest = new DownscaleRequest();
    downscaleRequest.setEnvironmentCrn(testDto.getRequest().getEnvironmentCrn());
    downscaleRequest.setTargetAvailabilityType(testDto.getRequest().getTargetAvailabilityType());
    testDto.setResponse(client.getDefaultClient().getFreeIpaV1Endpoint().downscale(downscaleRequest));
    testDto.setFlow("FreeIPA downscale", testDto.getResponse().getFlowIdentifier());
    testDto.setOperationId(testDto.getResponse().getOperationId());
    Log.whenJson(LOGGER, format(" FreeIPA downscale started: %n"), testDto.getResponse());
    return testDto;
}
Also used : DownscaleRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleRequest)

Example 7 with DownscaleRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleRequest in project cloudbreak by hortonworks.

the class FreeIpaScalingService method downscale.

public DownscaleResponse downscale(String accountId, DownscaleRequest request) {
    Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(request.getEnvironmentCrn(), accountId);
    Set<InstanceMetaData> allInstances = stack.getNotDeletedInstanceMetaDataSet();
    AvailabilityType originalAvailabilityType = AvailabilityType.getByInstanceCount(allInstances.size());
    logRequest(OperationType.DOWNSCALE, request, originalAvailabilityType);
    validationService.validateStackForDownscale(allInstances, stack, new ScalingPath(originalAvailabilityType, request.getTargetAvailabilityType()));
    return triggerDownscale(request, stack, originalAvailabilityType);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) ScalingPath(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath) AvailabilityType(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.AvailabilityType) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

DownscaleRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleRequest)5 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 Operation (com.sequenceiq.freeipa.entity.Operation)3 Test (org.junit.jupiter.api.Test)3 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 DownscaleResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleResponse)2 ScalingPath (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath)2 AvailabilityType (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.AvailabilityType)1 DownscaleEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent)1