use of com.sequenceiq.cloudbreak.saas.sdx.status.StatusCheckResult 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.");
}
}
Aggregations