Search in sources :

Example 26 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaDescribeService method describe.

public DescribeFreeIpaResponse describe(String environmentCrn, String accountId) {
    Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithLists(environmentCrn, accountId);
    DescribeFreeIpaResponse response = getResponseForStack(stack, false);
    LOGGER.trace("FreeIPA describe response: {}", response);
    return response;
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 27 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaStatusIsNullThenThrowsException.

@Test
void testCheckFreeipaRunningWhenFreeIpaStatusIsNullThenThrowsException() {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    when(underTest.describe(ENV_CRN)).thenReturn(freeipa);
    ServiceUnavailableException exception = Assertions.assertThrows(ServiceUnavailableException.class, () -> underTest.checkFreeipaRunning(ENV_CRN));
    assertEquals("Freeipa availability cannot be determined currently.", exception.getMessage());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) ServiceUnavailableException(javax.ws.rs.ServiceUnavailableException) Test(org.junit.jupiter.api.Test)

Example 28 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaAvailableThenPass.

@Test
void testCheckFreeipaRunningWhenFreeIpaAvailableThenPass() {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(Status.AVAILABLE);
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    when(underTest.describe(ENV_CRN)).thenReturn(freeipa);
    Assertions.assertDoesNotThrow(() -> underTest.checkFreeipaRunning(ENV_CRN));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 29 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaStoppedThenThrowsException.

@Test
void testCheckFreeipaRunningWhenFreeIpaStoppedThenThrowsException() {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(Status.STOPPED);
    freeipa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    when(underTest.describe(ENV_CRN)).thenReturn(freeipa);
    BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.checkFreeipaRunning(ENV_CRN));
    assertEquals("Freeipa should be in Available state but currently is " + Status.STOPPED, exception.getMessage());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 30 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaService method checkFreeipaRunning.

public void checkFreeipaRunning(String envCrn) {
    DescribeFreeIpaResponse freeipa = describe(envCrn);
    if (freeipa != null && freeipa.getAvailabilityStatus() != null) {
        if (!freeipa.getAvailabilityStatus().isAvailable()) {
            String message = "Freeipa should be in Available state but currently is " + freeipa.getStatus().name();
            LOGGER.info(message);
            throw new BadRequestException(message);
        }
    } else {
        String message = "Freeipa availability cannot be determined currently.";
        LOGGER.warn(message);
        throw new ServiceUnavailableException(message);
    }
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ServiceUnavailableException(javax.ws.rs.ServiceUnavailableException)

Aggregations

DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)60 Test (org.junit.jupiter.api.Test)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)8 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)7 InstanceGroupResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)6 AttemptResults (com.dyngr.core.AttemptResults)5 Stack (com.sequenceiq.freeipa.entity.Stack)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)3 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)3 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)3 InstanceMetaDataResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse)3 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 Environment (com.sequenceiq.environment.environment.domain.Environment)2