use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverter method convert.
private AwsEncryptionV4Parameters convert(AwsEncryptionV1Parameters source, DetailedEnvironmentResponse environment) {
AwsEncryptionV4Parameters response = new AwsEncryptionV4Parameters();
String dataHubEncryptionKey = source.getKey();
EncryptionType dataHubEncryptionKeyType = source.getType();
if (EncryptionType.CUSTOM.equals(dataHubEncryptionKeyType)) {
response.setKey(dataHubEncryptionKey);
response.setType(dataHubEncryptionKeyType);
} else {
String environmentEncryptionKeyArn = Optional.ofNullable(environment).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
if (environmentEncryptionKeyArn != null && !environmentEncryptionKeyArn.isEmpty()) {
response.setKey(environmentEncryptionKeyArn);
response.setType(EncryptionType.CUSTOM);
} else {
response.setType(EncryptionType.DEFAULT);
}
}
return response;
}
use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.
the class StackValidator method validateEncryptionKey.
private void validateEncryptionKey(Stack stack, ValidationResultBuilder validationBuilder) {
if (StringUtils.isEmpty(stack.getEnvironmentCrn())) {
validationBuilder.error("Environment CRN cannot be null or empty.");
return;
}
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
stack.getInstanceGroups().stream().filter(request -> isEncryptionTypeSetUp(request.getTemplate())).filter(request -> {
EncryptionType valueForTypeKey = getEncryptionType(request.getTemplate());
return EncryptionType.CUSTOM.equals(valueForTypeKey);
}).forEach(request -> {
checkEncryptionKeyValidityForInstanceGroupWhenKeysAreListable(request, environment.getCrn(), stack.getRegion(), validationBuilder);
});
}
use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.
the class AwsInstanceTemplateV4Parameters method asMap.
@Override
public Map<String, Object> asMap() {
Map<String, Object> map = super.asMap();
doIfNotNull(spot, sp -> {
putIfValueNotNull(map, AwsInstanceTemplate.EC2_SPOT_PERCENTAGE, sp.getPercentage());
putIfValueNotNull(map, AwsInstanceTemplate.EC2_SPOT_MAX_PRICE, sp.getMaxPrice());
});
if (encryption != null) {
EncryptionType encryptionType = encryption.getType();
putIfValueNotNull(map, InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, encryptionType);
putIfValueNotNull(map, AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, encryptionType != null && encryptionType != EncryptionType.NONE);
}
putIfValueNotNull(map, AwsInstanceTemplate.PLACEMENT_GROUP_STRATEGY, Optional.ofNullable(placementGroup).map(AwsPlacementGroupV4Parameters::getStrategy).orElse(AwsPlacementGroupStrategy.NONE).name());
return map;
}
Aggregations