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);
}
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();
}
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();
}
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));
}
Aggregations