Merge branch 'master' of git@github.com:jclouds/jclouds

* 'master' of git@github.com:jclouds/jclouds:
  added AWS Elastic IP Address clojure wrapper
  additional region-related fixes for clojure wrappers
  changed AvailabilityZone to String (from enum)
This commit is contained in:
Adrian Cole 2010-05-02 17:56:52 -07:00
commit 453148e56f
28 changed files with 226 additions and 150 deletions

View File

@ -24,7 +24,7 @@
(:use (clojure.contrib def core)) (:use (clojure.contrib def core))
(:import org.jclouds.aws.domain.Region (:import org.jclouds.aws.domain.Region
org.jclouds.compute.domain.NodeMetadata org.jclouds.compute.domain.NodeMetadata
(org.jclouds.aws.ec2.domain Volume Snapshot AvailabilityZone) (org.jclouds.aws.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZone)
(org.jclouds.aws.ec2.options DescribeSnapshotsOptions DetachVolumeOptions CreateSnapshotOptions))) (org.jclouds.aws.ec2.options DescribeSnapshotsOptions DetachVolumeOptions CreateSnapshotOptions)))
(defn snapshot? (defn snapshot?
@ -46,16 +46,16 @@
.getContext .getProviderSpecificContext .getApi .getElasticBlockStoreServices)) .getContext .getProviderSpecificContext .getApi .getElasticBlockStoreServices))
(defn get-region (defn get-region
"Returns the first argument as the corresponding Region if it is a "Coerces the first parameter into a Region string; strings, keywords, and
keyword or already a Region instance. An optional second argument NodeMetadata instances are acceptable arguments. An optional second argument
is returned if the first cannot be coerced into a Region. is returned if the first cannot be coerced into a region string.
Returns nil otherwise." Returns nil otherwise."
([v] (get-region v nil)) ([v] (get-region v nil))
([v default-region] ([v default-region]
(cond (cond
(string? v) v
(keyword? v) (name v) (keyword? v) (name v)
(instance? Region v) v (instance? NodeMetadata v) (let [zone (compute/location v)]
(instance? NodeMetadata v) (let [zone (.getLocationId v)]
; no easier way to go from zone -> region? ; no easier way to go from zone -> region?
(if (> (.indexOf zone "-") -1) (if (> (.indexOf zone "-") -1)
(subs zone 0 (-> zone count dec)) (subs zone 0 (-> zone count dec))
@ -119,7 +119,7 @@
"Returns a set of org.jclouds.aws.ec2.domain.Snapshot instances that match "Returns a set of org.jclouds.aws.ec2.domain.Snapshot instances that match
the criteria provided. Options include: the criteria provided. Options include:
:region - region string or keyword :region - region string, keyword, or NodeMetadata
:owner - AWS account id (or \"amazon\" or \"self\") :owner - AWS account id (or \"amazon\" or \"self\")
:restorable-by - AWS account id :restorable-by - AWS account id
@ -172,9 +172,9 @@
[v] [v]
(cond (cond
(instance? AvailabilityZone v) v (instance? AvailabilityZone v) v
(instance? NodeMetadata v) (AvailabilityZone/fromValue (.getLocationId #^NodeMetadata v)) (instance? NodeMetadata v) (compute/location #^NodeMetadata v)
(string? v) (AvailabilityZone/fromValue v) (string? v) v
(keyword? v) (AvailabilityZone/fromValue (name v)) (keyword? v) (name v)
:else (throw (IllegalArgumentException. :else (throw (IllegalArgumentException.
(str "Can't obtain zone from argument of type " (class v)))))) (str "Can't obtain zone from argument of type " (class v))))))
@ -283,3 +283,36 @@
(.deleteVolumeInRegion (ebs-service) (.deleteVolumeInRegion (ebs-service)
(get-region region) (get-region region)
(as-string volume-id)))) (as-string volume-id))))
(defn status
"Returns the status of the given entity; works for Volumes and Snapshots."
[k]
(.getStatus k))
(defn status-available?
[#^Volume v]
(= Volume$Status/AVAILABLE (status v)))
(defn status-creating?
[#^Volume v]
(= Volume$Status/CREATING (status v)))
(defn status-deleting?
[#^Volume v]
(= Volume$Status/DELETING (status v)))
(defn status-in-use?
[#^Volume v]
(= Volume$Status/IN_USE (status v)))
(defn status-completed?
[#^Snapshot s]
(= Snapshot$Status/COMPLETED (status s)))
(defn status-error?
[#^Snapshot s]
(= Snapshot$Status/ERROR (status s)))
(defn status-pending?
[#^Snapshot s]
(= Snapshot$Status/PENDING (status s)))

View File

@ -0,0 +1,91 @@
;;
;; Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
;;
;; ====================================================================
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; ====================================================================
;;
(ns
#^{:author "Chas Emerick, cemerick@snowtide.com"
:doc "A clojure binding for the jclouds AWS elastic IP address interface."}
org.jclouds.aws.elastic-ip
(:require (org.jclouds [compute :as compute])
[org.jclouds.aws.ebs :as ebs])
(:use (clojure.contrib def core))
(:import org.jclouds.compute.domain.NodeMetadata
(org.jclouds.aws.ec2.domain PublicIpInstanceIdPair)
java.net.InetAddress))
(defn #^org.jclouds.aws.ec2.services.ElasticIPAddressClient
eip-service
"Returns the synchronous ElasticIPAddressClient associated with
the specified compute service, or compute/*compute* as bound by with-compute-service."
[& [compute]]
(-> (or compute compute/*compute*)
.getContext .getProviderSpecificContext .getApi .getElasticIPAddressServices))
(defn- as-ip
"Coerces v to an InetAddress; accepts InetAddresses and strings."
[v]
(if (string? v)
(InetAddress/getByName v)
v))
(defn allocate
"Claims a new elastic IP address within the (optionally) specified region for your account.
Region may be a string, keyword, or a node from which the region
is inferred. Returns a corresponding InetAddress instance."
([] (allocate nil))
([region]
(.allocateAddressInRegion (eip-service) (ebs/get-region region))))
(defn associate
"Associates an elastic IP address with a node."
([#^NodeMetadata node public-ip]
(associate node public-ip (.getId node)))
([region public-ip instance-id]
(.associateAddressInRegion (eip-service)
(ebs/get-region region)
(as-ip public-ip)
instance-id)))
(defn addresses
"Returns a map of elastic IP addresses to maps with slots:
:region - the region (string/keyword/NodeMetadata) the IP address is allocated within
:node-id - the ID of the instance with which the IP address is associated (optional)
You may optionally specify which IP addresses you would like to query."
([] (addresses nil))
([region & public-ips]
(into {} (for [#^PublicIpInstanceIdPair pair (.describeAddressesInRegion (eip-service)
(ebs/get-region region)
(into-array InetAddress (map as-ip public-ips)))]
[(.getPublicIp pair) (merge {:region (.getRegion pair)}
(when (.getInstanceId pair) {:node-id (.getInstanceId pair)}))]))))
(defn dissociate
"Dissociates an elastic IP address from the node with which it is currently associated."
[region public-ip]
(.disassociateAddressInRegion (eip-service)
(ebs/get-region region)
(as-ip public-ip)))
(defn release
"Disclaims an elastic IP address from your account."
([public-ip] (release nil public-ip))
([region public-ip]
(.releaseAddressInRegion (eip-service)
(ebs/get-region region)
(as-ip public-ip))))

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
@ -41,10 +40,10 @@ public class IfNotNullBindAvailabilityZoneToFormParam implements Binder {
if (input != null) { if (input != null) {
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
"this binder is only valid for GeneratedHttpRequests!"); "this binder is only valid for GeneratedHttpRequests!");
checkArgument(input instanceof AvailabilityZone, checkArgument(input instanceof String,
"this binder is only valid for AvailabilityZone!"); "this binder is only valid for AvailabilityZone!");
((GeneratedHttpRequest<?>) request).addFormParam("Placement.AvailabilityZone", ((GeneratedHttpRequest<?>) request).addFormParam("Placement.AvailabilityZone",
((AvailabilityZone) input).value()); (String) input);
} }
} }

View File

@ -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.EC2DestroyNodeStrategy;
import org.jclouds.aws.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy; import org.jclouds.aws.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy;
import org.jclouds.aws.ec2.config.EC2ContextModule; 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.KeyPair;
import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.functions.RunningInstanceToStorageMappingUnix; import org.jclouds.aws.ec2.functions.RunningInstanceToStorageMappingUnix;
@ -257,11 +256,11 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
@Provides @Provides
@Singleton @Singleton
Map<String, ? extends Location> provideLocations(Map<AvailabilityZone, String> availabilityZoneToRegionMap) { Map<String, ? extends Location> provideLocations(Map<String, String> availabilityZoneToRegionMap) {
Map<String, Location> locations = Maps.newLinkedHashMap(); Map<String, Location> locations = Maps.newLinkedHashMap();
for (AvailabilityZone zone : availabilityZoneToRegionMap.keySet()) { for (String zone : availabilityZoneToRegionMap.keySet()) {
locations.put(zone.toString(), new LocationImpl(LocationScope.ZONE, zone.toString(), zone locations.put(zone, new LocationImpl(LocationScope.ZONE, zone, zone,
.toString(), availabilityZoneToRegionMap.get(zone))); availabilityZoneToRegionMap.get(zone)));
} }
for (String region : availabilityZoneToRegionMap.values()) { for (String region : availabilityZoneToRegionMap.values()) {
locations.put(region, new LocationImpl(LocationScope.REGION, region, locations.put(region, new LocationImpl(LocationScope.REGION, region,

View File

@ -102,7 +102,7 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
Set<InetAddress> publicAddresses = nullSafeSet(instance.getIpAddress()); Set<InetAddress> publicAddresses = nullSafeSet(instance.getIpAddress());
Set<InetAddress> privateAddresses = nullSafeSet(instance.getPrivateIpAddress()); Set<InetAddress> privateAddresses = nullSafeSet(instance.getPrivateIpAddress());
String locationId = instance.getAvailabilityZone().toString(); String locationId = instance.getAvailabilityZone();
Map<String, String> extra = getExtra(instance); Map<String, String> extra = getExtra(instance);

View File

@ -34,7 +34,6 @@ import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.compute.domain.EC2Size; import org.jclouds.aws.ec2.compute.domain.EC2Size;
import org.jclouds.aws.ec2.compute.domain.PortsRegionTag; 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.CreateNewKeyPair;
import org.jclouds.aws.ec2.compute.functions.CreateSecurityGroupIfNeeded; import org.jclouds.aws.ec2.compute.functions.CreateSecurityGroupIfNeeded;
import org.jclouds.aws.ec2.compute.functions.RunningInstanceToNodeMetadata; 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.KeyPair;
import org.jclouds.aws.ec2.domain.Reservation; import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.domain.RunningInstance;
@ -122,8 +120,7 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate
EC2Size ec2Size = EC2Size.class.cast(template.getSize()); EC2Size ec2Size = EC2Size.class.cast(template.getSize());
// parse the availability zone of the request // parse the availability zone of the request
AvailabilityZone zone = template.getLocation().getScope() == LocationScope.ZONE ? AvailabilityZone String zone = template.getLocation().getScope() == LocationScope.ZONE ? template.getLocation().getId()
.fromValue(template.getLocation().getId())
: null; : null;
// if the location has a parent, it must be an availability zone. // if the location has a parent, it must be an availability zone.

View File

@ -27,9 +27,7 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2; 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.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.predicates.InstanceStateRunning; import org.jclouds.aws.ec2.predicates.InstanceStateRunning;
@ -132,9 +130,9 @@ public class EC2RestClientModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
Map<AvailabilityZone, String> provideAvailabilityZoneToRegions( Map<String, String> provideAvailabilityZoneToRegions(
AvailabilityZoneAndRegionClient client, @EC2 Map<String, URI> regions) { AvailabilityZoneAndRegionClient client, @EC2 Map<String, URI> regions) {
Map<AvailabilityZone, String> map = Maps.newHashMap(); Map<String, String> map = Maps.newHashMap();
for (String region : regions.keySet()) { for (String region : regions.keySet()) {
for (AvailabilityZoneInfo zoneInfo : client.describeAvailabilityZonesInRegion(region)) { for (AvailabilityZoneInfo zoneInfo : client.describeAvailabilityZonesInRegion(region)) {
map.put(zoneInfo.getZone(), region); map.put(zoneInfo.getZone(), region);

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.aws.ec2.domain; 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 * @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() { public static final Set<String> zones = ImmutableSet.of(EU_WEST_1A, EU_WEST_1B,
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); 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")));
}
} }

View File

@ -51,32 +51,23 @@ public class AvailabilityZoneInfo implements Comparable<AvailabilityZoneInfo>{
} }
} }
private final String zoneName; private final String zone;
private final AvailabilityZone zone;
private final State state; private final State state;
private final String region; private final String region;
private final Set<String> messages = Sets.newHashSet(); private final Set<String> messages = Sets.newHashSet();
public AvailabilityZoneInfo(String zoneName, AvailabilityZone zone, State zoneState, public AvailabilityZoneInfo(String zone, State zoneState,
String region, Iterable<String> messages) { String region, Iterable<String> messages) {
this.zoneName = checkNotNull(zoneName, "zoneName");
this.zone = checkNotNull(zone, "zone"); this.zone = checkNotNull(zone, "zone");
this.state = checkNotNull(zoneState, "zoneState"); this.state = checkNotNull(zoneState, "zoneState");
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
Iterables.addAll(this.messages, checkNotNull(messages, "messages")); Iterables.addAll(this.messages, checkNotNull(messages, "messages"));
} }
/**
* Name of the Availability Zone.
*/
public String getZoneName() {
return zoneName;
}
/** /**
* the Availability Zone. * the Availability Zone.
*/ */
public AvailabilityZone getZone() { public String getZone() {
return zone; return zone;
} }
@ -109,7 +100,6 @@ public class AvailabilityZoneInfo implements Comparable<AvailabilityZoneInfo>{
result = prime * result + ((region == null) ? 0 : region.hashCode()); result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode());
result = prime * result + ((zone == null) ? 0 : zone.hashCode()); result = prime * result + ((zone == null) ? 0 : zone.hashCode());
result = prime * result + ((zoneName == null) ? 0 : zoneName.hashCode());
return result; return result;
} }
@ -142,23 +132,18 @@ public class AvailabilityZoneInfo implements Comparable<AvailabilityZoneInfo>{
return false; return false;
} else if (!zone.equals(other.zone)) } else if (!zone.equals(other.zone))
return false; return false;
if (zoneName == null) {
if (other.zoneName != null)
return false;
} else if (!zoneName.equals(other.zoneName))
return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "AvailabilityZoneInfo [messages=" + messages + ", region=" + region + ", state=" return "AvailabilityZoneInfo [messages=" + messages + ", region=" + region + ", state="
+ state + ", zone=" + zone + ", zoneName=" + zoneName + "]"; + state + ", zone=" + zone + "]";
} }
@Override @Override
public int compareTo(AvailabilityZoneInfo that) { public int compareTo(AvailabilityZoneInfo that) {
return zoneName.compareTo(that.zoneName); return zone.compareTo(that.zone);
} }
} }

View File

@ -132,7 +132,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
private final String keyName; private final String keyName;
private final Date launchTime; private final Date launchTime;
private final boolean monitoring; private final boolean monitoring;
private final AvailabilityZone availabilityZone; private final String availabilityZone;
@Nullable @Nullable
private final String platform; private final String platform;
@Nullable @Nullable
@ -161,7 +161,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
String imageId, String instanceId, InstanceState instanceState, String imageId, String instanceId, InstanceState instanceState,
String instanceType, @Nullable InetAddress ipAddress, @Nullable String kernelId, String instanceType, @Nullable InetAddress ipAddress, @Nullable String kernelId,
@Nullable String keyName, Date launchTime, boolean monitoring, @Nullable String keyName, Date launchTime, boolean monitoring,
AvailabilityZone availabilityZone, @Nullable String platform, String availabilityZone, @Nullable String platform,
@Nullable String privateDnsName, @Nullable InetAddress privateIpAddress, @Nullable String privateDnsName, @Nullable InetAddress privateIpAddress,
Set<String> productCodes, @Nullable String ramdiskId, @Nullable String reason, Set<String> productCodes, @Nullable String ramdiskId, @Nullable String reason,
@Nullable String subnetId, @Nullable String vpcId, RootDeviceType rootDeviceType, @Nullable String subnetId, @Nullable String vpcId, RootDeviceType rootDeviceType,
@ -284,7 +284,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
/** /**
* The location where the instance launched. * The location where the instance launched.
*/ */
public AvailabilityZone getAvailabilityZone() { public String getAvailabilityZone() {
return availabilityZone; return availabilityZone;
} }

View File

@ -84,13 +84,13 @@ public class Volume implements Comparable<Volume> {
private final int size; private final int size;
@Nullable @Nullable
private final String snapshotId; private final String snapshotId;
private final AvailabilityZone availabilityZone; private final String availabilityZone;
private final Status status; private final Status status;
private final Date createTime; private final Date createTime;
private final Set<Attachment> attachments = Sets.newLinkedHashSet(); private final Set<Attachment> attachments = Sets.newLinkedHashSet();
public Volume(String region, String id, int size, String snapshotId, 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<Attachment> attachments) { Iterable<Attachment> attachments) {
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
this.id = id; this.id = id;
@ -122,7 +122,7 @@ public class Volume implements Comparable<Volume> {
return snapshotId; return snapshotId;
} }
public AvailabilityZone getAvailabilityZone() { public String getAvailabilityZone() {
return availabilityZone; return availabilityZone;
} }

View File

@ -24,9 +24,7 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -36,12 +34,12 @@ import com.google.common.base.Function;
*/ */
@Singleton @Singleton
public class AvailabilityZoneToEndpoint implements Function<Object, URI> { public class AvailabilityZoneToEndpoint implements Function<Object, URI> {
private final Map<AvailabilityZone, String> availabilityZoneToRegion; private final Map<String, String> availabilityZoneToRegion;
private final Map<String, URI> regionToEndpoint; private final Map<String, URI> regionToEndpoint;
@Inject @Inject
public AvailabilityZoneToEndpoint(@EC2 Map<String, URI> regionToEndpoint, public AvailabilityZoneToEndpoint(@EC2 Map<String, URI> regionToEndpoint,
Map<AvailabilityZone, String> availabilityZoneToRegion) { Map<String, String> availabilityZoneToRegion) {
this.regionToEndpoint = regionToEndpoint; this.regionToEndpoint = regionToEndpoint;
this.availabilityZoneToRegion = availabilityZoneToRegion; this.availabilityZoneToRegion = availabilityZoneToRegion;
} }

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.aws.ec2.options; package org.jclouds.aws.ec2.options;
import java.util.Arrays;
import java.util.Set; import java.util.Set;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions; import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions;
/** /**
@ -46,10 +46,8 @@ public class DescribeAvailabilityZonesOptions extends BaseEC2RequestOptions {
/** /**
* Availability Zone name. * Availability Zone name.
*/ */
public DescribeAvailabilityZonesOptions zones(AvailabilityZone... zones) { public DescribeAvailabilityZonesOptions zones(String... zones) {
String[] zoneStrings = new String[zones.length]; String[] zoneStrings = Arrays.copyOf(zones, zones.length, String[].class);
for (int i = 0; i < zoneStrings.length; i++)
zoneStrings[i] = zones[i].value();
indexFormValuesWithPrefix("ZoneName", zoneStrings); indexFormValuesWithPrefix("ZoneName", zoneStrings);
return this; return this;
} }
@ -61,9 +59,9 @@ public class DescribeAvailabilityZonesOptions extends BaseEC2RequestOptions {
public static class Builder { 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(); DescribeAvailabilityZonesOptions options = new DescribeAvailabilityZonesOptions();
return options.zones(zones); return options.zones(zones);
} }

View File

@ -28,12 +28,10 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams; import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams; import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindVolumeIdsToIndexedFormParams; import org.jclouds.aws.ec2.binders.BindVolumeIdsToIndexedFormParams;
import org.jclouds.aws.ec2.domain.Attachment; 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.Permission;
import org.jclouds.aws.ec2.domain.Snapshot; import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.aws.ec2.domain.Volume; import org.jclouds.aws.ec2.domain.Volume;
@ -79,7 +77,7 @@ public interface ElasticBlockStoreAsyncClient {
@FormParams(keys = ACTION, values = "CreateVolume") @FormParams(keys = ACTION, values = "CreateVolume")
@XMLResponseParser(CreateVolumeResponseHandler.class) @XMLResponseParser(CreateVolumeResponseHandler.class)
ListenableFuture<Volume> createVolumeFromSnapshotInAvailabilityZone( ListenableFuture<Volume> createVolumeFromSnapshotInAvailabilityZone(
@EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone, @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone,
@FormParam("SnapshotId") String snapshotId); @FormParam("SnapshotId") String snapshotId);
/** /**
@ -90,7 +88,7 @@ public interface ElasticBlockStoreAsyncClient {
@FormParams(keys = ACTION, values = "CreateVolume") @FormParams(keys = ACTION, values = "CreateVolume")
@XMLResponseParser(CreateVolumeResponseHandler.class) @XMLResponseParser(CreateVolumeResponseHandler.class)
ListenableFuture<Volume> createVolumeFromSnapshotInAvailabilityZone( ListenableFuture<Volume> 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); @FormParam("Size") int size, @FormParam("SnapshotId") String snapshotId);
/** /**
@ -101,7 +99,7 @@ public interface ElasticBlockStoreAsyncClient {
@FormParams(keys = ACTION, values = "CreateVolume") @FormParams(keys = ACTION, values = "CreateVolume")
@XMLResponseParser(CreateVolumeResponseHandler.class) @XMLResponseParser(CreateVolumeResponseHandler.class)
ListenableFuture<Volume> createVolumeInAvailabilityZone( ListenableFuture<Volume> createVolumeInAvailabilityZone(
@EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone, @EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone,
@FormParam("Size") int size); @FormParam("Size") int size);
/** /**

View File

@ -23,9 +23,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment; 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.Permission;
import org.jclouds.aws.ec2.domain.Snapshot; import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.aws.ec2.domain.Volume; 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" * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html"
* /> * />
*/ */
Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone, Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone,
String snapshotId); String snapshotId);
/** /**
@ -95,7 +93,7 @@ public interface ElasticBlockStoreClient {
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html"
* /> * />
*/ */
Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone, Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone,
int size, String snapshotId); int size, String snapshotId);
/** /**
@ -120,7 +118,7 @@ public interface ElasticBlockStoreClient {
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" * "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 * Describes the specified Amazon EBS volumes that you own. If you do not specify one or more

View File

@ -88,7 +88,7 @@ public interface InstanceAsyncClient {
@XMLResponseParser(RunInstancesResponseHandler.class) @XMLResponseParser(RunInstancesResponseHandler.class)
ListenableFuture<Reservation> runInstancesInRegion( ListenableFuture<Reservation> runInstancesInRegion(
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region, @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("ImageId") String imageId, @FormParam("MinCount") int minCount,
@FormParam("MaxCount") int maxCount, RunInstancesOptions... options); @FormParam("MaxCount") int maxCount, RunInstancesOptions... options);

View File

@ -134,7 +134,7 @@ public interface InstanceClient {
* @see RunInstancesOptions * @see RunInstancesOptions
*/ */
Reservation runInstancesInRegion(@Nullable String region, Reservation runInstancesInRegion(@Nullable String region,
@Nullable AvailabilityZone nullableAvailabilityZone, String imageId, int minCount, @Nullable String nullableAvailabilityZone, String imageId, int minCount,
int maxCount, RunInstancesOptions... options); int maxCount, RunInstancesOptions... options);
/** /**

View File

@ -70,10 +70,11 @@ public class EC2Utils {
return null; return null;
} }
public static AvailabilityZone findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest) { public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
for (Object arg : gRequest.getArgs()) { for (Object arg : gRequest.getArgs()) {
if (arg instanceof AvailabilityZone) { if (arg instanceof String) {
return (AvailabilityZone) arg; String zone = (String) arg;
if(AvailabilityZone.zones.contains(zone)) return zone;
} }
} }
return null; return null;

View File

@ -28,12 +28,9 @@ import java.util.SortedSet;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Attachment; 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.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.Reservation; import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RootDeviceType; import org.jclouds.aws.ec2.domain.RootDeviceType;
import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.domain.RunningInstance;
@ -81,7 +78,7 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
private String keyName; private String keyName;
private Date launchTime; private Date launchTime;
private boolean monitoring; private boolean monitoring;
private AvailabilityZone availabilityZone; private String availabilityZone;
private String platform; private String platform;
private String privateDnsName; private String privateDnsName;
private InetAddress privateIpAddress; private InetAddress privateIpAddress;
@ -153,7 +150,7 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
} else if (qName.equals("enabled")) { } else if (qName.equals("enabled")) {
monitoring = Boolean.parseBoolean(currentOrNull()); monitoring = Boolean.parseBoolean(currentOrNull());
} else if (qName.equals("availabilityZone")) { } else if (qName.equals("availabilityZone")) {
availabilityZone = AvailabilityZone.fromValue(currentOrNull()); availabilityZone = currentOrNull();
} else if (qName.equals("platform")) { } else if (qName.equals("platform")) {
platform = currentOrNull(); platform = currentOrNull();
} else if (qName.equals("privateDnsName")) { } else if (qName.equals("privateDnsName")) {

View File

@ -27,10 +27,8 @@ import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Attachment; 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.domain.Volume;
import org.jclouds.aws.ec2.util.EC2Utils; import org.jclouds.aws.ec2.util.EC2Utils;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
@ -56,12 +54,12 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
@EC2 @EC2
String defaultRegion; String defaultRegion;
@Inject @Inject
protected Map<AvailabilityZone, String> availabilityZoneToRegion; protected Map<String, String> availabilityZoneToRegion;
private String id; private String id;
private int size; private int size;
private String snapshotId; private String snapshotId;
private AvailabilityZone availabilityZone; private String availabilityZone;
private Volume.Status volumeStatus; private Volume.Status volumeStatus;
private Date createTime; private Date createTime;
private Set<Attachment> attachments = Sets.newLinkedHashSet(); private Set<Attachment> attachments = Sets.newLinkedHashSet();
@ -96,13 +94,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
} else if (qName.equals("size")) { } else if (qName.equals("size")) {
size = Integer.parseInt(currentText.toString().trim()); size = Integer.parseInt(currentText.toString().trim());
} else if (qName.equals("availabilityZone")) { } else if (qName.equals("availabilityZone")) {
String availabilityZoneName = currentText.toString().trim(); availabilityZone = currentText.toString().trim();
try {
availabilityZone = AvailabilityZone.fromValue(availabilityZoneName);
} catch (IllegalArgumentException e) {
logger.warn(e, "unsupported availability zone: %s", availabilityZoneName);
availabilityZone = AvailabilityZone.UNKNOWN;
}
} else if (qName.equals("volumeId")) { } else if (qName.equals("volumeId")) {
if (inAttachmentSet) { if (inAttachmentSet) {
volumeId = currentText.toString().trim(); volumeId = currentText.toString().trim();
@ -166,7 +158,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
super.setContext(request); super.setContext(request);
region = EC2Utils.findRegionInArgsOrNull(request); region = EC2Utils.findRegionInArgsOrNull(request);
if (region == null) { if (region == null) {
AvailabilityZone zone = EC2Utils.findAvailabilityZoneInArgsOrNull(request); String zone = EC2Utils.findAvailabilityZoneInArgsOrNull(request);
if (zone != null) { if (zone != null) {
region = checkNotNull(availabilityZoneToRegion.get(zone), String.format( region = checkNotNull(availabilityZoneToRegion.get(zone), String.format(
"zone %s not in %s", zone, availabilityZoneToRegion)); "zone %s not in %s", zone, availabilityZoneToRegion));

View File

@ -22,8 +22,6 @@ import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo; import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo.State; import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo.State;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
@ -41,11 +39,10 @@ public class DescribeAvailabilityZonesResponseHandler extends
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private Set<AvailabilityZoneInfo> availablilityZones = Sets.newLinkedHashSet(); private Set<AvailabilityZoneInfo> availablilityZones = Sets.newLinkedHashSet();
private AvailabilityZone zone; private String zone;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
private String region; private String region;
private String zoneName;
private State zoneState; private State zoneState;
private boolean inMessageSet; private boolean inMessageSet;
private Set<String> messages = Sets.newHashSet(); private Set<String> messages = Sets.newHashSet();
@ -62,13 +59,7 @@ public class DescribeAvailabilityZonesResponseHandler extends
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
if (qName.equals("zoneName")) { if (qName.equals("zoneName")) {
zoneName = currentText.toString().trim(); zone = currentText.toString().trim();
try {
zone = AvailabilityZone.fromValue(zoneName);
} catch (IllegalArgumentException e) {
logger.warn(e, "unsupported region: %s", zoneName);
zone = AvailabilityZone.UNKNOWN;
}
} else if (qName.equals("regionName")) { } else if (qName.equals("regionName")) {
try { try {
region = currentText.toString().trim(); region = currentText.toString().trim();
@ -88,10 +79,9 @@ public class DescribeAvailabilityZonesResponseHandler extends
} else if (qName.equals("messageSet")) { } else if (qName.equals("messageSet")) {
inMessageSet = false; inMessageSet = false;
} else if (qName.equals("item") && !inMessageSet) { } else if (qName.equals("item") && !inMessageSet) {
availablilityZones.add(new AvailabilityZoneInfo(zoneName, zone, zoneState, region, availablilityZones.add(new AvailabilityZoneInfo(zone, zoneState, region,
messages)); messages));
this.zone = null; this.zone = null;
this.zoneName = null;
this.region = null; this.region = null;
this.zoneState = null; this.zoneState = null;
this.messages = Sets.newHashSet(); this.messages = Sets.newHashSet();

View File

@ -34,7 +34,6 @@ import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory; import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo; import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
@ -75,8 +74,8 @@ public class AvailabilityZoneAndRegionClientLiveTest {
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 2 : allResults.size(); assert allResults.size() >= 2 : allResults.size();
Iterator<AvailabilityZoneInfo> iterator = allResults.iterator(); Iterator<AvailabilityZoneInfo> iterator = allResults.iterator();
AvailabilityZone id1 = iterator.next().getZone(); String id1 = iterator.next().getZone();
AvailabilityZone id2 = iterator.next().getZone(); String id2 = iterator.next().getZone();
SortedSet<AvailabilityZoneInfo> twoResults = Sets.newTreeSet(client SortedSet<AvailabilityZoneInfo> twoResults = Sets.newTreeSet(client
.describeAvailabilityZonesInRegion(region, availabilityZones(id1, id2))); .describeAvailabilityZonesInRegion(region, availabilityZones(id1, id2)));
assertNotNull(twoResults); assertNotNull(twoResults);

View File

@ -108,8 +108,8 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Singleton @Singleton
@Provides @Provides
Map<AvailabilityZone, String> provideAvailabilityZoneRegionMap() { Map<String, String> provideAvailabilityZoneRegionMap() {
return ImmutableMap.<AvailabilityZone, String> of(AvailabilityZone.US_EAST_1A, return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A,
Region.US_EAST_1); Region.US_EAST_1);
} }
}; };

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone; import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable; import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
import org.jclouds.aws.ec2.options.CreateSnapshotOptions; import org.jclouds.aws.ec2.options.CreateSnapshotOptions;
@ -57,7 +56,7 @@ public class ElasticBlockStoreAsyncClientTest extends
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod( Method method = ElasticBlockStoreAsyncClient.class.getMethod(
"createVolumeInAvailabilityZone", AvailabilityZone.class, int.class); "createVolumeInAvailabilityZone", String.class, int.class);
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest( GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
method, AvailabilityZone.US_EAST_1A, 20); method, AvailabilityZone.US_EAST_1A, 20);
@ -77,7 +76,7 @@ public class ElasticBlockStoreAsyncClientTest extends
public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod( Method method = ElasticBlockStoreAsyncClient.class.getMethod(
"createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class, String.class); "createVolumeFromSnapshotInAvailabilityZone", String.class, String.class);
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest( GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
method, AvailabilityZone.US_EAST_1A, "snapshotId"); method, AvailabilityZone.US_EAST_1A, "snapshotId");
@ -97,7 +96,7 @@ public class ElasticBlockStoreAsyncClientTest extends
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, public void testCreateVolumeFromSnapShotWithSize() throws SecurityException,
NoSuchMethodException, IOException { NoSuchMethodException, IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod( Method method = ElasticBlockStoreAsyncClient.class.getMethod(
"createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class, int.class, "createVolumeFromSnapshotInAvailabilityZone", String.class, int.class,
String.class); String.class);
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest( GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId"); method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");

View File

@ -113,7 +113,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException { public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class,
AvailabilityZone.class, String.class, int.class, int.class, Array.newInstance( String.class, String.class, int.class, int.class, Array.newInstance(
RunInstancesOptions.class, 0).getClass()); RunInstancesOptions.class, 0).getClass());
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null, GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
null, "ami-voo", 1, 1); null, "ami-voo", 1, 1);
@ -134,7 +134,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class,
AvailabilityZone.class, String.class, int.class, int.class, Array.newInstance( String.class, String.class, int.class, int.class, Array.newInstance(
RunInstancesOptions.class, 0).getClass()); RunInstancesOptions.class, 0).getClass());
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", 1, 5, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", 1, 5,

View File

@ -67,8 +67,8 @@ public class BaseEC2HandlerTest extends BaseHandlerTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Singleton @Singleton
@Provides @Provides
Map<AvailabilityZone, String> provideAvailabilityZoneRegionMap() { Map<String, String> provideAvailabilityZoneRegionMap() {
return ImmutableMap.<AvailabilityZone, String> of(AvailabilityZone.US_EAST_1A, return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A,
Region.US_EAST_1); Region.US_EAST_1);
} }
}); });

View File

@ -44,15 +44,19 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
InputStream is = getClass().getResourceAsStream("/ec2/availabilityZones.xml"); InputStream is = getClass().getResourceAsStream("/ec2/availabilityZones.xml");
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of( Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
new AvailabilityZoneInfo("us-east-1a", AvailabilityZone.US_EAST_1A,
AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A,
.<String> of()), new AvailabilityZoneInfo("us-east-1b", AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet
AvailabilityZone.US_EAST_1B, AvailabilityZoneInfo.State.AVAILABLE, .<String> of()),
Region.US_EAST_1, ImmutableSet.<String> of()), new AvailabilityZoneInfo( new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B,
"us-east-1c", AvailabilityZone.US_EAST_1C, AvailabilityZoneInfo.State.AVAILABLE,
AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet Region.US_EAST_1, ImmutableSet.<String> of()),
.<String> of("our service is awesome")), new AvailabilityZoneInfo(
"us-east-1d", AvailabilityZone.US_EAST_1D, new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C,
AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet
.<String> of("our service is awesome")),
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D,
AvailabilityZoneInfo.State.UNKNOWN, Region.US_EAST_1, ImmutableSet AvailabilityZoneInfo.State.UNKNOWN, Region.US_EAST_1, ImmutableSet
.<String> of())); .<String> of()));
Set<AvailabilityZoneInfo> result = factory.create( Set<AvailabilityZoneInfo> result = factory.create(

View File

@ -51,7 +51,7 @@ Here's an example of creating and running a small linux node with the tag webser
See http://code.google.com/p/jclouds for details." See http://code.google.com/p/jclouds for details."
(:use org.jclouds.core (:use org.jclouds.core
clojure.contrib.logging) (clojure.contrib logging core))
(:import java.io.File (:import java.io.File
java.util.Properties java.util.Properties
[org.jclouds.domain Location] [org.jclouds.domain Location]
@ -304,7 +304,7 @@ See http://code.google.com/p/jclouds for details."
(defn location (defn location
"Returns the compute node's location id" "Returns the compute node's location id"
[#^ComputeMetadata node] [#^ComputeMetadata node]
(.getLocationId node)) (-?> node .getLocation .getId))
(define-accessors Template image size location options) (define-accessors Template image size location options)
(define-accessors Image version os-family os-description architecture) (define-accessors Image version os-family os-description architecture)