Search in sources :

Example 1 with DistroXV1Endpoint

use of com.sequenceiq.distrox.api.v1.distrox.endpoint.DistroXV1Endpoint in project cloudbreak by hortonworks.

the class DistroXRemoveInstancesAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    List<String> removableInstanceIds = testDto.getInstanceIdsForAction();
    if (!removableInstanceIds.isEmpty()) {
        MultipleInstanceDeleteRequest instanceDeleteRequest = new MultipleInstanceDeleteRequest();
        instanceDeleteRequest.setInstances(removableInstanceIds);
        Log.when(LOGGER, String.format(" Removing instances [%s] from distrox '%s'... ", instanceDeleteRequest.getInstances(), testDto.getName()));
        FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().deleteInstancesByCrn(testDto.getCrn(), removableInstanceIds, instanceDeleteRequest, false);
        testDto.setFlow("Instance deletion", flowIdentifier);
        StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
        testDto.setResponse(stackV4Response);
        Log.whenJson(LOGGER, " Distrox remove instances response: ", stackV4Response);
        LOGGER.info(String.format("Hardware info for distrox '%s' after remove instances [%s].", testDto.getName(), stackV4Response.getHardwareInfoGroups()));
        return testDto;
    } else {
        throw new TestFailException(String.format("Cannot find any instance to remove from distrox '%s'!", testDto.getName()));
    }
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) MultipleInstanceDeleteRequest(com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 2 with DistroXV1Endpoint

use of com.sequenceiq.distrox.api.v1.distrox.endpoint.DistroXV1Endpoint in project cloudbreak by hortonworks.

the class DistroXRepairAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    DistroXRepairV1Request distroXRepairV1Request = createRepairRequest();
    Log.when(LOGGER, format(" Starting repair on DistroX: %s ", testDto.getName()));
    Log.whenJson(LOGGER, " DistroX  repair request: ", distroXRepairV1Request);
    FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().repairClusterByName(testDto.getName(), distroXRepairV1Request);
    testDto.setFlow("DistroX repair flow identifier", flowIdentifier);
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " DistroX repair response: ", stackV4Response);
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXRepairV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXRepairV1Request) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 3 with DistroXV1Endpoint

use of com.sequenceiq.distrox.api.v1.distrox.endpoint.DistroXV1Endpoint in project cloudbreak by hortonworks.

the class DistroXRepairInstancesAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    DistroXRepairV1Request distroXRepairV1Request = createRepairRequest(testDto.getRepairableInstanceIds().orElse(Collections.emptyList()));
    Log.when(LOGGER, format("Starting repair instances on DistroX: %s ", testDto.getName()));
    Log.whenJson(LOGGER, "DistroX instance id based repair request: ", distroXRepairV1Request);
    FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().repairClusterByName(testDto.getName(), distroXRepairV1Request);
    testDto.setFlow("DistroX instance id based repair flow identifier", flowIdentifier);
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " DistroX instance id based repair response: ", stackV4Response);
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXRepairV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXRepairV1Request) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 4 with DistroXV1Endpoint

use of com.sequenceiq.distrox.api.v1.distrox.endpoint.DistroXV1Endpoint in project cloudbreak by hortonworks.

the class DistroXUpgradeAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    DistroXUpgradeV1Request upgradeRequest = testDto.getDistroXUpgradeRequest();
    Log.when(LOGGER, format(" Starting DistroX upgrade: %s ", testDto.getName()));
    Log.whenJson(LOGGER, " DistroX upgrade request: ", upgradeRequest);
    DistroXUpgradeV1Response response = client.getDefaultClient().distroXUpgradeV1Endpoint().upgradeClusterByName(testDto.getName(), upgradeRequest);
    testDto.setFlow("DistroX upgrade flow identifier", response.getFlowIdentifier());
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " DistroX upgrade response: ", stackV4Response);
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)

Example 5 with DistroXV1Endpoint

use of com.sequenceiq.distrox.api.v1.distrox.endpoint.DistroXV1Endpoint in project cloudbreak by hortonworks.

the class DistroXScaleAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    Log.when(LOGGER, String.format("Distrox scale request on: %s. Hostgroup: %s, desiredCount: %d", testDto.getName(), hostGroup, desiredCount));
    Log.whenJson(LOGGER, " Distrox scale request: ", testDto.getRequest());
    DistroXScaleV1Request scaleRequest = new DistroXScaleV1Request();
    scaleRequest.setGroup(hostGroup);
    scaleRequest.setDesiredCount(desiredCount);
    scaleRequest.setAdjustmentType(adjustmentType);
    scaleRequest.setThreshold(threshold);
    FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().putScalingByName(testDto.getName(), scaleRequest);
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
    testDto.setFlow("Distrox scale", flowIdentifier);
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " Distrox scale response: ", stackV4Response);
    LOGGER.info("Hardware info for stack after upscale: {}", stackV4Response.getHardwareInfoGroups());
    return testDto;
}
Also used : DistroXScaleV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXScaleV1Request) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)5 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)4 DistroXRepairV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXRepairV1Request)2 DistroXScaleV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXScaleV1Request)1 MultipleInstanceDeleteRequest (com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest)1 DistroXUpgradeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)1 DistroXUpgradeV1Response (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1