Search in sources :

Example 1 with AzureInstanceTemplateV4Parameters

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;
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)

Example 2 with AzureInstanceTemplateV4Parameters

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.");
    }
}
Also used : AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters) AzureEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)

Example 3 with AzureInstanceTemplateV4Parameters

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);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) AzureInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with AzureInstanceTemplateV4Parameters

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);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) AzureInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters) Test(org.junit.jupiter.api.Test)

Example 5 with AzureInstanceTemplateV4Parameters

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);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) RootVolumeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) AzureInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) Test(org.junit.jupiter.api.Test)

Aggregations

AzureInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)9 AzureEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)5 AzureInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters)5 Test (org.junit.jupiter.api.Test)4 InstanceTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request)3 InstanceTemplateV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request)3 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)3 RootVolumeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request)2 RootVolumeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AzureEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)1 AzureResourceEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1