use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverter method convert.
public AzureInstanceTemplateV4Parameters convert(AzureInstanceTemplateV1Parameters source, DetailedEnvironmentResponse environment) {
AzureInstanceTemplateV4Parameters response = new AzureInstanceTemplateV4Parameters();
response.setEncrypted(source.getEncrypted());
initAzureEncryptionFromEnvironment(response, environment);
response.setManagedDisk(source.getManagedDisk());
response.setPrivateId(source.getPrivateId());
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters 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.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverterTest method convertTestAzureInstanceTemplateV1ParametersToAzureInstanceTemplateV4ParametersWhenBasicFields.
@Test
void convertTestAzureInstanceTemplateV1ParametersToAzureInstanceTemplateV4ParametersWhenBasicFields() {
AzureInstanceTemplateV1Parameters source = new AzureInstanceTemplateV1Parameters();
source.setPrivateId(PRIVATE_ID);
DetailedEnvironmentResponse environment = createDetailedEnvironmentResponseForAzureEncryption(false, false, null, null);
AzureInstanceTemplateV4Parameters azureInstanceTemplateV4Parameters = underTest.convert(source, environment);
assertThat(azureInstanceTemplateV4Parameters).isNotNull();
assertThat(azureInstanceTemplateV4Parameters.getEncrypted()).isEqualTo(Boolean.FALSE);
assertThat(azureInstanceTemplateV4Parameters.getManagedDisk()).isEqualTo(Boolean.TRUE);
assertThat(azureInstanceTemplateV4Parameters.getPrivateId()).isEqualTo(PRIVATE_ID);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateV1ToInstanceTemplateV4ConverterTest method convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenMinimal.
@Test
void convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenMinimal() {
InstanceTemplateV1Request source = new InstanceTemplateV1Request();
source.setAzure(null);
source.setInstanceType(INSTANCE_TYPE);
AzureInstanceTemplateV4Parameters azureInstanceTemplateV4Parameters = new AzureInstanceTemplateV4Parameters();
when(instanceTemplateParameterConverter.convert(any(AzureInstanceTemplateV1Parameters.class), eq(environment))).thenReturn(azureInstanceTemplateV4Parameters);
InstanceTemplateV4Request instanceTemplateV4Request = underTest.convert(source, environment);
assertThat(instanceTemplateV4Request).isNotNull();
assertThat(instanceTemplateV4Request.getRootVolume()).isNull();
assertThat(instanceTemplateV4Request.getAzure()).isSameAs(azureInstanceTemplateV4Parameters);
assertThat(instanceTemplateV4Request.getCloudPlatform()).isNull();
assertThat(instanceTemplateV4Request.getInstanceType()).isEqualTo(INSTANCE_TYPE);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateV1ToInstanceTemplateV4ConverterTest method convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenAzure.
@Test
void convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenAzure() {
InstanceTemplateV1Request source = new InstanceTemplateV1Request();
RootVolumeV1Request rootVolumeV1Request = new RootVolumeV1Request();
source.setRootVolume(rootVolumeV1Request);
AzureInstanceTemplateV1Parameters azureInstanceTemplateV1Parameters = new AzureInstanceTemplateV1Parameters();
source.setAzure(azureInstanceTemplateV1Parameters);
source.setInstanceType(INSTANCE_TYPE);
RootVolumeV4Request rootVolumeV4Request = new RootVolumeV4Request();
when(volumeConverter.convert(rootVolumeV1Request)).thenReturn(rootVolumeV4Request);
AzureInstanceTemplateV4Parameters azureInstanceTemplateV4Parameters = new AzureInstanceTemplateV4Parameters();
when(instanceTemplateParameterConverter.convert(azureInstanceTemplateV1Parameters, environment)).thenReturn(azureInstanceTemplateV4Parameters);
InstanceTemplateV4Request instanceTemplateV4Request = underTest.convert(source, environment);
assertThat(instanceTemplateV4Request).isNotNull();
assertThat(instanceTemplateV4Request.getRootVolume()).isSameAs(rootVolumeV4Request);
assertThat(instanceTemplateV4Request.getAzure()).isSameAs(azureInstanceTemplateV4Parameters);
assertThat(instanceTemplateV4Request.getCloudPlatform()).isEqualTo(CloudPlatform.AZURE);
assertThat(instanceTemplateV4Request.getInstanceType()).isEqualTo(INSTANCE_TYPE);
}
Aggregations