use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaConfigProviderTest method testPgwNotChosenIfNotCreated.
@Test
public void testPgwNotChosenIfNotCreated() {
DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
InstanceMetaDataResponse pgw = createInstanceMetadata("d", TERMINATED);
pgw.setInstanceType(InstanceMetadataType.GATEWAY_PRIMARY);
instanceGroupResponse.setMetaData(Set.of(createInstanceMetadata("b", TERMINATED), createInstanceMetadata("a", REQUESTED), createInstanceMetadata("f", CREATED), pgw, createInstanceMetadata("c", CREATED)));
freeIpaResponse.setInstanceGroups(List.of(instanceGroupResponse));
when(freeipaClient.findByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(Optional.of(freeIpaResponse));
Map<String, Object> result = underTest.createFreeIpaConfig(ENVIRONMENT_CRN);
assertEquals(1, result.size());
assertEquals("c", result.get("host"));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaConfigProviderTest method testNoChoosenIfInsanceMetadataEmpty.
@Test
public void testNoChoosenIfInsanceMetadataEmpty() {
DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
instanceGroupResponse.setMetaData(Set.of());
freeIpaResponse.setInstanceGroups(List.of(instanceGroupResponse));
when(freeipaClient.findByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(Optional.of(freeIpaResponse));
Map<String, Object> result = underTest.createFreeIpaConfig(ENVIRONMENT_CRN);
assertTrue(result.isEmpty());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaUnknownThenThrowsException.
@ParameterizedTest
@EnumSource(value = Status.class)
void testCheckFreeipaRunningWhenFreeIpaUnknownThenThrowsException(Status status) {
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setStatus(status);
freeipa.setAvailabilityStatus(AvailabilityStatus.UNKNOWN);
when(freeipaClientService.getByEnvironmentCrn(ENV_CRN)).thenReturn(freeipa);
CloudbreakServiceException exception = Assertions.assertThrows(CloudbreakServiceException.class, () -> underTest.checkFreeipaRunning(ENV_CRN));
assertEquals("Freeipa availability cannot be determined currently.", exception.getMessage());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaDeletionRetrievalTask method checkStatus.
@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
try {
LOGGER.info("Checking the state of FreeIpa termination progress for environment: '{}'", environmentCrn);
Optional<DescribeFreeIpaResponse> freeIpaResponse = freeIpaService.describe(environmentCrn);
if (freeIpaResponse.isPresent()) {
if (freeIpaResponse.get().getStatus() == Status.DELETE_FAILED) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed: " + freeIpaResponse.get().getStatusReason());
}
if (!freeIpaResponse.get().getStatus().isSuccessfullyDeleted()) {
return false;
}
} else {
LOGGER.info("FreeIpa was not found.");
return true;
}
} catch (Exception e) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed. " + e.getMessage(), e);
}
return true;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method testRebuild.
@Test
public void testRebuild() throws Exception {
Stack stack = createStack(Status.DELETE_COMPLETED, List.of(InstanceStatus.TERMINATED, InstanceStatus.TERMINATED), 2);
CreateFreeIpaRequest createFreeIpaRequest = new CreateFreeIpaRequest();
DescribeFreeIpaResponse response = new DescribeFreeIpaResponse();
when(stackService.getByCrnAndAccountIdEvenIfTerminated(ENVIRONMENT_ID1, ACCOUNT_ID, FREEIPA_CRN)).thenReturn(stack);
when(stackService.findByEnvironmentCrnAndAccountId(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(Optional.empty());
when(stackToCreateFreeIpaRequestConverter.convert(eq(stack))).thenReturn(createFreeIpaRequest);
when(freeIpaCreationService.launchFreeIpa(eq(createFreeIpaRequest), eq(ACCOUNT_ID))).thenReturn(response);
when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
RebuildRequest rebuildRequest = new RebuildRequest();
rebuildRequest.setEnvironmentCrn(ENVIRONMENT_ID1);
rebuildRequest.setSourceCrn(FREEIPA_CRN);
assertEquals(response, underTest.rebuild(ACCOUNT_ID, rebuildRequest));
}
Aggregations