Example usage for com.amazonaws.services.ec2.model Tenancy Default

List of usage examples for com.amazonaws.services.ec2.model Tenancy Default

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model Tenancy Default.

Prototype

Tenancy Default

To view the source code for com.amazonaws.services.ec2.model Tenancy Default.

Click Source Link

Usage

From source file:com.kenlin.awsec2offering.App.java

License:Open Source License

private void addReservedOfferings(ArrayNode array, String availabilityZone, String productDescription,
        String offeringType, String instanceType) {
    DescribeReservedInstancesOfferingsRequest req = new DescribeReservedInstancesOfferingsRequest()
            .withIncludeMarketplace(false).withInstanceTenancy(Tenancy.Default); // Not Tenancy.Dedicated
    if (availabilityZone != null)
        req.setAvailabilityZone(availabilityZone);
    if (productDescription != null)
        req.setProductDescription(productDescription);
    if (offeringType != null)
        req.setOfferingType(offeringType);
    if (instanceType != null)
        req.setInstanceType(parseInstanceType(instanceType));

    String nextToken = null;/*  ww w .  j  a  v  a  2s .  co  m*/
    do {
        DescribeReservedInstancesOfferingsResult res = ec2.describeReservedInstancesOfferings(req);
        for (ReservedInstancesOffering o : res.getReservedInstancesOfferings()) {
            Offering offering = new Offering(o);
            try {
                array.add(offering.toJsonNode());
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        nextToken = res.getNextToken();
        req.withNextToken(nextToken);
    } while (nextToken != null);
}