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());
}
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);
}
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);
}
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);
}
}
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);
}
}
}
Aggregations