Search in sources :

Example 26 with InstanceGroupV4Request

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

Example 27 with InstanceGroupV4Request

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());
        });
    }
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 28 with InstanceGroupV4Request

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

Example 29 with InstanceGroupV4Request

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

Example 30 with InstanceGroupV4Request

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

Aggregations

InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)51 Test (org.junit.jupiter.api.Test)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)22 InstanceTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request)18 ArrayList (java.util.ArrayList)8 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)5 InstanceGroupNetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)4 SecurityGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.securitygroup.SecurityGroupV4Request)4 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)2 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)2 SecurityRuleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.SecurityRuleV4Request)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)2 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)2 List (java.util.List)2 Test (org.junit.Test)2 Strings (com.google.common.base.Strings)1