use of com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentResponseConverter method azureEnvParamsToAzureEnvironmentParams.
private AzureEnvironmentParameters azureEnvParamsToAzureEnvironmentParams(ParametersDto parameters) {
AzureResourceGroupDto resourceGroupDto = Optional.ofNullable(parameters.getAzureParametersDto()).map(AzureParametersDto::getAzureResourceGroupDto).filter(rgDto -> Objects.nonNull(rgDto.getResourceGroupUsagePattern())).filter(rgDto -> Objects.nonNull(rgDto.getResourceGroupCreation())).orElse(null);
AzureResourceEncryptionParametersDto resourceEncryptionParametersDto = Optional.ofNullable(parameters.getAzureParametersDto()).map(AzureParametersDto::getAzureResourceEncryptionParametersDto).orElse(null);
return AzureEnvironmentParameters.builder().withAzureResourceGroup(getIfNotNull(resourceGroupDto, this::azureParametersToAzureResourceGroup)).withResourceEncryptionParameters(getIfNotNull(resourceEncryptionParametersDto, this::azureParametersToAzureResourceEncryptionParameters)).build();
}
use of com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto in project cloudbreak by hortonworks.
the class AzureParameterValidator method validateEncryptionParameters.
// CHECKSTYLE:ON
private ValidationResult validateEncryptionParameters(ValidationResultBuilder validationResultBuilder, AzureParametersDto azureParametersDto, String accountId) {
AzureResourceEncryptionParametersDto azureResourceEncryptionParametersDto = azureParametersDto.getAzureResourceEncryptionParametersDto();
String encryptionKeyUrl = azureResourceEncryptionParametersDto.getEncryptionKeyUrl();
String encryptionKeyResourceGroupName = azureResourceEncryptionParametersDto.getEncryptionKeyResourceGroupName();
if (encryptionKeyUrl != null) {
if (!entitlementService.isAzureDiskSSEWithCMKEnabled(accountId)) {
LOGGER.info("Invalid request, CDP_CB_AZURE_DISK_SSE_WITH_CMK entitlement turned off for account {}", accountId);
return validationResultBuilder.error("You specified encryptionKeyUrl to use Server Side Encryption for Azure Managed disks with CMK, " + "but that feature is currently disabled. Get 'CDP_CB_AZURE_DISK_SSE_WITH_CMK' enabled for your account to use SSE with CMK.").build();
}
if (encryptionKeyResourceGroupName == null && USE_MULTIPLE.equals(azureParametersDto.getAzureResourceGroupDto().getResourceGroupUsagePattern())) {
LOGGER.info("Invalid request, neither --encryption-key-resource-group-name nor --resource-group-name is present.");
return validationResultBuilder.error("To use Server Side Encryption for Azure Managed disks with CMK, at least one of --encryption-key-resource-group-name or " + "--resource-group-name should be specified. Please provide --resource-group-name, if encryption key is present in the same " + "resource group you wish to create the environment in, or provide --encryption-key-resource-group-name.").build();
}
}
if (encryptionKeyResourceGroupName != null) {
if (!entitlementService.isAzureDiskSSEWithCMKEnabled(accountId)) {
LOGGER.info("Invalid request, CDP_CB_AZURE_DISK_SSE_WITH_CMK entitlement turned off for account {}", accountId);
return validationResultBuilder.error("You specified encryptionKeyResourceGroupName to provide the resource group name which contains the encryption key" + "for Server Side Encryption of Azure Managed disks, but that feature is currently disabled. " + "Get 'CDP_CB_AZURE_DISK_SSE_WITH_CMK' enabled for your account to use SSE with CMK.").build();
}
if (encryptionKeyUrl == null) {
LOGGER.info("Invalid request, encryptionKeyResourceGroupName cannot be specified without encryptionKeyUrl");
return validationResultBuilder.error("You specified encryptionKeyResourceGroupName to provide the resource group name which contains the encryption key for " + "Server Side Encryption of Azure Managed disks. Please specify encryptionKeyUrl to use Server Side Encryption for " + "Azure Managed disks with CMK.").build();
}
}
String diskEncryptionSetId = azureResourceEncryptionParametersDto.getDiskEncryptionSetId();
if (diskEncryptionSetId != null) {
LOGGER.info("Invalid request, diskEncryptionSetId cannot be specified");
return validationResultBuilder.error("Specifying diskEncryptionSetId in request is Invalid. " + "Please specify encryptionKeyUrl to use Server Side Encryption for Azure Managed disks with CMK.").build();
}
LOGGER.debug("Validation of encryption parameters is successful.");
return validationResultBuilder.build();
}
use of com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto in project cloudbreak by hortonworks.
the class AzureParameterValidator method validate.
@Override
public ValidationResult validate(EnvironmentValidationDto environmentValidationDto, ParametersDto parametersDto, ValidationResultBuilder validationResultBuilder) {
EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
LOGGER.debug("ParametersDto: {}", parametersDto);
AzureParametersDto azureParametersDto = parametersDto.azureParametersDto();
if (Objects.isNull(azureParametersDto)) {
return validationResultBuilder.build();
}
ValidationResult validationResult;
AzureResourceEncryptionParametersDto azureResourceEncryptionParametersDto = azureParametersDto.getAzureResourceEncryptionParametersDto();
if (azureResourceEncryptionParametersDto != null) {
validationResult = validateEncryptionParameters(validationResultBuilder, azureParametersDto, environmentDto.getAccountId());
if (validationResult.hasError()) {
return validationResult;
}
}
AzureResourceGroupDto azureResourceGroupDto = azureParametersDto.getAzureResourceGroupDto();
if (Objects.isNull(azureResourceGroupDto)) {
return validationResultBuilder.build();
}
validationResult = validateEntitlement(validationResultBuilder, azureResourceGroupDto, environmentDto.getAccountId());
if (validationResult.hasError()) {
return validationResult;
}
if (USE_MULTIPLE.equals(azureResourceGroupDto.getResourceGroupUsagePattern())) {
return validateMultipleResourceGroupUsage(validationResultBuilder, azureResourceGroupDto);
}
if (USE_EXISTING.equals(azureResourceGroupDto.getResourceGroupCreation())) {
return validateExistingResourceGroupUsage(validationResultBuilder, environmentDto, azureResourceGroupDto);
}
return validationResultBuilder.build();
}
use of com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto in project cloudbreak by hortonworks.
the class AzureEnvironmentParametersConverter method postConvert.
@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
super.postConvert(baseParameters, environment, parametersDto);
AzureParameters azureParameters = (AzureParameters) baseParameters;
Optional<AzureParametersDto> azureParametersDto = Optional.of(parametersDto).map(ParametersDto::getAzureParametersDto);
azureParameters.setResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getName).orElse(null));
azureParameters.setResourceGroupCreation(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupCreation).orElse(null));
azureParameters.setResourceGroupUsagePattern(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupUsagePattern).orElse(null));
azureParameters.setEncryptionKeyUrl(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyUrl).orElse(null));
azureParameters.setEncryptionKeyResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyResourceGroupName).orElse(null));
}
use of com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPEnvironmentDetailsConverter method convertAzureDetails.
private UsageProto.CDPEnvironmentAzureDetails convertAzureDetails(ParametersDto parametersDto) {
UsageProto.CDPEnvironmentAzureDetails.Builder builder = UsageProto.CDPEnvironmentAzureDetails.newBuilder();
if (parametersDto != null) {
AzureParametersDto azureParametersDto = parametersDto.getAzureParametersDto();
if (azureParametersDto != null) {
builder.setSingleResourceGroup(azureParametersDto.getAzureResourceGroupDto().getResourceGroupUsagePattern().isSingleResourceGroup());
Optional<String> encryptionKeyUrl = Optional.of(azureParametersDto).map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyUrl);
builder.setResourceEncryptionEnabled(encryptionKeyUrl.isPresent());
}
}
return builder.build();
}
Aggregations