Search in sources :

Example 1 with UserSyncState

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()));
}
Also used : EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) ResourceCrn(com.sequenceiq.authorization.annotation.ResourceCrn) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 2 with UserSyncState

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));
}
Also used : SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) UserV1Endpoint(com.sequenceiq.freeipa.api.v1.freeipa.user.UserV1Endpoint)

Example 3 with UserSyncState

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;
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) UserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState)

Aggregations

EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)3 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 UserV1Endpoint (com.sequenceiq.freeipa.api.v1.freeipa.user.UserV1Endpoint)1 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)1 UserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState)1 Operation (com.sequenceiq.freeipa.entity.Operation)1