Search in sources :

Example 1 with MultipleInstanceDeleteRequest

use of com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest 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)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 MultipleInstanceDeleteRequest (com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1