use of com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters 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.GcpEnvironmentParameters 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.GcpEnvironmentParameters in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentityForGCS.
@Test
public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentityForGCS() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockFileSystemResponseForCloudbreakClient();
SdxCluster sdxCluster = new SdxCluster();
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
sdxCluster.setInitiatorUserCrn(USER_CRN);
sdxCluster.setClusterName("sdx-cluster");
SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
cloudStorageRequest.setBaseLocation("gs://example-path");
cloudStorageRequest.setFileSystemType(FileSystemType.GCS);
GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL);
cloudStorageRequest.setGcs(gcsCloudStorageV1Parameters);
sdxClusterRequest.setCloudStorage(cloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("GCP");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
loggingResponse.setGcs(gcsCloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
GcpEnvironmentParameters gcpEnvironmentParameters = GcpEnvironmentParameters.builder().build();
environment.setGcp(gcpEnvironmentParameters);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest));
StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next();
assertEquals(2, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals(2, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getGcs().getServiceAccountEmail().equals(EMAIL)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getLocations().size());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType());
assertEquals("ranger/example-path", singleRequest.getValue());
verify(storageValidationService).validateCloudStorage("GCP", cloudStorageRequest);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters 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.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method createGcpRequest.
private GcpEnvironmentParameters createGcpRequest() {
GcpEnvironmentParameters gcpEnvironmentParameters = new GcpEnvironmentParameters();
gcpEnvironmentParameters.setGcpResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("dummy-encryption-key").build());
return gcpEnvironmentParameters;
}
Aggregations