Search in sources :

Example 46 with DescribeFreeIpaResponse

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

the class DistroXServiceTest method testIfDlIsRunning.

@Test
public void testIfDlIsRunning() {
    String envName = "someAwesomeEnvironment";
    DistroXV1Request request = new DistroXV1Request();
    request.setEnvironmentName(envName);
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setEnvironmentStatus(AVAILABLE);
    envResponse.setCrn("crn");
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
    when(environmentClientService.getByName(envName)).thenReturn(envResponse);
    when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
    when(platformAwareSdxConnector.listSdxCrnsWithAvailability(any(), any(), any())).thenReturn(Set.of(Pair.of(DATALAKE_CRN, StatusCheckResult.AVAILABLE)));
    underTest.post(request);
    verify(platformAwareSdxConnector).listSdxCrns(any(), any());
    verify(platformAwareSdxConnector).listSdxCrnsWithAvailability(any(), any(), any());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 47 with DescribeFreeIpaResponse

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

the class DistroXServiceTest method testIfDlIsNotExists.

@Test
public void testIfDlIsNotExists() {
    String envName = "someAwesomeEnvironment";
    DistroXV1Request request = new DistroXV1Request();
    request.setEnvironmentName(envName);
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setEnvironmentStatus(AVAILABLE);
    envResponse.setCrn("crn");
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
    when(environmentClientService.getByName(envName)).thenReturn(envResponse);
    when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of());
    assertThrows(BadRequestException.class, () -> underTest.post(request));
    verify(platformAwareSdxConnector).listSdxCrns(any(), any());
    verifyNoMoreInteractions(platformAwareSdxConnector);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with DescribeFreeIpaResponse

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

the class DistroXServiceTest method testWhenEnvExistsAndItIsAvailable.

@Test
@DisplayName("When the environment that has the given name is exist and also in the state AVAILABLE then no exception should come")
void testWhenEnvExistsAndItIsAvailable() throws IllegalAccessException {
    String envName = "someAwesomeEnvironment";
    DistroXV1Request r = new DistroXV1Request();
    r.setEnvironmentName(envName);
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setEnvironmentStatus(AVAILABLE);
    envResponse.setCrn("crn");
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
    when(environmentClientService.getByName(envName)).thenReturn(envResponse);
    StackV4Request converted = new StackV4Request();
    CloudbreakUser cloudbreakUser = mock(CloudbreakUser.class);
    when(stackRequestConverter.convert(r)).thenReturn(converted);
    when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
    when(restRequestThreadLocalService.getCloudbreakUser()).thenReturn(cloudbreakUser);
    underTest.post(r);
    verify(environmentClientService, calledOnce()).getByName(any());
    verify(environmentClientService, calledOnce()).getByName(envName);
    verify(stackOperations, calledOnce()).post(any(), any(), any(), anyBoolean());
    verify(stackOperations, calledOnce()).post(eq(USER_ID), eq(cloudbreakUser), eq(converted), eq(true));
    verify(workspaceService, calledOnce()).getForCurrentUser();
    verify(stackRequestConverter, calledOnce()).convert(any(DistroXV1Request.class));
    verify(stackRequestConverter, calledOnce()).convert(r);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 49 with DescribeFreeIpaResponse

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

the class FreeIpaDeletionRetrievalTask method handleTimeout.

@Override
public void handleTimeout(FreeIpaPollerObject freeIpaPollerObject) {
    try {
        String envCrn = freeIpaPollerObject.getEnvironmentCrn();
        Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(envCrn);
        if (freeIpa.isEmpty()) {
            throw new FreeIpaOperationFailedException("FreeIpa was not found for environment: " + envCrn);
        }
        throw new FreeIpaOperationFailedException(String.format("Polling operation timed out, FreeIpa deletion failed. FreeIpa status: '%s' " + "statusReason: '%s'", freeIpa.get().getStatus(), freeIpa.get().getStatusReason()));
    } catch (Exception e) {
        throw new FreeIpaOperationFailedException("Polling operation timed out, FreeIpa deletion failed. Also failed to get FreeIpa status: " + e.getMessage(), e);
    }
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException)

Example 50 with DescribeFreeIpaResponse

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

the class FreeIpaCreationHandler method attachParentFreeIpa.

private void attachParentFreeIpa(EnvironmentDto environmentDto) throws Exception {
    if (enabledChildPlatforms.stream().anyMatch(p -> p.equalsIgnoreCase(environmentDto.getCloudPlatform()))) {
        String parentEnvironmentCrn = environmentDto.getParentEnvironmentCrn();
        Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(parentEnvironmentCrn);
        if (freeIpa.isPresent()) {
            LOGGER.info("Using FreeIpa of parent environment '{}' .", parentEnvironmentCrn);
            AttachChildEnvironmentRequest attachChildEnvironmentRequest = new AttachChildEnvironmentRequest();
            attachChildEnvironmentRequest.setChildEnvironmentCrn(environmentDto.getResourceCrn());
            attachChildEnvironmentRequest.setParentEnvironmentCrn(parentEnvironmentCrn);
            freeIpaService.attachChildEnvironment(attachChildEnvironmentRequest);
            AddDnsZoneForSubnetsRequest addDnsZoneForSubnetsRequest = new AddDnsZoneForSubnetsRequest();
            addDnsZoneForSubnetsRequest.setEnvironmentCrn(parentEnvironmentCrn);
            addDnsZoneForSubnetsRequest.setSubnets(getSubnetCidrs(environmentDto));
            dnsV1Endpoint.addDnsZoneForSubnets(addDnsZoneForSubnetsRequest);
        }
    }
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) AddDnsZoneForSubnetsRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetsRequest) AttachChildEnvironmentRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest)

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