use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class FreeIpaTestDto method mapInstanceTemplateRequest.
private InstanceTemplateRequest mapInstanceTemplateRequest(InstanceGroupV4Request request) {
InstanceTemplateRequest template = new InstanceTemplateRequest();
template.setInstanceType(request.getTemplate().getInstanceType());
template.setAttachedVolumes(request.getTemplate().getAttachedVolumes().stream().map(volreq -> {
VolumeRequest volumeRequest = new VolumeRequest();
volumeRequest.setCount(volreq.getCount());
volumeRequest.setSize(volreq.getSize());
volumeRequest.setType(volreq.getType());
return volumeRequest;
}).collect(Collectors.toSet()));
Optional.ofNullable(request.getTemplate().getAws()).map(AwsInstanceTemplateV4Parameters::getSpot).map(AwsInstanceTemplateV4SpotParameters::getPercentage).ifPresent(spotPercentage -> {
AwsInstanceTemplateParameters awsInstanceTemplateParameters = new AwsInstanceTemplateParameters();
AwsInstanceTemplateSpotParameters awsInstanceTemplateSpotParameters = new AwsInstanceTemplateSpotParameters();
awsInstanceTemplateSpotParameters.setPercentage(spotPercentage);
awsInstanceTemplateParameters.setSpot(awsInstanceTemplateSpotParameters);
template.setAws(awsInstanceTemplateParameters);
});
return template;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverterTest method convertTestAwsInstanceTemplateV1ParametersToAwsInstanceTemplateV4ParametersWhenEncryption.
@ParameterizedTest(name = "{0}")
@MethodSource("convertTestAwsInstanceTemplateV1ParametersToAwsInstanceTemplateV4ParametersWhenEncryptionDataProvided")
void convertTestAwsInstanceTemplateV1ParametersToAwsInstanceTemplateV4ParametersWhenEncryption(String testCaseName, boolean withAws, boolean withResourceEncryption, String dataHubEncryptionKey, String environmentEncryptionKey, String expectedEncryptionKey) {
AwsInstanceTemplateV1Parameters source = new AwsInstanceTemplateV1Parameters();
String finalEncryptionKey = null;
if (dataHubEncryptionKey != null) {
source.setEncryption(encryption(EncryptionType.CUSTOM, DATAHUB_ENCRYPTION_KEY));
finalEncryptionKey = DATAHUB_ENCRYPTION_KEY;
} else {
if (environmentEncryptionKey != null) {
source.setEncryption(encryption(EncryptionType.CUSTOM, ENVIRONMENT_ENCRYPTION_KEY));
finalEncryptionKey = ENVIRONMENT_ENCRYPTION_KEY;
} else {
source.setEncryption(encryption(null, null));
}
}
DetailedEnvironmentResponse environment = createDetailedEnvironmentResponseForAwsEncryption(withAws, withResourceEncryption, finalEncryptionKey);
AwsInstanceTemplateV4Parameters awsInstanceTemplateV4Parameters = underTest.convert(source, environment);
assertThat(awsInstanceTemplateV4Parameters).isNotNull();
AwsEncryptionV4Parameters encryption = awsInstanceTemplateV4Parameters.getEncryption();
assertThat(encryption).isNotNull();
if (dataHubEncryptionKey != null || environmentEncryptionKey != null) {
assertThat(encryption.getType()).isEqualTo(EncryptionType.CUSTOM);
assertThat(encryption.getKey()).isEqualTo(expectedEncryptionKey);
} else {
assertThat(encryption.getType()).isEqualTo(EncryptionType.DEFAULT);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverterTest method testWhenDatahubEncryptionTypeSetToNull.
@Test
void testWhenDatahubEncryptionTypeSetToNull() {
AwsInstanceTemplateV1Parameters source = new AwsInstanceTemplateV1Parameters();
source.setEncryption(encryption(null, null));
DetailedEnvironmentResponse environment = createDetailedEnvironmentResponseForAwsEncryption(true, false, null);
AwsInstanceTemplateV4Parameters awsInstanceTemplateV4Parameters = underTest.convert(source, environment);
assertThat(awsInstanceTemplateV4Parameters).isNotNull();
AwsEncryptionV4Parameters encryption = awsInstanceTemplateV4Parameters.getEncryption();
assertThat(encryption).isNotNull();
assertThat(encryption.getType()).isEqualTo(EncryptionType.DEFAULT);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class StackAwsEncryptionValidatorTest method testValidateEncryptionKeyWhenTemplateParametersHasTypeKeyAndItsTypeIsEncryptionTypeWithDefaultValueThenThereIsNoEncryptionKeyCheck.
@Test
public void testValidateEncryptionKeyWhenTemplateParametersHasTypeKeyAndItsTypeIsEncryptionTypeWithDefaultValueThenThereIsNoEncryptionKeyCheck() {
AwsInstanceTemplateV4Parameters parameters = new AwsInstanceTemplateV4Parameters();
parameters.setEncryption(encryption(EncryptionType.DEFAULT, null));
when(subject.getInstanceGroups()).thenReturn(getInstanceGroupWithRequest(createRequestWithParameters(parameters)));
ValidationResult.ValidationResultBuilder builder = new ValidationResult.ValidationResultBuilder();
underTest.validate(subject, builder);
assertValidationErrorIsEmpty(builder.build().getErrors());
verify(platformResourceClientService, times(0)).getEncryptionKeys(anyString(), anyString());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters in project cloudbreak by hortonworks.
the class StackAwsEncryptionValidatorTest method testValidateEncryptionKeyWhenEncryptionKeysCouldNotBeRetrievedThenThereIsNoEncryptionKeyCheck.
@Test
public void testValidateEncryptionKeyWhenEncryptionKeysCouldNotBeRetrievedThenThereIsNoEncryptionKeyCheck() {
AwsInstanceTemplateV4Parameters parameters = new AwsInstanceTemplateV4Parameters();
parameters.setEncryption(encryption(EncryptionType.CUSTOM, null));
when(subject.getInstanceGroups()).thenReturn(getInstanceGroupWithRequest(createRequestWithParameters(parameters)));
ValidationResult.ValidationResultBuilder builder = new ValidationResult.ValidationResultBuilder();
underTest.validate(subject, builder);
assertValidationErrorIsEmpty(builder.build().getErrors());
verify(platformResourceClientService, times(1)).getEncryptionKeys(anyString(), anyString());
}
Aggregations