Search in sources :

Example 11 with AvailabilityZone

use of com.amazonaws.services.ec2.model.AvailabilityZone in project GNS by MobilityFirst.

the class AWSEC2 method describeAvailabilityZones.

/**
   * Describe Availability Zones
   *
   * @param ec2
   */
public static void describeAvailabilityZones(AmazonEC2 ec2) {
    StringBuilder output = new StringBuilder();
    String prefix = currentTab + "Availability Zones: ";
    DescribeAvailabilityZonesResult availabilityZonesResult = ec2.describeAvailabilityZones();
    prefix = prefix.concat(" [" + availabilityZonesResult.getAvailabilityZones().size() + " total] ");
    for (AvailabilityZone zone : availabilityZonesResult.getAvailabilityZones()) {
        output.append(prefix);
        prefix = ", ";
        output.append(zone.getZoneName());
    }
    System.out.println(output);
}
Also used : AvailabilityZone(com.amazonaws.services.ec2.model.AvailabilityZone) DescribeAvailabilityZonesResult(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult)

Example 12 with AvailabilityZone

use of com.amazonaws.services.ec2.model.AvailabilityZone in project herd by FINRAOS.

the class MockSpotPrice method toAwsObject.

/**
 * Converts this object into an AWS equivalent object.
 *
 * @return A new equivalent AWS object
 */
public SpotPrice toAwsObject() {
    SpotPrice spotPrice = new SpotPrice();
    spotPrice.setAvailabilityZone(availabilityZone);
    spotPrice.setInstanceType(type);
    spotPrice.setSpotPrice(this.spotPrice);
    return spotPrice;
}
Also used : SpotPrice(com.amazonaws.services.ec2.model.SpotPrice)

Example 13 with AvailabilityZone

use of com.amazonaws.services.ec2.model.AvailabilityZone in project herd by FINRAOS.

the class MockAvailabilityZone method toAwsObject.

/**
 * Converts this object into an AWS equivalent object.
 *
 * @return A new equivalent AWS object
 */
public AvailabilityZone toAwsObject() {
    AvailabilityZone availabilityZone = new AvailabilityZone();
    availabilityZone.setRegionName(regionName);
    availabilityZone.setZoneName(zoneName);
    return availabilityZone;
}
Also used : AvailabilityZone(com.amazonaws.services.ec2.model.AvailabilityZone)

Example 14 with AvailabilityZone

use of com.amazonaws.services.ec2.model.AvailabilityZone in project herd by FINRAOS.

the class MockSubnet method toAwsObject.

/**
 * Converts this object into an AWS equivalent object.
 *
 * @return A new equivalent AWS object
 */
public Subnet toAwsObject() {
    Subnet subnet = new Subnet();
    subnet.setSubnetId(subnetId);
    subnet.setAvailabilityZone(availabilityZone);
    subnet.setAvailableIpAddressCount(availableIpAddressCount);
    return subnet;
}
Also used : Subnet(com.amazonaws.services.ec2.model.Subnet)

Example 15 with AvailabilityZone

use of com.amazonaws.services.ec2.model.AvailabilityZone in project herd by FINRAOS.

the class EmrPricingHelper method getInstanceTypeSpotPrices.

/**
 * Returns a mapping of instance types to spot prices for the given AZ and instance types. The spot prices are retrieved from EC2 API.
 * <p/>
 * This method also validates that the given instance types are real instance types supported by AWS.
 *
 * @param availabilityZone the AZ of the spot instances
 * @param instanceTypes the size of the spot instances
 * @param awsParamsDto the AWS related parameters for access/secret keys and proxy details
 *
 * @return the mapping of instance type to spot prices
 * @throws ObjectNotFoundException when any of the instance type does not exist in AWS
 */
private Map<String, BigDecimal> getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto) {
    List<String> productDescriptions = herdStringHelper.getDelimitedConfigurationValue(ConfigurationValue.EMR_SPOT_PRICE_HISTORY_PRODUCT_DESCRIPTIONS);
    List<SpotPrice> spotPrices = ec2Dao.getLatestSpotPrices(availabilityZone.getZoneName(), instanceTypes, productDescriptions, awsParamsDto);
    Map<String, BigDecimal> instanceTypeSpotPrices = new HashMap<>();
    for (SpotPrice spotPrice : spotPrices) {
        instanceTypeSpotPrices.put(spotPrice.getInstanceType(), new BigDecimal(spotPrice.getSpotPrice()));
    }
    return instanceTypeSpotPrices;
}
Also used : SpotPrice(com.amazonaws.services.ec2.model.SpotPrice) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal)

Aggregations

AvailabilityZone (com.amazonaws.services.ec2.model.AvailabilityZone)10 DescribeAvailabilityZonesResult (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)5 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)4 HashMap (java.util.HashMap)4 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)3 DescribeRegionsResult (com.amazonaws.services.ec2.model.DescribeRegionsResult)3 SpotPrice (com.amazonaws.services.ec2.model.SpotPrice)3 Subnet (com.amazonaws.services.ec2.model.Subnet)3 List (java.util.List)3 CreateVolumeRequest (com.amazonaws.services.ec2.model.CreateVolumeRequest)2 DescribeAvailabilityZonesRequest (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest)2 DescribeSpotPriceHistoryResult (com.amazonaws.services.ec2.model.DescribeSpotPriceHistoryResult)2 Region (com.amazonaws.services.ec2.model.Region)2 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)2 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)2 Region (com.sequenceiq.cloudbreak.cloud.model.Region)2 Collections.singletonList (java.util.Collections.singletonList)2 Test (org.junit.Test)2