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