use of com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus in project cloudbreak by hortonworks.
the class StartBindUserCreationService method invokeCreateBindUser.
private OperationStatus invokeCreateBindUser(StackView stackView) {
BindUserCreateRequest request = createRequest(stackView);
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
return ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> freeIpaV1Endpoint.createBindUser(request, userCrn));
}
use of com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus in project cloudbreak by hortonworks.
the class FreeIpaCleanupService method sendCleanupRequest.
private OperationStatus sendCleanupRequest(Stack stack, Set<CleanupStep> stepsToSkip, Set<String> hostNames, Set<String> ips) {
try {
CleanupRequest cleanupRequest = createCleanupRequest(stack, stepsToSkip, hostNames, ips);
LOGGER.info("Sending cleanup request to FreeIPA: [{}]", cleanupRequest);
OperationStatus cleanup = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> freeIpaV1Endpoint.internalCleanup(cleanupRequest, Crn.fromString(stack.getResourceCrn()).getAccountId()));
LOGGER.info("Cleanup operation started: {}", cleanup);
return cleanup;
} catch (WebApplicationException e) {
String errorMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Couldn't start cleanup due to: '%s' ", errorMessage);
LOGGER.error(message, e);
throw new FreeIpaOperationFailedException(message, e);
} catch (Exception e) {
LOGGER.error("Couldn't start cleanup", e);
throw new FreeIpaOperationFailedException("Couldn't start cleanup", e);
}
}
use of com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus in project cloudbreak by hortonworks.
the class FreeIpaOperationCheckerTask method checkStatus.
@Override
public boolean checkStatus(T operationPollerObject) {
OperationStatus operationStatus = ThreadBasedUserCrnProvider.doAsInternalActor(operationPollerObject.getRegionalAwareInternalCrnGeneratorFactory().iam().getInternalCrnForServiceAsString(), () -> operationPollerObject.getOperationV1Endpoint().getOperationStatus(operationPollerObject.getOperationId(), operationPollerObject.getAccountId()));
LOGGER.debug("OperationStatus for operationId[{}]: {}", operationPollerObject.getOperationId(), operationStatus);
if (OperationState.COMPLETED.equals(operationStatus.getStatus())) {
return true;
} else if (OperationState.RUNNING.equals(operationStatus.getStatus())) {
return false;
} else {
String failureDetails = extractFailureDetails(operationStatus);
throw new FreeIpaOperationFailedException(String.format("FreeIPA [%s] operation [%s] failed with state [%s] and error message [%s]. " + "Failure details: [%s]", operationStatus.getOperationType(), operationPollerObject.getOperationId(), operationStatus.getStatus(), operationStatus.getError(), failureDetails));
}
}
use of com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method cleanUp.
private void cleanUp(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
CleanupRequest cleanupRequest = new CleanupRequest();
cleanupRequest.setEnvironmentCrn(environmentCrn);
cleanupRequest.setClusterName("testuser");
cleanupRequest.setUsers(Set.of("kerberosbind-testuser", "ldapbind-testuser"));
OperationStatus operationStatus = ipaClient.getFreeIpaV1Endpoint().cleanup(cleanupRequest);
waitToCompleted(testContext, operationStatus.getOperationId(), "cleanupOperation");
} catch (Exception e) {
logger.error("CLEANUP test failed during upgrade", e);
// throw new TestFailException("CLEANUP test failed during upgrade with: " + e.getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus in project cloudbreak by hortonworks.
the class StartBindUserCreationServiceTest method testOperationRejected.
@Test
public void testOperationRejected() {
OperationStatus operationStatus = new OperationStatus(OPERATION_ID, OperationType.BIND_USER_CREATE, OperationState.REJECTED, List.of(), List.of(), "errMsg", 1L, 2L);
when(freeIpaV1Endpoint.createBindUser(any(BindUserCreateRequest.class), anyString())).thenReturn(operationStatus);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
assertThrows(RetryException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.startBindUserCreation(stackView)));
}
Aggregations