diff --git a/aws/core/src/main/clojure/org/jclouds/aws/ebs.clj b/aws/core/src/main/clojure/org/jclouds/aws/ebs.clj index 91a7e04993..7138cb4a46 100644 --- a/aws/core/src/main/clojure/org/jclouds/aws/ebs.clj +++ b/aws/core/src/main/clojure/org/jclouds/aws/ebs.clj @@ -172,9 +172,9 @@ [v] (cond (instance? AvailabilityZone v) v - (instance? NodeMetadata v) (AvailabilityZone/fromValue (.getLocationId #^NodeMetadata v)) - (string? v) (AvailabilityZone/fromValue v) - (keyword? v) (AvailabilityZone/fromValue (name v)) + (instance? NodeMetadata v) (.getLocationId #^NodeMetadata v) + (string? v) v + (keyword? v) (name v) :else (throw (IllegalArgumentException. (str "Can't obtain zone from argument of type " (class v)))))) diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java index e5b3d08500..f4e4ebd055 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import javax.inject.Singleton; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.http.HttpRequest; import org.jclouds.rest.Binder; import org.jclouds.rest.internal.GeneratedHttpRequest; @@ -41,10 +40,10 @@ public class IfNotNullBindAvailabilityZoneToFormParam implements Binder { if (input != null) { checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); - checkArgument(input instanceof AvailabilityZone, + checkArgument(input instanceof String, "this binder is only valid for AvailabilityZone!"); ((GeneratedHttpRequest) request).addFormParam("Placement.AvailabilityZone", - ((AvailabilityZone) input).value()); + (String) input); } } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java index b771690469..471556fc88 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -49,7 +49,6 @@ import org.jclouds.aws.ec2.compute.functions.RunningInstanceToNodeMetadata; import org.jclouds.aws.ec2.compute.strategy.EC2DestroyNodeStrategy; import org.jclouds.aws.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy; import org.jclouds.aws.ec2.config.EC2ContextModule; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.KeyPair; import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.functions.RunningInstanceToStorageMappingUnix; @@ -257,11 +256,11 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule { @Provides @Singleton - Map provideLocations(Map availabilityZoneToRegionMap) { + Map provideLocations(Map availabilityZoneToRegionMap) { Map locations = Maps.newLinkedHashMap(); - for (AvailabilityZone zone : availabilityZoneToRegionMap.keySet()) { - locations.put(zone.toString(), new LocationImpl(LocationScope.ZONE, zone.toString(), zone - .toString(), availabilityZoneToRegionMap.get(zone))); + for (String zone : availabilityZoneToRegionMap.keySet()) { + locations.put(zone, new LocationImpl(LocationScope.ZONE, zone, zone, + availabilityZoneToRegionMap.get(zone))); } for (String region : availabilityZoneToRegionMap.values()) { locations.put(region, new LocationImpl(LocationScope.REGION, region, diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 37f24262f2..e8c5f49a35 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -102,7 +102,7 @@ public class RunningInstanceToNodeMetadata implements Function publicAddresses = nullSafeSet(instance.getIpAddress()); Set privateAddresses = nullSafeSet(instance.getPrivateIpAddress()); - String locationId = instance.getAvailabilityZone().toString(); + String locationId = instance.getAvailabilityZone(); Map extra = getExtra(instance); diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java index 432d6f5aa2..c3b0f5cd9a 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java @@ -34,7 +34,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.compute.domain.EC2Size; import org.jclouds.aws.ec2.compute.domain.PortsRegionTag; @@ -42,7 +41,6 @@ import org.jclouds.aws.ec2.compute.domain.RegionTag; import org.jclouds.aws.ec2.compute.functions.CreateNewKeyPair; import org.jclouds.aws.ec2.compute.functions.CreateSecurityGroupIfNeeded; import org.jclouds.aws.ec2.compute.functions.RunningInstanceToNodeMetadata; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.KeyPair; import org.jclouds.aws.ec2.domain.Reservation; import org.jclouds.aws.ec2.domain.RunningInstance; @@ -122,8 +120,7 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate EC2Size ec2Size = EC2Size.class.cast(template.getSize()); // parse the availability zone of the request - AvailabilityZone zone = template.getLocation().getScope() == LocationScope.ZONE ? AvailabilityZone - .fromValue(template.getLocation().getId()) + String zone = template.getLocation().getScope() == LocationScope.ZONE ? template.getLocation().getId() : null; // if the location has a parent, it must be an availability zone. diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java index fb38c9b2b3..692f06f8cb 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java @@ -27,9 +27,7 @@ import java.util.concurrent.TimeUnit; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo; import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.predicates.InstanceStateRunning; @@ -132,9 +130,9 @@ public class EC2RestClientModule extends AbstractModule { @Provides @Singleton - Map provideAvailabilityZoneToRegions( + Map provideAvailabilityZoneToRegions( AvailabilityZoneAndRegionClient client, @EC2 Map regions) { - Map map = Maps.newHashMap(); + Map map = Maps.newHashMap(); for (String region : regions.keySet()) { for (AvailabilityZoneInfo zoneInfo : client.describeAvailabilityZonesInRegion(region)) { map.put(zoneInfo.getZone(), region); diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZone.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZone.java index 860058b257..1332bf3710 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZone.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZone.java @@ -18,9 +18,9 @@ */ package org.jclouds.aws.ec2.domain; -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.internal.ImmutableSet; -import com.google.common.base.CaseFormat; +import java.util.Set; /** * @@ -28,21 +28,21 @@ import com.google.common.base.CaseFormat; * * @author Adrian Cole */ -public enum AvailabilityZone { +public class AvailabilityZone { - UNKNOWN, EU_WEST_1A, EU_WEST_1B, US_EAST_1A, US_EAST_1B, US_EAST_1C, US_EAST_1D, US_WEST_1A, US_WEST_1B, AP_SOUTHEAST_1A, AP_SOUTHEAST_1B; + public static final String EU_WEST_1A = "eu-west-1a"; + public static final String EU_WEST_1B = "eu-west-1b"; + public static final String US_EAST_1A = "us-east-1a"; + public static final String US_EAST_1B = "us-east-1b"; + public static final String US_EAST_1C = "us-east-1c"; + public static final String US_EAST_1D = "us-east-1d"; + public static final String US_WEST_1A = "us-west-1a"; + public static final String US_WEST_1B = "us-west-1b"; + public static final String AP_SOUTHEAST_1A = "ap-southeast-1a"; + public static final String AP_SOUTHEAST_1B = "ap-southeast-1b"; - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); - } + public static final Set zones = ImmutableSet.of(EU_WEST_1A, EU_WEST_1B, + US_EAST_1A, US_EAST_1B, US_EAST_1C, US_EAST_1D, + US_WEST_1A, US_WEST_1B, AP_SOUTHEAST_1A, AP_SOUTHEAST_1B); - @Override - public String toString() { - return value(); - } - - public static AvailabilityZone fromValue(String availablilityZone) { - return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull( - availablilityZone, "availablilityZone"))); - } } \ No newline at end of file diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZoneInfo.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZoneInfo.java index 2cfaa18dcb..6f40352b46 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZoneInfo.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/AvailabilityZoneInfo.java @@ -51,32 +51,23 @@ public class AvailabilityZoneInfo implements Comparable{ } } - private final String zoneName; - private final AvailabilityZone zone; + private final String zone; private final State state; private final String region; private final Set messages = Sets.newHashSet(); - public AvailabilityZoneInfo(String zoneName, AvailabilityZone zone, State zoneState, + public AvailabilityZoneInfo(String zone, State zoneState, String region, Iterable messages) { - this.zoneName = checkNotNull(zoneName, "zoneName"); this.zone = checkNotNull(zone, "zone"); this.state = checkNotNull(zoneState, "zoneState"); this.region = checkNotNull(region, "region"); Iterables.addAll(this.messages, checkNotNull(messages, "messages")); } - /** - * Name of the Availability Zone. - */ - public String getZoneName() { - return zoneName; - } - /** * the Availability Zone. */ - public AvailabilityZone getZone() { + public String getZone() { return zone; } @@ -109,7 +100,6 @@ public class AvailabilityZoneInfo implements Comparable{ result = prime * result + ((region == null) ? 0 : region.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((zone == null) ? 0 : zone.hashCode()); - result = prime * result + ((zoneName == null) ? 0 : zoneName.hashCode()); return result; } @@ -142,23 +132,18 @@ public class AvailabilityZoneInfo implements Comparable{ return false; } else if (!zone.equals(other.zone)) return false; - if (zoneName == null) { - if (other.zoneName != null) - return false; - } else if (!zoneName.equals(other.zoneName)) - return false; return true; } @Override public String toString() { return "AvailabilityZoneInfo [messages=" + messages + ", region=" + region + ", state=" - + state + ", zone=" + zone + ", zoneName=" + zoneName + "]"; + + state + ", zone=" + zone + "]"; } @Override public int compareTo(AvailabilityZoneInfo that) { - return zoneName.compareTo(that.zoneName); + return zone.compareTo(that.zone); } } \ No newline at end of file diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java index 49aa27b89c..f5c7e6ec62 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java @@ -132,7 +132,7 @@ public class RunningInstance implements Comparable { private final String keyName; private final Date launchTime; private final boolean monitoring; - private final AvailabilityZone availabilityZone; + private final String availabilityZone; @Nullable private final String platform; @Nullable @@ -161,7 +161,7 @@ public class RunningInstance implements Comparable { String imageId, String instanceId, InstanceState instanceState, String instanceType, @Nullable InetAddress ipAddress, @Nullable String kernelId, @Nullable String keyName, Date launchTime, boolean monitoring, - AvailabilityZone availabilityZone, @Nullable String platform, + String availabilityZone, @Nullable String platform, @Nullable String privateDnsName, @Nullable InetAddress privateIpAddress, Set productCodes, @Nullable String ramdiskId, @Nullable String reason, @Nullable String subnetId, @Nullable String vpcId, RootDeviceType rootDeviceType, @@ -284,7 +284,7 @@ public class RunningInstance implements Comparable { /** * The location where the instance launched. */ - public AvailabilityZone getAvailabilityZone() { + public String getAvailabilityZone() { return availabilityZone; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Volume.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Volume.java index 51a80f119e..5a43774637 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Volume.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Volume.java @@ -84,13 +84,13 @@ public class Volume implements Comparable { private final int size; @Nullable private final String snapshotId; - private final AvailabilityZone availabilityZone; + private final String availabilityZone; private final Status status; private final Date createTime; private final Set attachments = Sets.newLinkedHashSet(); public Volume(String region, String id, int size, String snapshotId, - AvailabilityZone availabilityZone, Volume.Status status, Date createTime, + String availabilityZone, Volume.Status status, Date createTime, Iterable attachments) { this.region = checkNotNull(region, "region"); this.id = id; @@ -122,7 +122,7 @@ public class Volume implements Comparable { return snapshotId; } - public AvailabilityZone getAvailabilityZone() { + public String getAvailabilityZone() { return availabilityZone; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/functions/AvailabilityZoneToEndpoint.java b/aws/core/src/main/java/org/jclouds/aws/ec2/functions/AvailabilityZoneToEndpoint.java index e90ecd0ffc..10e3825bc5 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/functions/AvailabilityZoneToEndpoint.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/functions/AvailabilityZoneToEndpoint.java @@ -24,9 +24,7 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import com.google.common.base.Function; @@ -36,12 +34,12 @@ import com.google.common.base.Function; */ @Singleton public class AvailabilityZoneToEndpoint implements Function { - private final Map availabilityZoneToRegion; + private final Map availabilityZoneToRegion; private final Map regionToEndpoint; @Inject public AvailabilityZoneToEndpoint(@EC2 Map regionToEndpoint, - Map availabilityZoneToRegion) { + Map availabilityZoneToRegion) { this.regionToEndpoint = regionToEndpoint; this.availabilityZoneToRegion = availabilityZoneToRegion; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeAvailabilityZonesOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeAvailabilityZonesOptions.java index 398518e9cf..17705bcedc 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeAvailabilityZonesOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeAvailabilityZonesOptions.java @@ -18,9 +18,9 @@ */ package org.jclouds.aws.ec2.options; +import java.util.Arrays; import java.util.Set; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions; /** @@ -46,10 +46,8 @@ public class DescribeAvailabilityZonesOptions extends BaseEC2RequestOptions { /** * Availability Zone name. */ - public DescribeAvailabilityZonesOptions zones(AvailabilityZone... zones) { - String[] zoneStrings = new String[zones.length]; - for (int i = 0; i < zoneStrings.length; i++) - zoneStrings[i] = zones[i].value(); + public DescribeAvailabilityZonesOptions zones(String... zones) { + String[] zoneStrings = Arrays.copyOf(zones, zones.length, String[].class); indexFormValuesWithPrefix("ZoneName", zoneStrings); return this; } @@ -61,9 +59,9 @@ public class DescribeAvailabilityZonesOptions extends BaseEC2RequestOptions { public static class Builder { /** - * @see DescribeAvailabilityZonesOptions#zones(AvailabilityZone[] ) + * @see DescribeAvailabilityZonesOptions#zones(String...) */ - public static DescribeAvailabilityZonesOptions availabilityZones(AvailabilityZone... zones) { + public static DescribeAvailabilityZonesOptions availabilityZones(String... zones) { DescribeAvailabilityZonesOptions options = new DescribeAvailabilityZonesOptions(); return options.zones(zones); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClient.java b/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClient.java index c92a788a67..da4f0698bf 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClient.java @@ -28,12 +28,10 @@ import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams; import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams; import org.jclouds.aws.ec2.binders.BindVolumeIdsToIndexedFormParams; import org.jclouds.aws.ec2.domain.Attachment; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.Permission; import org.jclouds.aws.ec2.domain.Snapshot; import org.jclouds.aws.ec2.domain.Volume; @@ -79,7 +77,7 @@ public interface ElasticBlockStoreAsyncClient { @FormParams(keys = ACTION, values = "CreateVolume") @XMLResponseParser(CreateVolumeResponseHandler.class) ListenableFuture createVolumeFromSnapshotInAvailabilityZone( - @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone, + @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, @FormParam("SnapshotId") String snapshotId); /** @@ -90,7 +88,7 @@ public interface ElasticBlockStoreAsyncClient { @FormParams(keys = ACTION, values = "CreateVolume") @XMLResponseParser(CreateVolumeResponseHandler.class) ListenableFuture createVolumeFromSnapshotInAvailabilityZone( - @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone, + @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, @FormParam("Size") int size, @FormParam("SnapshotId") String snapshotId); /** @@ -101,7 +99,7 @@ public interface ElasticBlockStoreAsyncClient { @FormParams(keys = ACTION, values = "CreateVolume") @XMLResponseParser(CreateVolumeResponseHandler.class) ListenableFuture createVolumeInAvailabilityZone( - @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone, + @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, @FormParam("Size") int size); /** diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreClient.java b/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreClient.java index 4d6687297a..b01f71ee68 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/services/ElasticBlockStoreClient.java @@ -23,9 +23,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.domain.Attachment; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.Permission; import org.jclouds.aws.ec2.domain.Snapshot; import org.jclouds.aws.ec2.domain.Volume; @@ -65,7 +63,7 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" * /> */ - Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone, + Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone, String snapshotId); /** @@ -95,7 +93,7 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" * /> */ - Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone, + Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone, int size, String snapshotId); /** @@ -120,7 +118,7 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" * /> */ - Volume createVolumeInAvailabilityZone(AvailabilityZone availabilityZone, int size); + Volume createVolumeInAvailabilityZone(String availabilityZone, int size); /** * Describes the specified Amazon EBS volumes that you own. If you do not specify one or more diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceAsyncClient.java b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceAsyncClient.java index 2f75345c66..46b39acfd2 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceAsyncClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceAsyncClient.java @@ -88,7 +88,7 @@ public interface InstanceAsyncClient { @XMLResponseParser(RunInstancesResponseHandler.class) ListenableFuture runInstancesInRegion( @EndpointParam(parser = RegionToEndpoint.class) @Nullable String region, - @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) AvailabilityZone nullableAvailabilityZone, + @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone, @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount, @FormParam("MaxCount") int maxCount, RunInstancesOptions... options); diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java index f6892dce6e..d89248248d 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java @@ -134,7 +134,7 @@ public interface InstanceClient { * @see RunInstancesOptions */ Reservation runInstancesInRegion(@Nullable String region, - @Nullable AvailabilityZone nullableAvailabilityZone, String imageId, int minCount, + @Nullable String nullableAvailabilityZone, String imageId, int minCount, int maxCount, RunInstancesOptions... options); /** diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java b/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java index 944d7a35bb..d9a3348a83 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java @@ -70,10 +70,11 @@ public class EC2Utils { return null; } - public static AvailabilityZone findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest) { + public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest) { for (Object arg : gRequest.getArgs()) { - if (arg instanceof AvailabilityZone) { - return (AvailabilityZone) arg; + if (arg instanceof String) { + String zone = (String) arg; + if(AvailabilityZone.zones.contains(zone)) return zone; } } return null; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java index 52ff00ae2b..29365ce7db 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java @@ -28,12 +28,9 @@ import java.util.SortedSet; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.domain.Attachment; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.InstanceState; -import org.jclouds.aws.ec2.domain.InstanceType; import org.jclouds.aws.ec2.domain.Reservation; import org.jclouds.aws.ec2.domain.RootDeviceType; import org.jclouds.aws.ec2.domain.RunningInstance; @@ -81,7 +78,7 @@ public abstract class BaseReservationHandler extends HandlerWithResult { private String keyName; private Date launchTime; private boolean monitoring; - private AvailabilityZone availabilityZone; + private String availabilityZone; private String platform; private String privateDnsName; private InetAddress privateIpAddress; @@ -153,7 +150,7 @@ public abstract class BaseReservationHandler extends HandlerWithResult { } else if (qName.equals("enabled")) { monitoring = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("availabilityZone")) { - availabilityZone = AvailabilityZone.fromValue(currentOrNull()); + availabilityZone = currentOrNull(); } else if (qName.equals("platform")) { platform = currentOrNull(); } else if (qName.equals("privateDnsName")) { diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/CreateVolumeResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/CreateVolumeResponseHandler.java index 5b926cecbf..9d01398fce 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/CreateVolumeResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/CreateVolumeResponseHandler.java @@ -27,10 +27,8 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.domain.Attachment; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.Volume; import org.jclouds.aws.ec2.util.EC2Utils; import org.jclouds.date.DateService; @@ -56,12 +54,12 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult availabilityZoneToRegion; + protected Map availabilityZoneToRegion; private String id; private int size; private String snapshotId; - private AvailabilityZone availabilityZone; + private String availabilityZone; private Volume.Status volumeStatus; private Date createTime; private Set attachments = Sets.newLinkedHashSet(); @@ -96,13 +94,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult availablilityZones = Sets.newLinkedHashSet(); - private AvailabilityZone zone; + private String zone; @Resource protected Logger logger = Logger.NULL; private String region; - private String zoneName; private State zoneState; private boolean inMessageSet; private Set messages = Sets.newHashSet(); @@ -62,13 +59,7 @@ public class DescribeAvailabilityZonesResponseHandler extends public void endElement(String uri, String name, String qName) { if (qName.equals("zoneName")) { - zoneName = currentText.toString().trim(); - try { - zone = AvailabilityZone.fromValue(zoneName); - } catch (IllegalArgumentException e) { - logger.warn(e, "unsupported region: %s", zoneName); - zone = AvailabilityZone.UNKNOWN; - } + zone = currentText.toString().trim(); } else if (qName.equals("regionName")) { try { region = currentText.toString().trim(); @@ -88,10 +79,9 @@ public class DescribeAvailabilityZonesResponseHandler extends } else if (qName.equals("messageSet")) { inMessageSet = false; } else if (qName.equals("item") && !inMessageSet) { - availablilityZones.add(new AvailabilityZoneInfo(zoneName, zone, zoneState, region, + availablilityZones.add(new AvailabilityZoneInfo(zone, zoneState, region, messages)); this.zone = null; - this.zoneName = null; this.region = null; this.zoneState = null; this.messages = Sets.newHashSet(); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java index 2b157b894c..02c726f849 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java @@ -34,7 +34,6 @@ import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2ContextFactory; -import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; @@ -75,8 +74,8 @@ public class AvailabilityZoneAndRegionClientLiveTest { assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); Iterator iterator = allResults.iterator(); - AvailabilityZone id1 = iterator.next().getZone(); - AvailabilityZone id2 = iterator.next().getZone(); + String id1 = iterator.next().getZone(); + String id2 = iterator.next().getZone(); SortedSet twoResults = Sets.newTreeSet(client .describeAvailabilityZonesInRegion(region, availabilityZones(id1, id2))); assertNotNull(twoResults); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/BaseEC2AsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/BaseEC2AsyncClientTest.java index e934237421..7dd0e19b5d 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/BaseEC2AsyncClientTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/BaseEC2AsyncClientTest.java @@ -108,8 +108,8 @@ public abstract class BaseEC2AsyncClientTest extends RestClientTest { @SuppressWarnings("unused") @Singleton @Provides - Map provideAvailabilityZoneRegionMap() { - return ImmutableMap. of(AvailabilityZone.US_EAST_1A, + Map provideAvailabilityZoneRegionMap() { + return ImmutableMap. of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); } }; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClientTest.java index 026cb599e9..ff45bbe8c7 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClientTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/ElasticBlockStoreAsyncClientTest.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.lang.reflect.Array; import java.lang.reflect.Method; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable; import org.jclouds.aws.ec2.options.CreateSnapshotOptions; @@ -57,7 +56,7 @@ public class ElasticBlockStoreAsyncClientTest extends public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { Method method = ElasticBlockStoreAsyncClient.class.getMethod( - "createVolumeInAvailabilityZone", AvailabilityZone.class, int.class); + "createVolumeInAvailabilityZone", String.class, int.class); GeneratedHttpRequest httpMethod = processor.createRequest( method, AvailabilityZone.US_EAST_1A, 20); @@ -77,7 +76,7 @@ public class ElasticBlockStoreAsyncClientTest extends public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, IOException { Method method = ElasticBlockStoreAsyncClient.class.getMethod( - "createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class, String.class); + "createVolumeFromSnapshotInAvailabilityZone", String.class, String.class); GeneratedHttpRequest httpMethod = processor.createRequest( method, AvailabilityZone.US_EAST_1A, "snapshotId"); @@ -97,7 +96,7 @@ public class ElasticBlockStoreAsyncClientTest extends public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException, IOException { Method method = ElasticBlockStoreAsyncClient.class.getMethod( - "createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class, int.class, + "createVolumeFromSnapshotInAvailabilityZone", String.class, int.class, String.class); GeneratedHttpRequest httpMethod = processor.createRequest( method, AvailabilityZone.US_EAST_1A, 15, "snapshotId"); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java index 6cb31c5286..09e003e01a 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java @@ -113,7 +113,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest httpMethod = processor.createRequest(method, null, null, "ami-voo", 1, 1); @@ -134,7 +134,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest httpMethod = processor.createRequest(method, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", 1, 5, diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/BaseEC2HandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/BaseEC2HandlerTest.java index 3a929bebd3..f1aec5c2b4 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/BaseEC2HandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/BaseEC2HandlerTest.java @@ -67,8 +67,8 @@ public class BaseEC2HandlerTest extends BaseHandlerTest { @SuppressWarnings("unused") @Singleton @Provides - Map provideAvailabilityZoneRegionMap() { - return ImmutableMap. of(AvailabilityZone.US_EAST_1A, + Map provideAvailabilityZoneRegionMap() { + return ImmutableMap. of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); } }); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java index 56ce3caea6..f26766202a 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java @@ -44,15 +44,19 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes InputStream is = getClass().getResourceAsStream("/ec2/availabilityZones.xml"); Set expected = ImmutableSet. of( - new AvailabilityZoneInfo("us-east-1a", AvailabilityZone.US_EAST_1A, - AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet - . of()), new AvailabilityZoneInfo("us-east-1b", - AvailabilityZone.US_EAST_1B, AvailabilityZoneInfo.State.AVAILABLE, - Region.US_EAST_1, ImmutableSet. of()), new AvailabilityZoneInfo( - "us-east-1c", AvailabilityZone.US_EAST_1C, - AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet - . of("our service is awesome")), new AvailabilityZoneInfo( - "us-east-1d", AvailabilityZone.US_EAST_1D, + + new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, + AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet + . of()), + new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, + AvailabilityZoneInfo.State.AVAILABLE, + Region.US_EAST_1, ImmutableSet. of()), + + new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, + AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet + . of("our service is awesome")), + + new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, AvailabilityZoneInfo.State.UNKNOWN, Region.US_EAST_1, ImmutableSet . of())); Set result = factory.create(