use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.
the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndNoEncryptionParameters.
@Test
void setupInstanceVolumeEncryptionTestWhenAwsAndNoEncryptionParameters() {
DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
envResponse.setCloudPlatform(CloudPlatform.AWS.name());
InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
InstanceTemplateV4Request instanceTemplateV4Request = instanceGroupV4Request.getTemplate();
instanceTemplateV4Request.createAws();
when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
verifyAwsEncryption(instanceTemplateV4Request, EncryptionType.DEFAULT);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.
the class SdxService method overrideDefaultTemplateValues.
private void overrideDefaultTemplateValues(StackV4Request defaultTemplate, List<SdxInstanceGroupRequest> customInstanceGroups, String accountId) {
if (isCustomInstanceTypeSelected(customInstanceGroups) && !entitlementService.isDatalakeSelectInstanceTypeEnabled(accountId)) {
throw new BadRequestException("Datalake instance type selection is not enabled! " + "Contact Cloudera support to enable CDP_DATALAKE_SELECT_INSTANCE_TYPE entitlement for the account.");
}
if (CollectionUtils.isNotEmpty(customInstanceGroups)) {
LOGGER.debug("Override default template with custom instance groups from request.");
customInstanceGroups.forEach(customInstanceGroup -> {
InstanceGroupV4Request templateInstanceGroup = defaultTemplate.getInstanceGroups().stream().filter(templateGroup -> templateGroup.getName() != null && templateGroup.getName().equals(customInstanceGroup.getName())).findAny().orElseThrow(() -> new BadRequestException("Custom instance group is missing from default template: " + customInstanceGroup.getName()));
overrideInstanceType(templateInstanceGroup, customInstanceGroup.getInstanceType());
});
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.
the class SdxService method overrideInstanceType.
private void overrideInstanceType(InstanceGroupV4Request templateGroup, String newInstanceType) {
InstanceTemplateV4Request instanceTemplate = templateGroup.getTemplate();
if (instanceTemplate != null && StringUtils.isNoneBlank(newInstanceType)) {
LOGGER.debug("Override instance group {} instance type from {} to {}", templateGroup.getName(), instanceTemplate.getInstanceType(), newInstanceType);
instanceTemplate.setInstanceType(newInstanceType);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.
the class SdxService method updateAwsSpotParameters.
private void updateAwsSpotParameters(StackV4Request stackRequest, SdxAwsSpotParameters sdxSpotParameters) {
stackRequest.getInstanceGroups().stream().map(InstanceGroupV4Request::getTemplate).peek(template -> {
if (template.getAws() == null) {
template.setAws(new AwsInstanceTemplateV4Parameters());
}
}).map(InstanceTemplateV4Base::getAws).peek(aws -> {
if (aws.getSpot() == null) {
aws.setSpot(new AwsInstanceTemplateV4SpotParameters());
}
}).map(AwsInstanceTemplateV4Parameters::getSpot).forEach(spot -> {
spot.setPercentage(sdxSpotParameters.getPercentage());
spot.setMaxPrice(sdxSpotParameters.getMaxPrice());
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverter method setUpMock.
private void setUpMock(InstanceGroupV4Request instanceGroup, InstanceGroupNetworkV4Request instanceGroupNetworkV4Request, String subnetId) {
if (!StringUtils.isEmpty(subnetId)) {
InstanceGroupMockNetworkV4Parameters mock = new InstanceGroupMockNetworkV4Parameters();
mock.setSubnetIds(List.of(subnetId));
instanceGroupNetworkV4Request.setMock(mock);
instanceGroup.setNetwork(instanceGroupNetworkV4Request);
}
}
Aggregations