use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState in project cloudbreak by hortonworks.
the class UserV1Controller method getLastSyncOperationStatus.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.GET_OPERATION_STATUS)
public SyncOperationStatus getLastSyncOperationStatus(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn) {
Crn envCrn = Crn.safeFromString(environmentCrn);
EnvironmentUserSyncState userSyncState = environmentUserSyncStateCalculator.calculateEnvironmentUserSyncState(envCrn.getAccountId(), envCrn);
return operationToSyncOperationStatus.convert(operationService.getOperationForAccountIdAndOperationId(envCrn.getAccountId(), userSyncState.getLastUserSyncOperationId()));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState in project cloudbreak by hortonworks.
the class AwsYcloudHybridCloudTest method checkUserSyncState.
private void checkUserSyncState(String environmentCrn, com.sequenceiq.freeipa.api.client.FreeIpaClient freeIpaClient) throws JsonProcessingException {
UserV1Endpoint userV1Endpoint = freeIpaClient.getUserV1Endpoint();
EnvironmentUserSyncState userSyncState = userV1Endpoint.getUserSyncState(environmentCrn);
SyncOperationStatus syncOperationStatus = userV1Endpoint.getSyncOperationStatus(userSyncState.getLastUserSyncOperationId());
LOGGER.info("Last user sync is in state {}, last operation: {}", userSyncState.getState(), OBJECT_MAPPER.writeValueAsString(syncOperationStatus));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState in project cloudbreak by hortonworks.
the class EnvironmentUserSyncStateCalculator method calculateUserSyncState.
private UserSyncState calculateUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) {
Operation lastSync = userSyncStatus.getLastStartedFullSync();
UserSyncState state;
switch(lastSync.getStatus()) {
case RUNNING:
state = UserSyncState.SYNC_IN_PROGRESS;
break;
case COMPLETED:
state = calculateStateForCompletedOperation(accountId, envCrnString, userSyncStatus);
break;
case REQUESTED:
case REJECTED:
// REQUESTED or REJECTED operations will never be saved as part of the UserSyncStatus
throw createExceptionForUnexpectedOperationStatus(envCrnString, userSyncStatus);
case TIMEDOUT:
LOGGER.warn("UserSyncStatus.lastStartedFullSync '{}' is timed out for environment '{}'", lastSync.getOperationId(), envCrnString);
state = UserSyncState.SYNC_FAILED;
break;
case FAILED:
state = UserSyncState.SYNC_FAILED;
break;
default:
state = UserSyncState.STALE;
break;
}
return state;
}
Aggregations