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