use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class OperationService method getOperationForAccountIdAndOperationId.
public Operation getOperationForAccountIdAndOperationId(String accountId, String operationId) {
Optional<Operation> operationOptional = operationRepository.findByOperationIdAndAccountId(operationId, accountId);
if (!operationOptional.isPresent()) {
LOGGER.info("Operation [{}] in account [{}] not found", operationId, accountId);
throw NotFoundException.notFound("Operation", operationId).get();
} else {
Operation operation = operationOptional.get();
LOGGER.debug("Operation found: {}", operation);
return operation;
}
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class OperationService method startOperation.
public Operation startOperation(String accountId, OperationType operationType, Collection<String> environmentCrns, Collection<String> userCrns) {
Operation requestedOperation = requestOperation(accountId, operationType, environmentCrns, userCrns);
OperationAcceptor acceptor = operationAcceptorMap.get(operationType);
AcceptResult acceptResult = acceptor.accept(requestedOperation);
if (acceptResult.isAccepted()) {
return acceptOperation(requestedOperation);
} else {
return rejectOperation(requestedOperation, acceptResult.getRejectionMessage().orElse("Rejected for unspecified reason."));
}
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserSyncService method performSyncForStacks.
private Operation performSyncForStacks(String accountId, UserSyncRequestFilter userSyncFilter, UserSyncOptions options, List<Stack> stacks) {
logAffectedStacks(stacks);
Set<String> environmentCrns = stacks.stream().map(Stack::getEnvironmentCrn).collect(Collectors.toSet());
Operation operation = operationService.startOperation(accountId, OperationType.USER_SYNC, environmentCrns, union(userSyncFilter.getUserCrnFilter(), userSyncFilter.getMachineUserCrnFilter()));
LOGGER.info("Starting operation [{}] with status [{}]", operation.getOperationId(), operation.getStatus());
if (operation.getStatus() == OperationState.RUNNING) {
operationService.tryWithOperationCleanup(operation.getOperationId(), accountId, () -> ThreadBasedUserCrnProvider.doAs(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> {
if (userSyncFilter.isFullSync()) {
stacks.forEach(stack -> updateUserSyncStatusForStack(operation, stack));
}
asyncSynchronizeUsers(operation.getOperationId(), accountId, stacks, userSyncFilter, options);
}));
}
return operation;
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class EnvironmentUserSyncStateCalculator method createExceptionForUnexpectedOperationStatus.
private IllegalStateException createExceptionForUnexpectedOperationStatus(String envCrnString, UserSyncStatus userSyncStatus) {
Operation lastSync = userSyncStatus.getLastStartedFullSync();
LOGGER.error("UserSyncStatus.lastStartedFullSync '{}' in unexpected state {} for environment '{}'", lastSync, lastSync.getStatus(), envCrnString);
return new IllegalStateException(String.format("Last sync operation [%s] for environment '%s' is in unexpected state %s", lastSync.getOperationId(), envCrnString, lastSync.getStatus()));
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateService method createBindUser.
public OperationStatus createBindUser(String accountId, BindUserCreateRequest request) {
Stack stack = stackService.getByEnvironmentCrnAndAccountId(request.getEnvironmentCrn(), accountId);
MDCBuilder.buildMdcContext(stack);
LOGGER.info("Start 'BIND_USER_CREATE' operation from request: {}", request);
Operation operation = operationService.startOperation(accountId, OperationType.BIND_USER_CREATE, List.of(request.getEnvironmentCrn()), List.of(request.getBindUserNameSuffix()));
if (RUNNING == operation.getStatus()) {
return operationConverter.convert(startCreateBindUserFLow(accountId, request, stack.getId(), operation));
} else {
LOGGER.info("Operation isn't in RUNNING state: {}", operation);
return operationConverter.convert(operation);
}
}
Aggregations