Search in sources :

Example 1 with AwsInstanceTemplateV4SpotParameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters 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 2 with AwsInstanceTemplateV4SpotParameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverter method convert.

private AwsInstanceTemplateV4SpotParameters convert(AwsInstanceTemplateV1SpotParameters source) {
    AwsInstanceTemplateV4SpotParameters target = new AwsInstanceTemplateV4SpotParameters();
    target.setPercentage(source.getPercentage());
    target.setMaxPrice(source.getMaxPrice());
    return target;
}
Also used : AwsInstanceTemplateV4SpotParameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters)

Example 3 with AwsInstanceTemplateV4SpotParameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters 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 4 with AwsInstanceTemplateV4SpotParameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters in project cloudbreak by hortonworks.

the class AwsCloudProvider method template.

@Override
public InstanceTemplateV4TestDto template(InstanceTemplateV4TestDto template) {
    AwsInstanceTemplateV4Parameters aws = new AwsInstanceTemplateV4Parameters();
    AwsInstanceTemplateV4SpotParameters spot = new AwsInstanceTemplateV4SpotParameters();
    spot.setPercentage(getSpotPercentage());
    aws.setSpot(spot);
    return template.withInstanceType(awsProperties.getInstance().getType()).withAws(aws);
}
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)

Aggregations

AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)3 AwsInstanceTemplateV4SpotParameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters)3 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)1 VolumeRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.VolumeRequest)1 AwsInstanceTemplateParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateParameters)1 AwsInstanceTemplateSpotParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters)1