use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class DistroXService method validate.
private void validate(DistroXV1Request request) {
DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(request.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
if (environment == null) {
throw new BadRequestException(format("'%s' Environment does not exist.", request.getEnvironmentName()));
}
DescribeFreeIpaResponse freeipa = freeipaClientService.getByEnvironmentCrn(environment.getCrn());
if (freeipa == null || freeipa.getAvailabilityStatus() == null || !freeipa.getAvailabilityStatus().isAvailable()) {
throw new BadRequestException(format("If you want to provision a Data Hub then the FreeIPA instance must be running in the '%s' Environment.", environment.getName()));
}
Set<String> sdxCrns = platformAwareSdxConnector.listSdxCrns(environment.getName(), environment.getCrn());
if (sdxCrns.isEmpty()) {
throw new BadRequestException(format("Data Lake stack cannot be found for environment CRN: %s (%s)", environment.getName(), environment.getCrn()));
}
Set<Pair<String, StatusCheckResult>> sdxCrnsWithAvailability = platformAwareSdxConnector.listSdxCrnsWithAvailability(environment.getName(), environment.getCrn(), sdxCrns);
if (!sdxCrnsWithAvailability.stream().map(Pair::getValue).allMatch(statusCheckResult -> StatusCheckResult.AVAILABLE.equals(statusCheckResult))) {
throw new BadRequestException("Data Lake stacks of environment should be available.");
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class StackToDescribeFreeIpaResponseConverter method convert.
public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, Optional<UserSyncStatus> userSyncStatus, Boolean includeAllInstances) {
DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse();
describeFreeIpaResponse.setName(stack.getName());
describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn());
describeFreeIpaResponse.setCrn(stack.getResourceCrn());
describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform());
describeFreeIpaResponse.setVariant(stack.getPlatformvariant());
describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication()));
Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i)));
Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f)));
describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack));
describeFreeIpaResponse.setPlacement(convertToPlacementResponse(stack));
describeFreeIpaResponse.setTunnel(stack.getTunnel());
describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups(), includeAllInstances));
describeFreeIpaResponse.setAvailabilityStatus(stackToAvailabilityStatusConverter.convert(stack));
describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus());
describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString());
describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason());
decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups());
decorateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa);
describeFreeIpaResponse.setAppVersion(stack.getAppVersion());
decorateWithCloudStorageAndTelemetry(stack, describeFreeIpaResponse);
userSyncStatus.ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u)));
return describeFreeIpaResponse;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class EnvironmentStatusTest method setFreeIpaStatus.
private void setFreeIpaStatus(Status freeIpaStatus) {
DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
freeIpaResponse.setStatus(freeIpaStatus);
when(freeIpaService.internalDescribe(environment.getResourceCrn(), environment.getAccountId())).thenReturn(Optional.of(freeIpaResponse));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaPollerServiceTest method testStartAttachedFreeipaInstancesWhenFreeipaStopped.
@Test
void testStartAttachedFreeipaInstancesWhenFreeipaStopped() {
DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
freeipaResponse.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
freeipaResponse.setStatus(Status.STOPPED);
when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
when(freeipaPollerProvider.startPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish);
underTest.startAttachedFreeipaInstances(ENV_ID, ENV_CRN);
verify(freeIpaService, times(1)).startFreeIpa(ENV_CRN);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaPollerServiceTest method testSyncUsersWhenFreeIpaAvailable.
@Test
void testSyncUsersWhenFreeIpaAvailable() {
DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
freeipaResponse.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
freeipaResponse.setStatus(Status.AVAILABLE);
when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
when(freeIpaService.synchronizeAllUsersInEnvironment(ENV_CRN)).thenReturn(createStatus(SynchronizationStatus.REQUESTED, ""));
when(freeipaPollerProvider.syncUsersPoller(ENV_ID, ENV_CRN, OPERATION)).thenReturn(AttemptResults::justFinish);
underTest.waitForSynchronizeUsers(ENV_ID, ENV_CRN);
verify(freeIpaService, times(1)).synchronizeAllUsersInEnvironment(ENV_CRN);
}
Aggregations