use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaDescribeServiceTest method describeAll.
@Test
void describeAll() {
DescribeFreeIpaResponse describeResponse = mock(DescribeFreeIpaResponse.class);
ImageEntity image = mock(ImageEntity.class);
FreeIpa freeIpa = mock(FreeIpa.class);
UserSyncStatus userSyncStatus = mock(UserSyncStatus.class);
when(stackService.findMultipleByEnvironmentCrnAndAccountIdEvenIfTerminatedWithList(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID))).thenReturn(Collections.singletonList(stack));
when(imageService.getByStack(any())).thenReturn(image);
when(freeIpaService.findByStackId(any())).thenReturn(freeIpa);
when(userSyncStatusService.findByStack(any())).thenReturn(Optional.of(userSyncStatus));
when(stackToDescribeFreeIpaResponseConverter.convert(any(), any(), any(), any(), any())).thenReturn(describeResponse);
when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
assertEquals(List.of(describeResponse), underTest.describeAll(ENVIRONMENT_CRN, ACCOUNT_ID));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class DistroXServiceTest method testIfDlIsNotRunning.
@Test
public void testIfDlIsNotRunning() {
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.NOT_AVAILABLE)));
assertThrows(BadRequestException.class, () -> 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 testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException.
@Test
void testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException() throws IllegalAccessException {
String envName = "someAwesomeEnvironment";
DistroXV1Request request = new DistroXV1Request();
request.setEnvironmentName(envName);
DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
envResponse.setEnvironmentStatus(START_DATAHUB_STARTED);
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));
underTest.post(request);
verify(platformAwareSdxConnector).listSdxCrns(any(), any());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method createFreeIpa.
private void createFreeIpa(Event<EnvironmentDto> environmentDtoEvent, EnvironmentDto environmentDto) throws Exception {
Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(environmentDto.getResourceCrn());
if (freeIpa.isEmpty()) {
LOGGER.info("FreeIpa for environmentCrn '{}' was not found, creating a new one.", environmentDto.getResourceCrn());
CreateFreeIpaRequest createFreeIpaRequest = createFreeIpaRequest(environmentDto);
freeIpaService.create(createFreeIpaRequest);
awaitFreeIpaCreation(environmentDtoEvent, environmentDto);
AddDnsZoneForSubnetIdsRequest addDnsZoneForSubnetIdsRequest = addDnsZoneForSubnetIdsRequest(environmentDto);
if (shouldSendSubnetIdsToFreeIpa(addDnsZoneForSubnetIdsRequest)) {
dnsV1Endpoint.addDnsZoneForSubnetIds(addDnsZoneForSubnetIdsRequest);
}
} else {
LOGGER.info("FreeIpa for environmentCrn '{}' already exists. Using this one.", environmentDto.getResourceCrn());
if (CREATE_IN_PROGRESS == freeIpa.get().getStatus()) {
awaitFreeIpaCreation(environmentDtoEvent, environmentDto);
}
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaCreationRetrievalTask method checkStatus.
@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
try {
LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn);
Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn);
if (freeIpaOptional.isEmpty()) {
throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn);
}
DescribeFreeIpaResponse freeIpa = freeIpaOptional.get();
if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) {
LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process.");
}
if (freeIpa.getStatus().isFailed()) {
LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
throw new FreeIpaOperationFailedException(String.format("Reason: '%s'", freeIpa.getStatusReason()));
}
if (freeIpa.getAvailabilityStatus() != null && freeIpa.getAvailabilityStatus().isAvailable()) {
return true;
}
} catch (Exception e) {
throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e);
}
return false;
}
Aggregations