Search in sources :

Example 1 with GcpResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverter method initGcpEncryptionFromEnvironment.

private void initGcpEncryptionFromEnvironment(GcpInstanceTemplateV4Parameters response, DetailedEnvironmentResponse environment) {
    String encryptionKey = Optional.of(environment).map(DetailedEnvironmentResponse::getGcp).map(GcpEnvironmentParameters::getGcpResourceEncryptionParameters).map(GcpResourceEncryptionParameters::getEncryptionKey).orElse(null);
    if (encryptionKey != null) {
        LOGGER.info("Applying Encryption with CMEK for GCP disks as per environment.");
        GcpEncryptionV4Parameters encryption = new GcpEncryptionV4Parameters();
        encryption.setType(EncryptionType.CUSTOM);
        encryption.setKeyEncryptionMethod(KeyEncryptionMethod.KMS);
        encryption.setKey(encryptionKey);
        response.setEncryption(encryption);
    } else {
        LOGGER.info("Environment has not requested for Customer-Managed Encryption with CMEK for GCP disks.");
    }
}
Also used : GcpEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters) GcpEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters)

Example 2 with GcpResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverterTest method createDetailedEnvironmentResponseForGcpEncryption.

private DetailedEnvironmentResponse createDetailedEnvironmentResponseForGcpEncryption(boolean withGcp, boolean withResourceEncryption, String encryptionKey) {
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    if (withGcp) {
        GcpEnvironmentParameters parameters = new GcpEnvironmentParameters();
        environment.setGcp(parameters);
        if (withResourceEncryption) {
            GcpResourceEncryptionParameters encryption = new GcpResourceEncryptionParameters();
            parameters.setGcpResourceEncryptionParameters(encryption);
            encryption.setEncryptionKey(encryptionKey);
        }
    }
    return environment;
}
Also used : GcpResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters) GcpEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)

Example 3 with GcpResourceEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters in project cloudbreak by hortonworks.

the class StackRequestManifester method setupInstanceVolumeEncryptionForGcp.

@VisibleForTesting
void setupInstanceVolumeEncryptionForGcp(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    String encryptionKey = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getGcp).map(GcpEnvironmentParameters::getGcpResourceEncryptionParameters).map(GcpResourceEncryptionParameters::getEncryptionKey).orElse(null);
    if (encryptionKey != null) {
        stackRequest.getInstanceGroups().forEach(ig -> {
            GcpInstanceTemplateV4Parameters gcp = ig.getTemplate().createGcp();
            GcpEncryptionV4Parameters encryption = gcp.getEncryption();
            if (encryption == null) {
                encryption = new GcpEncryptionV4Parameters();
                gcp.setEncryption(encryption);
            }
            gcp.getEncryption().setType(EncryptionType.CUSTOM);
            gcp.getEncryption().setKey(encryptionKey);
            gcp.getEncryption().setKeyEncryptionMethod(KeyEncryptionMethod.KMS);
        });
    }
}
Also used : GcpEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters) GcpInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters) GcpEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

GcpEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters)3 GcpEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 GcpInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters)1 GcpResourceEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1