Search in sources :

Example 1 with AwsDiskEncryptionParametersDto

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

the class UpdateAwsDiskEncryptionParametersDtoTest method builderTest.

@Test
void builderTest() {
    AwsDiskEncryptionParametersDto awsDiskEncryptionParametersDto = AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build();
    UpdateAwsDiskEncryptionParametersDto underTest = UpdateAwsDiskEncryptionParametersDto.builder().withAwsDiskEncryptionParametersDto(awsDiskEncryptionParametersDto).build();
    assertThat(underTest.getAwsDiskEncryptionParametersDto()).isEqualTo(awsDiskEncryptionParametersDto);
}
Also used : AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) Test(org.junit.jupiter.api.Test)

Example 2 with AwsDiskEncryptionParametersDto

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

the class EnvironmentDetailsToCDPEnvironmentDetailsConverter method convertAwsDetails.

private UsageProto.CDPEnvironmentAwsDetails convertAwsDetails(ParametersDto parametersDto) {
    UsageProto.CDPEnvironmentAwsDetails.Builder builder = UsageProto.CDPEnvironmentAwsDetails.newBuilder();
    if (parametersDto != null) {
        AwsParametersDto awsParametersDto = parametersDto.getAwsParametersDto();
        if (awsParametersDto != null) {
            Optional<String> encryptionKeyArn = Optional.of(awsParametersDto).map(AwsParametersDto::getAwsDiskEncryptionParametersDto).map(AwsDiskEncryptionParametersDto::getEncryptionKeyArn);
            builder.setResourceEncryptionEnabled(encryptionKeyArn.isPresent());
        }
    }
    return builder.build();
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto)

Example 3 with AwsDiskEncryptionParametersDto

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

the class AwsParameterValidator method validate.

@Override
public ValidationResult validate(EnvironmentValidationDto environmentValidationDto, ParametersDto parametersDto, ValidationResultBuilder validationResultBuilder) {
    EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
    LOGGER.debug("ParametersDto: {}", parametersDto);
    AwsParametersDto awsParametersDto = parametersDto.getAwsParametersDto();
    if (Objects.isNull(awsParametersDto)) {
        LOGGER.debug("No aws parameters defined.");
        return validationResultBuilder.build();
    }
    // This flag is introduced to skip S3Guard Table validation in case of UpdateAwsDiskEncryptionParameters call.
    boolean validateOnlyAwsEncryptionParameters = validateOnlyAwsEncryptionParameters(environmentDto);
    if (Objects.isNull(awsParametersDto.getAwsDiskEncryptionParametersDto()) && !validateOnlyAwsEncryptionParameters) {
        if (StringUtils.isNotBlank(awsParametersDto.getS3GuardTableName())) {
            LOGGER.debug("S3Guard table name defined: {}", awsParametersDto.getS3GuardTableName());
            boolean tableAlreadyAttached = isTableAlreadyAttached(environmentDto, awsParametersDto);
            if (tableAlreadyAttached) {
                validationResultBuilder.error(String.format("S3Guard Dynamo table '%s' is already attached to another active environment. " + "Please select another unattached table or specify a non-existing name to create it. " + "Refer to Cloudera documentation at %s for the required setup.", awsParametersDto.getS3GuardTableName(), DocumentationLinkProvider.awsDynamoDbSetupLink()));
            } else {
                determineAwsParameters(environmentDto, parametersDto);
            }
        }
    }
    AwsDiskEncryptionParametersDto awsDiskEncryptionParametersDto = awsParametersDto.getAwsDiskEncryptionParametersDto();
    if (awsDiskEncryptionParametersDto != null) {
        ValidationResult validationResult = validateEntitlement(validationResultBuilder, awsDiskEncryptionParametersDto, environmentDto.getAccountId());
        if (validationResult.hasError()) {
            return validationResult;
        }
    }
    if (awsParametersDto.getFreeIpaSpotPercentage() < PERCENTAGE_MIN || awsParametersDto.getFreeIpaSpotPercentage() > PERCENTAGE_MAX) {
        validationResultBuilder.error(String.format("FreeIpa spot percentage must be between %d and %d.", PERCENTAGE_MIN, PERCENTAGE_MAX));
    }
    return validationResultBuilder.build();
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 4 with AwsDiskEncryptionParametersDto

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

the class AwsEnvironmentParametersConverter method postConvert.

@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
    super.postConvert(baseParameters, environment, parametersDto);
    AwsParameters awsParameters = (AwsParameters) baseParameters;
    Optional<AwsParametersDto> awsParametersDto = Optional.of(parametersDto).map(ParametersDto::getAwsParametersDto);
    awsParameters.setS3guardTableName(awsParametersDto.map(AwsParametersDto::getS3GuardTableName).orElse(null));
    awsParameters.setS3guardTableCreation(awsParametersDto.map(AwsParametersDto::getDynamoDbTableCreation).orElse(null));
    awsParameters.setFreeIpaSpotPercentage(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotPercentage).orElse(0));
    awsParameters.setFreeIpaSpotMaxPrice(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotMaxPrice).orElse(null));
    awsParameters.setEncryptionKeyArn(awsParametersDto.map(AwsParametersDto::getAwsDiskEncryptionParametersDto).map(AwsDiskEncryptionParametersDto::getEncryptionKeyArn).orElse(null));
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto)

Aggregations

AwsDiskEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto)4 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)3 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)1 AwsParameters (com.sequenceiq.environment.parameters.dao.domain.AwsParameters)1 Test (org.junit.jupiter.api.Test)1