diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java index 021dffc1bb..3a4bac6a70 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java @@ -37,6 +37,7 @@ public class Spot implements Comparable { private String productDescription; private float spotPrice; private Date timestamp; + private String availabilityZone; public void clear() { this.region = null; @@ -44,6 +45,7 @@ public class Spot implements Comparable { this.productDescription = null; this.spotPrice = 0.0f; this.timestamp = null; + this.availabilityZone = null; } public Builder region(String region) { @@ -71,8 +73,13 @@ public class Spot implements Comparable { return this; } + public Builder availabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + return this; + } + public Spot build() { - return new Spot(region, instanceType, productDescription, spotPrice, timestamp); + return new Spot(region, instanceType, productDescription, spotPrice, timestamp, availabilityZone); } } @@ -81,13 +88,16 @@ public class Spot implements Comparable { private final String productDescription; private final float spotPrice; private final Date timestamp; + private final String availabilityZone; - public Spot(String region, String instanceType, String productDescription, float spotPrice, Date timestamp) { + public Spot(String region, String instanceType, String productDescription, float spotPrice, Date timestamp, + String availabilityZone) { this.region = checkNotNull(region, "region"); this.instanceType = checkNotNull(instanceType, "instanceType"); this.productDescription = checkNotNull(productDescription, "productDescription"); this.spotPrice = spotPrice; this.timestamp = checkNotNull(timestamp, "timestamp"); + this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone"); } /** @@ -117,6 +127,10 @@ public class Spot implements Comparable { return timestamp; } + public String getAvailabilityZone() { + return availabilityZone; + } + @Override public int compareTo(Spot o) { return Float.compare(spotPrice, o.spotPrice); @@ -131,6 +145,7 @@ public class Spot implements Comparable { result = prime * result + ((region == null) ? 0 : region.hashCode()); result = prime * result + Float.floatToIntBits(spotPrice); result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode()); + result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode()); return result; } @@ -165,13 +180,20 @@ public class Spot implements Comparable { return false; } else if (!timestamp.equals(other.timestamp)) return false; + if (availabilityZone == null) { + if (other.availabilityZone != null) + return false; + } else if (!availabilityZone.equals(other.availabilityZone)) { + return false; + } return true; } @Override public String toString() { return "[region=" + region + ", instanceType=" + instanceType + ", productDescription=" + productDescription - + ", spotPrice=" + spotPrice + ", timestamp=" + timestamp + "]"; + + ", spotPrice=" + spotPrice + ", timestamp=" + timestamp + ", availabilityZone=" + + availabilityZone + "]"; } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java index 54035a933d..ba01984610 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java @@ -65,6 +65,8 @@ public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult expected = ImmutableSet.of( - Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f) - .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z")).build(), - Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f) - .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z")).build(), - Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f) - .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z")).build() + Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f) + .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z")) + .availabilityZone("us-west-1a").build(), + Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f) + .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z")) + .availabilityZone("us-west-1b").build(), + Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f) + .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z")) + .availabilityZone("us-west-1c").build() ); diff --git a/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml b/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml index b71570a645..c25a53653a 100644 --- a/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml +++ b/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml @@ -7,18 +7,21 @@ SUSE Linux 0.013000 2011-03-07T12:17:19.000Z + us-west-1a m1.large Linux/UNIX 0.119000 2011-03-07T16:29:16.000Z + us-west-1b t1.micro Windows 0.013000 2011-03-07T17:56:54.000Z + us-west-1c \ No newline at end of file