Search in sources :

Example 21 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class FreeIpaConverter method convert.

public FreeIpaCreationDto convert(AttachedFreeIpaRequest request, String accountId, String cloudPlatform) {
    FreeIpaCreationDto.Builder builder = FreeIpaCreationDto.builder();
    if (request != null) {
        builder.withCreate(request.getCreate());
        builder.withEnableMultiAz(request.isEnableMultiAz());
        if (request.isEnableMultiAz()) {
            if (!cloudPlatform.equalsIgnoreCase(CloudConstants.AWS)) {
                throw new BadRequestException("You need to provision AWS environment to use Multi Availability Zone.");
            }
            if (!entitlementService.awsNativeFreeIpaEnabled(accountId)) {
                throw new BadRequestException("You need to be entitled for CDP_CB_AWS_NATIVE_FREEIPA to provision FreeIPA in Multi Availability Zone.");
            }
        }
        Optional.ofNullable(request.getInstanceCountByGroup()).ifPresent(builder::withInstanceCountByGroup);
        Optional.ofNullable(request.getInstanceType()).ifPresent(builder::withInstanceType);
        Optional.ofNullable(request.getAws()).map(AwsFreeIpaParameters::getSpot).ifPresent(spotParameters -> builder.withAws(FreeIpaCreationAwsParametersDto.builder().withSpot(FreeIpaCreationAwsSpotParametersDto.builder().withPercentage(spotParameters.getPercentage()).withMaxPrice(spotParameters.getMaxPrice()).build()).build()));
        FreeIpaImageRequest image = request.getImage();
        if (image != null) {
            builder.withImageCatalog(image.getCatalog());
            builder.withImageId(image.getId());
        }
    }
    return builder.build();
}
Also used : FreeIpaImageRequest(com.sequenceiq.environment.api.v1.environment.model.request.FreeIpaImageRequest) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Aggregations

FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)21 Test (org.junit.jupiter.api.Test)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Features (com.sequenceiq.common.api.telemetry.model.Features)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)7 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)7 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)7 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)6 AttachedFreeIpaRequest (com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest)4 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)4 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 FreeIpaImageRequest (com.sequenceiq.environment.api.v1.environment.model.request.FreeIpaImageRequest)1 FreeIpaCreationAwsParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto)1 FreeIpaCreationAwsSpotParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto)1 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)1