Search in sources :

Example 1 with AzureEncryptionV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters 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 AzureEncryptionV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method verifyAzureEncryptionForEncryptionAtHost.

private void verifyAzureEncryptionForEncryptionAtHost(InstanceTemplateV4Request instanceTemplateV4Request, Boolean expectedIsEncryptionAtHost) {
    AzureInstanceTemplateV4Parameters azure = instanceTemplateV4Request.getAzure();
    assertThat(azure).isNotNull();
    AzureEncryptionV4Parameters encryption = azure.getEncryption();
    assertThat(encryption).isNotNull();
    assertThat(encryption.isEncryptionAtHostEnabled()).isEqualTo(expectedIsEncryptionAtHost);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)

Example 3 with AzureEncryptionV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method verifyAzureEncryption.

private void verifyAzureEncryption(InstanceTemplateV4Request instanceTemplateV4Request, EncryptionType expectedEncryptionType, String expectedDiskEncryptionSetId, String expectedEncryptionKeyUrl) {
    AzureInstanceTemplateV4Parameters azure = instanceTemplateV4Request.getAzure();
    assertThat(azure).isNotNull();
    AzureEncryptionV4Parameters encryption = azure.getEncryption();
    assertThat(encryption).isNotNull();
    assertThat(encryption.getType()).isEqualTo(expectedEncryptionType);
    assertThat(encryption.getKey()).isEqualTo(expectedEncryptionKeyUrl);
    assertThat(encryption.getDiskEncryptionSetId()).isEqualTo(expectedDiskEncryptionSetId);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)

Example 4 with AzureEncryptionV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters 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)

Example 5 with AzureEncryptionV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method createAzureEncryptionV4Parameters.

private AzureEncryptionV4Parameters createAzureEncryptionV4Parameters(EncryptionType encryptionType, String encryptionKey) {
    AzureEncryptionV4Parameters azureEncryptionV4Parameters = new AzureEncryptionV4Parameters();
    azureEncryptionV4Parameters.setType(encryptionType);
    azureEncryptionV4Parameters.setKey(encryptionKey);
    return azureEncryptionV4Parameters;
}
Also used : AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)

Aggregations

AzureEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)6 AzureInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AzureInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters)1 AzureEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)1 AzureResourceEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1