use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getInstanceTemplateRequest.
private InstanceTemplateRequest getInstanceTemplateRequest(Template template) {
InstanceTemplateRequest request = null;
if (template != null) {
request = new InstanceTemplateRequest();
request.setInstanceType(template.getInstanceType());
Integer spotPercentage = template.getAttributes().getValue(AwsInstanceTemplate.EC2_SPOT_PERCENTAGE);
Double maxPrice = template.getAttributes().getValue(AwsInstanceTemplate.EC2_SPOT_MAX_PRICE);
if (spotPercentage != null) {
LOGGER.debug("EC2 spot percentage found in the instances template attributes");
AwsInstanceTemplateParameters aws = new AwsInstanceTemplateParameters();
AwsInstanceTemplateSpotParameters spot = new AwsInstanceTemplateSpotParameters();
spot.setPercentage(spotPercentage);
if (maxPrice != null) {
LOGGER.debug("EC2 max price found in the instances template attributes");
spot.setMaxPrice(maxPrice);
}
aws.setSpot(spot);
request.setAws(aws);
}
VolumeRequest volumeRequest = new VolumeRequest();
volumeRequest.setType(template.getVolumeType());
volumeRequest.setCount(template.getVolumeCount());
volumeRequest.setSize(template.getVolumeSize());
request.setAttachedVolumes(Optional.of(volumeRequest).filter(v -> v.getCount() != null && v.getCount() > 0 && v.getSize() != null && v.getSize() > 0).stream().collect(Collectors.toSet()));
}
LOGGER.debug("Created instance template request {} from instance template {}", request, template);
return request;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters in project cloudbreak by hortonworks.
the class FreeIpaTestDto method withSpotPercentage.
public FreeIpaTestDto withSpotPercentage(int spotPercentage) {
getRequest().getInstanceGroups().forEach(instanceGroupRequest -> {
AwsInstanceTemplateParameters aws = instanceGroupRequest.getInstanceTemplate().getAws();
if (Objects.isNull(aws)) {
aws = new AwsInstanceTemplateParameters();
instanceGroupRequest.getInstanceTemplate().setAws(aws);
}
AwsInstanceTemplateSpotParameters spot = new AwsInstanceTemplateSpotParameters();
spot.setPercentage(spotPercentage);
aws.setSpot(spot);
});
return this;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters 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.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters in project cloudbreak by hortonworks.
the class InstanceTemplateRequestToTemplateConverterTest method createAwsInstanceTemplateParameters.
private AwsInstanceTemplateParameters createAwsInstanceTemplateParameters(int spotPercentage, Double spotMaxPrice) {
AwsInstanceTemplateSpotParameters spot = new AwsInstanceTemplateSpotParameters();
spot.setPercentage(spotPercentage);
spot.setMaxPrice(spotMaxPrice);
AwsInstanceTemplateParameters aws = new AwsInstanceTemplateParameters();
aws.setSpot(spot);
return aws;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateSpotParameters in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method createInstanceTemplate.
private InstanceTemplateRequest createInstanceTemplate(FreeIpaCreationDto freeIpaCreation) {
InstanceTemplateRequest instanceTemplateRequest = new InstanceTemplateRequest();
instanceTemplateRequest.setInstanceType(freeIpaCreation.getInstanceType());
Optional.ofNullable(freeIpaCreation.getAws()).map(FreeIpaCreationAwsParametersDto::getSpot).ifPresent(spotParametersDto -> {
AwsInstanceTemplateSpotParameters spot = new AwsInstanceTemplateSpotParameters();
spot.setPercentage(spotParametersDto.getPercentage());
spot.setMaxPrice(spotParametersDto.getMaxPrice());
AwsInstanceTemplateParameters aws = new AwsInstanceTemplateParameters();
aws.setSpot(spot);
instanceTemplateRequest.setAws(aws);
});
return instanceTemplateRequest;
}
Aggregations