Search in sources :

Example 1 with AzureResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverter method initAzureEncryptionFromEnvironment.

private void initAzureEncryptionFromEnvironment(AzureInstanceTemplateV4Parameters response, DetailedEnvironmentResponse environment) {
    String encryptionKeyUrl = Optional.of(environment).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getEncryptionKeyUrl).orElse(null);
    String diskEncryptionSetId = Optional.of(environment).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getDiskEncryptionSetId).orElse(null);
    if (encryptionKeyUrl != null && diskEncryptionSetId != null) {
        LOGGER.info("Applying SSE with CMK for Azure managed disks as per environment.");
        AzureEncryptionV4Parameters encryption = new AzureEncryptionV4Parameters();
        encryption.setKey(encryptionKeyUrl);
        encryption.setType(EncryptionType.CUSTOM);
        encryption.setDiskEncryptionSetId(diskEncryptionSetId);
        response.setEncryption(encryption);
    } else {
        LOGGER.info("Environment has not requested for SSE with CMK for Azure managed disks.");
    }
}
Also used : AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters) AzureEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)

Example 2 with AzureResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverterTest method createDetailedEnvironmentResponseForAzureEncryption.

private DetailedEnvironmentResponse createDetailedEnvironmentResponseForAzureEncryption(boolean withAzure, boolean withResourceEncryption, String diskEncryptionSetId, String encryptionKeyUrl) {
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    if (withAzure) {
        AzureEnvironmentParameters parameters = new AzureEnvironmentParameters();
        environment.setAzure(parameters);
        if (withResourceEncryption) {
            AzureResourceEncryptionParameters encryption = new AzureResourceEncryptionParameters();
            parameters.setResourceEncryptionParameters(encryption);
            encryption.setEncryptionKeyUrl(encryptionKeyUrl);
            encryption.setDiskEncryptionSetId(diskEncryptionSetId);
        }
    }
    return environment;
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) AzureResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters) AzureEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)

Example 3 with AzureResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters in project cloudbreak by hortonworks.

the class StackRequestManifester method setupInstanceVolumeEncryptionForAzure.

@VisibleForTesting
void setupInstanceVolumeEncryptionForAzure(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    Optional<String> encryptionKeyUrl = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getEncryptionKeyUrl);
    Optional<String> diskEncryptionSetId = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getDiskEncryptionSetId);
    stackRequest.getInstanceGroups().forEach(ig -> {
        AzureInstanceTemplateV4Parameters azure = ig.getTemplate().createAzure();
        AzureEncryptionV4Parameters encryption = azure.getEncryption();
        if (encryption == null) {
            encryption = new AzureEncryptionV4Parameters();
            azure.setEncryption(encryption);
        }
        if (encryptionKeyUrl.isPresent() && diskEncryptionSetId.isPresent()) {
            azure.getEncryption().setKey(encryptionKeyUrl.get());
            azure.getEncryption().setType(EncryptionType.CUSTOM);
            azure.getEncryption().setDiskEncryptionSetId(diskEncryptionSetId.get());
        }
        if (entitlementService.isAzureEncryptionAtHostEnabled(environmentResponse.getAccountId())) {
            azure.getEncryption().setEncryptionAtHostEnabled(Boolean.TRUE);
        }
    });
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters) AzureResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

AzureEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)2 AzureEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)2 AzureResourceEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AzureInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)1