use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method getSampleGcpRequest.
private InstanceTemplateV4Request getSampleGcpRequest() {
InstanceTemplateV4Request source = new InstanceTemplateV4Request();
source.setCloudPlatform(CloudPlatform.GCP);
source.setRootVolume(getRootVolume(100));
source.setInstanceType("n1-standard-4");
GcpInstanceTemplateV4Parameters parameters = new GcpInstanceTemplateV4Parameters();
GcpEncryptionV4Parameters encryption = new GcpEncryptionV4Parameters();
encryption.setType(EncryptionType.CUSTOM);
encryption.setKeyEncryptionMethod(KeyEncryptionMethod.RAW);
encryption.setKey("myKey");
parameters.setEncryption(encryption);
source.setGcp(parameters);
ProviderParameterCalculator providerParameterCalculator = new ProviderParameterCalculator();
ReflectionTestUtils.setField(underTest, "providerParameterCalculator", providerParameterCalculator);
when(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)).thenReturn("name");
return source;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters 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.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters in project cloudbreak by hortonworks.
the class StackRequestManifesterTest method createGcpEncryptionV4Parameters.
private GcpEncryptionV4Parameters createGcpEncryptionV4Parameters(EncryptionType encryptionType, String encryptionKey) {
GcpEncryptionV4Parameters gcpEncryptionV4Parameters = new GcpEncryptionV4Parameters();
gcpEncryptionV4Parameters.setType(encryptionType);
gcpEncryptionV4Parameters.setKey(encryptionKey);
return gcpEncryptionV4Parameters;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters 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);
});
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters in project cloudbreak by hortonworks.
the class StackRequestManifesterTest method verifyGcpEncryption.
private void verifyGcpEncryption(InstanceTemplateV4Request instanceTemplateV4Request, EncryptionType expectedEncryptionType, String expectedEncryptionKey) {
GcpInstanceTemplateV4Parameters gcp = instanceTemplateV4Request.getGcp();
assertThat(gcp).isNotNull();
GcpEncryptionV4Parameters encryption = gcp.getEncryption();
assertThat(encryption).isNotNull();
assertThat(encryption.getType()).isEqualTo(expectedEncryptionType);
assertThat(encryption.getKey()).isEqualTo(expectedEncryptionKey);
}
Aggregations