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.");
}
}
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;
}
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);
});
}
}
Aggregations