Search in sources :

Example 6 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request 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;
}
Also used : AwsInstanceTemplateSpotParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsInstanceTemplateParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateParameters) VolumeRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.VolumeRequest)

Example 7 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class InstanceGroupV1ToInstanceGroupV4Converter method convert.

private InstanceGroupV4Request convert(NetworkV4Request network, InstanceGroupV1Request source, DetailedEnvironmentResponse environment) {
    InstanceGroupV4Request response = new InstanceGroupV4Request();
    response.setNodeCount(source.getNodeCount());
    response.setType(source.getType());
    response.setCloudPlatform(source.getCloudPlatform());
    response.setName(source.getName());
    response.setTemplate(getIfNotNull(source.getTemplate(), environment, instanceTemplateConverter::convert));
    response.setRecoveryMode(source.getRecoveryMode());
    response.setScalabilityOption(source.getScalabilityOption());
    response.setSecurityGroup(createSecurityGroupFromEnvironment(source.getType(), environment));
    response.setRecipeNames(source.getRecipeNames());
    response.setMinimumNodeCount(source.getMinimumNodeCount());
    response.setAws(getIfNotNull(source.getAws(), instanceGroupParameterConverter::convert));
    response.setAzure(getIfNotNull(source.getAzure(), instanceGroupParameterConverter::convert));
    response.setGcp(getIfNotNull(source.getGcp(), instanceGroupParameterConverter::convert));
    response.setYarn(getIfNotNull(source.getYarn(), instanceGroupParameterConverter::convert));
    response.setNetwork(getInstanceGroupNetworkV4Request(network, source, environment));
    return response;
}
Also used : InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 8 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverterTest method createInstanceGroups.

private List<InstanceGroupV4Request> createInstanceGroups() {
    List<InstanceGroupV4Request> instanceGroups = new ArrayList<>(GENERAL_TEST_QUANTITY);
    for (int i = 0; i < GENERAL_TEST_QUANTITY; i++) {
        InstanceGroupV4Request instanceGroup = new InstanceGroupV4Request();
        InstanceTemplateV4Request template = new InstanceTemplateV4Request();
        template.setAttachedVolumes(Collections.EMPTY_SET);
        instanceGroup.setName(String.format("group-%d", i));
        instanceGroup.setTemplate(template);
        instanceGroup.setType(InstanceGroupType.CORE);
        instanceGroup.setNodeCount(i);
        instanceGroups.add(instanceGroup);
    }
    return instanceGroups;
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) ArrayList(java.util.ArrayList) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 9 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class NodeCountLimitValidatorTest method stackV4Request.

private StackV4Request stackV4Request(int nodeCount) {
    StackV4Request stackV4Request = new StackV4Request();
    InstanceGroupV4Request instanceGroupV4Request = new InstanceGroupV4Request();
    instanceGroupV4Request.setNodeCount(nodeCount);
    stackV4Request.setInstanceGroups(Lists.newArrayList(instanceGroupV4Request));
    return stackV4Request;
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 10 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class InstanceGroupV1ToInstanceGroupV4ConverterTest method prepareInstanceGroupV4Requests.

private List<InstanceGroupV4Request> prepareInstanceGroupV4Requests(InstanceGroupType instanceGroupType) {
    InstanceGroupV4Request instanceGroup = new InstanceGroupV4Request();
    instanceGroup.setAws(AWS_INSTANCE_GROUP_V4_PARAMETERS);
    instanceGroup.setName(INSTANCE_GROUP_NAME);
    if (InstanceGroupType.GATEWAY.equals(instanceGroupType)) {
        instanceGroup.setNodeCount(1);
    } else {
        instanceGroup.setNodeCount(NODE_COUNT_1);
    }
    instanceGroup.setRecipeNames(RECIPE_NAMES);
    instanceGroup.setRecoveryMode(RecoveryMode.AUTO);
    instanceGroup.setTemplate(new InstanceTemplateV4Request());
    instanceGroup.setType(instanceGroupType);
    return List.of(instanceGroup);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

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