use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters 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.");
}
}
use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverterTest method createDetailedEnvironmentResponseForAzureEncryption.
private DetailedEnvironmentResponse createDetailedEnvironmentResponseForAzureEncryption(boolean withAzure, boolean withResourceEncryption, String diskEncryptionSetId, String encryptionKeyUrl) {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
if (withAzure) {
AzureEnvironmentParameters parameters = new AzureEnvironmentParameters();
environment.setAzure(parameters);
if (withResourceEncryption) {
AzureResourceEncryptionParameters encryption = new AzureResourceEncryptionParameters();
parameters.setResourceEncryptionParameters(encryption);
encryption.setEncryptionKeyUrl(encryptionKeyUrl);
encryption.setDiskEncryptionSetId(diskEncryptionSetId);
}
}
return environment;
}
use of com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters 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);
}
});
}
Aggregations