use of com.cloudera.api.swagger.model.ApiBatchResponse in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method updateHostsWithRackIdUsingBatchCall.
private void updateHostsWithRackIdUsingBatchCall(List<ApiBatchRequestElement> batchRequestElements) throws ApiException {
BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(apiClient);
ApiBatchRequest batchRequest = new ApiBatchRequest().items(batchRequestElements);
ApiBatchResponse batchResponse = batchResourceApi.execute(batchRequest);
validateBatchResponse(batchResponse);
}
use of com.cloudera.api.swagger.model.ApiBatchResponse in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method processHostCertsBatchResponse.
private void processHostCertsBatchResponse(ApiClient client, ApiBatchResponse apiBatchResponse) {
if (apiBatchResponse != null && apiBatchResponse.getSuccess() != null && apiBatchResponse.getItems() != null && apiBatchResponse.getSuccess()) {
List<BigDecimal> ids = apiBatchResponse.getItems().stream().map(bre -> new Json((String) bre.getResponse()).getSilent(ApiCommand.class).getId()).collect(Collectors.toList());
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCommandList(stack, client, ids, "Rotate host certificates");
if (pollingResult.isExited()) {
throw new CancellationException("Cluster was terminated during rotation of host certificates");
} else if (pollingResult.isTimeout()) {
throw new ClouderaManagerOperationFailedException("Timeout while Cloudera Manager rotates the host certificates.");
}
} else {
throw new ClouderaManagerOperationFailedException("Host certificates rotation batch operation failed: " + apiBatchResponse);
}
}
use of com.cloudera.api.swagger.model.ApiBatchResponse in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method setUpBatchSuccess.
private void setUpBatchSuccess() throws ApiException {
setUpBatchWithResponseAnswer(invocation -> {
ApiBatchRequest batchRequest = invocation.getArgument(0, ApiBatchRequest.class);
int responseItemCount = batchRequest.getItems().size();
ApiBatchResponse batchResponse = new ApiBatchResponse().success(true).items(new ArrayList<>());
for (int i = 0; i < responseItemCount; i++) {
batchResponse.addItemsItem(new ApiBatchResponseElement());
}
return batchResponse;
});
}
use of com.cloudera.api.swagger.model.ApiBatchResponse in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method rotateHostCertificates.
@Override
public void rotateHostCertificates(String sshUser, KeyPair sshKeyPair, String subAltName) throws CloudbreakException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig);
HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client);
BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client);
ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY");
ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList, sshUser, sshKeyPair, subAltName);
ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest);
processHostCertsBatchResponse(client, apiBatchResponse);
} catch (ApiException | ClouderaManagerClientInitException e) {
LOGGER.warn("Can't rotate the host certificates", e);
throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage());
}
}
Aggregations