mirror of https://github.com/apache/jclouds.git
Issue 203 normalized location across blobstore and compute
This commit is contained in:
parent
950776c0e9
commit
021e5e18e0
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Futures.compose;
|
import static com.google.common.util.concurrent.Futures.compose;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||||
import org.jclouds.concurrent.ConcurrentUtils;
|
import org.jclouds.concurrent.ConcurrentUtils;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
|
@ -78,13 +80,15 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
@Inject
|
@Inject
|
||||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
AtmosAsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
||||||
|
Location defaultLocation, Map<String, ? extends Location> locations,
|
||||||
|
|
||||||
AtmosStorageAsyncClient async, AtmosStorageClient sync, ObjectToBlob object2Blob,
|
AtmosStorageAsyncClient async, AtmosStorageClient sync, ObjectToBlob object2Blob,
|
||||||
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
DirectoryEntryListToResourceMetadataList container2ResourceList,
|
DirectoryEntryListToResourceMetadataList container2ResourceList,
|
||||||
EncryptionService encryptionService, BlobToHttpGetOptions blob2ObjectGetOptions,
|
EncryptionService encryptionService, BlobToHttpGetOptions blob2ObjectGetOptions,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
||||||
super(context, blobUtils, service);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
this.async = checkNotNull(async, "async");
|
this.async = checkNotNull(async, "async");
|
||||||
|
@ -119,7 +123,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
* Note location is ignored
|
* Note location is ignored
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Boolean> createContainerInLocation(String location, String container) {
|
public ListenableFuture<Boolean> createContainerInLocation(Location location, String container) {
|
||||||
return compose(async.createDirectory(container), new Function<URI, Boolean>() {
|
return compose(async.createDirectory(container), new Function<URI, Boolean>() {
|
||||||
|
|
||||||
public Boolean apply(URI from) {
|
public Boolean apply(URI from) {
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.atmosonline.saas.blobstore;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -42,6 +44,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
||||||
import org.jclouds.blobstore.internal.BaseBlobStore;
|
import org.jclouds.blobstore.internal.BaseBlobStore;
|
||||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
|
@ -61,13 +64,14 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AtmosBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, AtmosStorageClient sync,
|
AtmosBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, Location defaultLocation,
|
||||||
|
Map<String, ? extends Location> locations, AtmosStorageClient sync,
|
||||||
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
DirectoryEntryListToResourceMetadataList container2ResourceList,
|
DirectoryEntryListToResourceMetadataList container2ResourceList,
|
||||||
EncryptionService encryptionService, BlobToHttpGetOptions blob2ObjectGetOptions,
|
EncryptionService encryptionService, BlobToHttpGetOptions blob2ObjectGetOptions,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
||||||
super(context, blobUtils);
|
super(context, blobUtils, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions,
|
this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions,
|
||||||
|
@ -107,7 +111,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
* directory name
|
* directory name
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createContainerInLocation(String location, String container) {
|
public boolean createContainerInLocation(Location location, String container) {
|
||||||
sync.createDirectory(container);
|
sync.createDirectory(container);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas.blobstore.config;
|
package org.jclouds.atmosonline.saas.blobstore.config;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
||||||
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
||||||
import org.jclouds.atmosonline.saas.blobstore.AtmosAsyncBlobStore;
|
import org.jclouds.atmosonline.saas.blobstore.AtmosAsyncBlobStore;
|
||||||
|
@ -31,7 +35,12 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -56,4 +65,15 @@ public class AtmosBlobStoreContextModule extends AtmosStorageContextModule {
|
||||||
bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class);
|
bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
Location getLocation() {
|
||||||
|
return new LocationImpl(LocationScope.ZONE, "UNKNOWN", "TODO", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
Map<String, ? extends Location> provideLocations(Location location) {
|
||||||
|
return ImmutableMap.of(location.getId(), location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas.blobstore.functions;
|
package org.jclouds.atmosonline.saas.blobstore.functions;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.atmosonline.saas.domain.BoundedSet;
|
import org.jclouds.atmosonline.saas.domain.BoundedSet;
|
||||||
|
@ -29,6 +30,7 @@ import org.jclouds.blobstore.domain.StorageType;
|
||||||
import org.jclouds.blobstore.domain.internal.BlobMetadataImpl;
|
import org.jclouds.blobstore.domain.internal.BlobMetadataImpl;
|
||||||
import org.jclouds.blobstore.domain.internal.PageSetImpl;
|
import org.jclouds.blobstore.domain.internal.PageSetImpl;
|
||||||
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl;
|
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -40,6 +42,12 @@ import com.google.common.collect.Maps;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DirectoryEntryListToResourceMetadataList implements
|
public class DirectoryEntryListToResourceMetadataList implements
|
||||||
Function<BoundedSet<? extends DirectoryEntry>, PageSet<? extends StorageMetadata>> {
|
Function<BoundedSet<? extends DirectoryEntry>, PageSet<? extends StorageMetadata>> {
|
||||||
|
private Location defaultLocation;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DirectoryEntryListToResourceMetadataList(Location defaultLocation) {
|
||||||
|
this.defaultLocation = defaultLocation;
|
||||||
|
}
|
||||||
|
|
||||||
public PageSet<? extends StorageMetadata> apply(BoundedSet<? extends DirectoryEntry> from) {
|
public PageSet<? extends StorageMetadata> apply(BoundedSet<? extends DirectoryEntry> from) {
|
||||||
|
|
||||||
|
@ -51,12 +59,12 @@ public class DirectoryEntryListToResourceMetadataList implements
|
||||||
: StorageType.BLOB;
|
: StorageType.BLOB;
|
||||||
if (type == StorageType.FOLDER)
|
if (type == StorageType.FOLDER)
|
||||||
return new StorageMetadataImpl(type, from.getObjectID(), from
|
return new StorageMetadataImpl(type, from.getObjectID(), from
|
||||||
.getObjectName(), null, null, null, null, null, Maps
|
.getObjectName(), defaultLocation, null, null, null, null, Maps
|
||||||
.<String, String> newHashMap());
|
.<String, String> newHashMap());
|
||||||
else
|
else
|
||||||
return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), null,
|
return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(),
|
||||||
null, null, null, null, Maps.<String, String> newHashMap(), null,
|
defaultLocation, null, null, null, null, Maps
|
||||||
null);
|
.<String, String> newHashMap(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}), from.getToken());
|
}), from.getToken());
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient {
|
||||||
container = directoryName;
|
container = directoryName;
|
||||||
path = null;
|
path = null;
|
||||||
}
|
}
|
||||||
return Futures.compose(blobStore.createContainerInLocation("default", container),
|
return Futures.compose(blobStore.createContainerInLocation(null, container),
|
||||||
new Function<Boolean, URI>() {
|
new Function<Boolean, URI>() {
|
||||||
|
|
||||||
public URI apply(Boolean from) {
|
public URI apply(Boolean from) {
|
||||||
|
|
|
@ -33,11 +33,6 @@ import com.google.common.base.CaseFormat;
|
||||||
*/
|
*/
|
||||||
public enum Region {
|
public enum Region {
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow the default region to be chosen based on the user-configured endpoint.
|
|
||||||
*/
|
|
||||||
DEFAULT,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Region returned is unknown.
|
* Region returned is unknown.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -297,7 +297,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, ? extends Image> provideImages(final EC2Client sync,
|
protected Map<String, ? extends Image> provideImages(final EC2Client sync,
|
||||||
Map<Region, URI> regionMap, LogHolder holder,
|
@EC2 Map<Region, URI> regionMap, LogHolder holder,
|
||||||
Function<ComputeMetadata, String> indexer,
|
Function<ComputeMetadata, String> indexer,
|
||||||
@Named(PROPERTY_EC2_AMI_OWNERS) String[] amiOwners, ImageParser parser)
|
@Named(PROPERTY_EC2_AMI_OWNERS) String[] amiOwners, ImageParser parser)
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute.functions;
|
package org.jclouds.aws.ec2.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -58,6 +60,8 @@ public class CreateNewKeyPair implements Function<RegionTag, KeyPair> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyPair createNewKeyPairInRegion(Region region, String tag) {
|
private KeyPair createNewKeyPairInRegion(Region region, String tag) {
|
||||||
|
checkNotNull(region, "region");
|
||||||
|
checkNotNull(tag, "tag");
|
||||||
logger.debug(">> creating keyPair region(%s) tag(%s)", region, tag);
|
logger.debug(">> creating keyPair region(%s) tag(%s)", region, tag);
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
while (keyPair == null) {
|
while (keyPair == null) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.jclouds.aws.ec2.compute.functions;
|
package org.jclouds.aws.ec2.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
@ -36,6 +38,8 @@ public class CreateSecurityGroupIfNeeded implements Function<PortsRegionTag, Str
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSecurityGroupInRegion(Region region, String name, int... ports) {
|
private void createSecurityGroupInRegion(Region region, String name, int... ports) {
|
||||||
|
checkNotNull(region, "region");
|
||||||
|
checkNotNull(name, "name");
|
||||||
logger.debug(">> creating securityGroup region(%s) name(%s)", region, name);
|
logger.debug(">> creating securityGroup region(%s) name(%s)", region, name);
|
||||||
try {
|
try {
|
||||||
ec2Client.getSecurityGroupServices().createSecurityGroupInRegion(region, name, name);
|
ec2Client.getSecurityGroupServices().createSecurityGroupInRegion(region, name, name);
|
||||||
|
@ -47,9 +51,11 @@ public class CreateSecurityGroupIfNeeded implements Function<PortsRegionTag, Str
|
||||||
name, IpProtocol.TCP, port, port, "0.0.0.0/0");
|
name, IpProtocol.TCP, port, port, "0.0.0.0/0");
|
||||||
logger.debug("<< authorized securityGroup(%s)", name);
|
logger.debug("<< authorized securityGroup(%s)", name);
|
||||||
}
|
}
|
||||||
logger.debug(">> authorizing securityGroup region(%s) name(%s) permission to itself", region, name);
|
logger.debug(">> authorizing securityGroup region(%s) name(%s) permission to itself",
|
||||||
String myOwnerId = Iterables.get(ec2Client.getSecurityGroupServices()
|
region, name);
|
||||||
.describeSecurityGroupsInRegion(region),0).getOwnerId();
|
String myOwnerId = Iterables.get(
|
||||||
|
ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region), 0)
|
||||||
|
.getOwnerId();
|
||||||
ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name,
|
ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name,
|
||||||
new UserIdGroupPair(myOwnerId, name));
|
new UserIdGroupPair(myOwnerId, name));
|
||||||
logger.debug("<< authorized securityGroup(%s)", name);
|
logger.debug("<< authorized securityGroup(%s)", name);
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class EC2RestClientModule extends AbstractModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@EC2
|
@EC2
|
||||||
Region provideCurrentRegion(Map<Region, URI> regionMap, @EC2 URI currentUri) {
|
Region provideCurrentRegion(@EC2 Map<Region, URI> regionMap, @EC2 URI currentUri) {
|
||||||
ImmutableBiMap<URI, Region> map = ImmutableBiMap.copyOf(regionMap).inverse();
|
ImmutableBiMap<URI, Region> map = ImmutableBiMap.copyOf(regionMap).inverse();
|
||||||
Region region = map.get(currentUri);
|
Region region = map.get(currentUri);
|
||||||
assert region != null : currentUri + " not in " + map;
|
assert region != null : currentUri + " not in " + map;
|
||||||
|
@ -124,6 +124,7 @@ public class EC2RestClientModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@EC2
|
||||||
Map<Region, URI> provideRegions(AvailabilityZoneAndRegionClient client) {
|
Map<Region, URI> provideRegions(AvailabilityZoneAndRegionClient client) {
|
||||||
return client.describeRegions();
|
return client.describeRegions();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ public class EC2RestClientModule extends AbstractModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
Map<AvailabilityZone, Region> provideAvailabilityZoneToRegions(
|
Map<AvailabilityZone, Region> provideAvailabilityZoneToRegions(
|
||||||
AvailabilityZoneAndRegionClient client, Map<Region, URI> regions) {
|
AvailabilityZoneAndRegionClient client, @EC2 Map<Region, URI> regions) {
|
||||||
Map<AvailabilityZone, Region> map = Maps.newHashMap();
|
Map<AvailabilityZone, Region> map = Maps.newHashMap();
|
||||||
for (Region region : regions.keySet()) {
|
for (Region region : regions.keySet()) {
|
||||||
for (AvailabilityZoneInfo zoneInfo : client.describeAvailabilityZonesInRegion(region)) {
|
for (AvailabilityZoneInfo zoneInfo : client.describeAvailabilityZonesInRegion(region)) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
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.AvailabilityZone;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -39,7 +40,7 @@ public class AvailabilityZoneToEndpoint implements Function<Object, URI> {
|
||||||
private final Map<Region, URI> regionToEndpoint;
|
private final Map<Region, URI> regionToEndpoint;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AvailabilityZoneToEndpoint(Map<Region, URI> regionToEndpoint,
|
public AvailabilityZoneToEndpoint(@EC2 Map<Region, URI> regionToEndpoint,
|
||||||
Map<AvailabilityZone, Region> availabilityZoneToRegion) {
|
Map<AvailabilityZone, Region> availabilityZoneToRegion) {
|
||||||
this.regionToEndpoint = regionToEndpoint;
|
this.regionToEndpoint = regionToEndpoint;
|
||||||
this.availabilityZoneToRegion = availabilityZoneToRegion;
|
this.availabilityZoneToRegion = availabilityZoneToRegion;
|
||||||
|
|
|
@ -39,13 +39,13 @@ public class RegionToEndpoint implements Function<Object, URI> {
|
||||||
private final URI defaultUri;
|
private final URI defaultUri;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RegionToEndpoint(Map<Region, URI> regionToEndpoint, @EC2 URI defaultUri) {
|
public RegionToEndpoint(@EC2 Map<Region, URI> regionToEndpoint, @EC2 URI defaultUri) {
|
||||||
this.regionToEndpoint = regionToEndpoint;
|
this.regionToEndpoint = regionToEndpoint;
|
||||||
this.defaultUri = defaultUri;
|
this.defaultUri = defaultUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI apply(Object from) {
|
public URI apply(Object from) {
|
||||||
return from.equals(Region.DEFAULT) ? defaultUri : regionToEndpoint.get(from);
|
return from == null ? defaultUri : regionToEndpoint.get(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions;
|
||||||
* import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.*
|
* import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.*
|
||||||
* <p/>
|
* <p/>
|
||||||
* EC2Client client = // get connection
|
* EC2Client client = // get connection
|
||||||
* client.getElasticBlockStoreServices().detachVolumeInRegion(Region.DEFAULT, id, fromDevice("123125").force());
|
* client.getElasticBlockStoreServices().detachVolumeInRegion(null, id, fromDevice("123125").force());
|
||||||
* <code>
|
* <code>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -74,7 +75,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeImages")
|
@FormParams(keys = ACTION, values = "DescribeImages")
|
||||||
@XMLResponseParser(DescribeImagesResponseHandler.class)
|
@XMLResponseParser(DescribeImagesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<Image>> describeImagesInRegion(
|
ListenableFuture<? extends Set<Image>> describeImagesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
DescribeImagesOptions... options);
|
DescribeImagesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +86,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "CreateImage")
|
@FormParams(keys = ACTION, values = "CreateImage")
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
ListenableFuture<String> createImageInRegion(
|
ListenableFuture<String> createImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("Name") String name, @FormParam("InstanceId") String instanceId,
|
@FormParam("Name") String name, @FormParam("InstanceId") String instanceId,
|
||||||
CreateImageOptions... options);
|
CreateImageOptions... options);
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ public interface AMIAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeregisterImage")
|
@FormParams(keys = ACTION, values = "DeregisterImage")
|
||||||
ListenableFuture<Void> deregisterImageInRegion(
|
ListenableFuture<Void> deregisterImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +108,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "RegisterImage")
|
@FormParams(keys = ACTION, values = "RegisterImage")
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
ListenableFuture<String> registerImageFromManifestInRegion(
|
ListenableFuture<String> registerImageFromManifestInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("Name") String imageName, @FormParam("ImageLocation") String pathToManifest,
|
@FormParam("Name") String imageName, @FormParam("ImageLocation") String pathToManifest,
|
||||||
RegisterImageOptions... options);
|
RegisterImageOptions... options);
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ public interface AMIAsyncClient {
|
||||||
"RegisterImage", "/dev/sda1", "/dev/sda1" })
|
"RegisterImage", "/dev/sda1", "/dev/sda1" })
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
ListenableFuture<String> registerUnixImageBackedByEbsInRegion(
|
ListenableFuture<String> registerUnixImageBackedByEbsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("Name") String imageName,
|
@FormParam("Name") String imageName,
|
||||||
@FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId,
|
@FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId,
|
||||||
RegisterImageBackedByEbsOptions... options);
|
RegisterImageBackedByEbsOptions... options);
|
||||||
|
@ -132,7 +133,7 @@ public interface AMIAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" })
|
||||||
ListenableFuture<Void> resetLaunchPermissionsOnImageInRegion(
|
ListenableFuture<Void> resetLaunchPermissionsOnImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +144,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"add", "launchPermission" })
|
"add", "launchPermission" })
|
||||||
ListenableFuture<Void> addLaunchPermissionsToImageInRegion(
|
ListenableFuture<Void> addLaunchPermissionsToImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
@ -156,7 +157,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"remove", "launchPermission" })
|
"remove", "launchPermission" })
|
||||||
ListenableFuture<Void> removeLaunchPermissionsFromImageInRegion(
|
ListenableFuture<Void> removeLaunchPermissionsFromImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
@ -170,7 +171,7 @@ public interface AMIAsyncClient {
|
||||||
"launchPermission" })
|
"launchPermission" })
|
||||||
@XMLResponseParser(PermissionHandler.class)
|
@XMLResponseParser(PermissionHandler.class)
|
||||||
ListenableFuture<Permission> getLaunchPermissionForImageInRegion(
|
ListenableFuture<Permission> getLaunchPermissionForImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +182,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
|
||||||
@XMLResponseParser(ProductCodesHandler.class)
|
@XMLResponseParser(ProductCodesHandler.class)
|
||||||
ListenableFuture<? extends Set<String>> getProductCodesForImageInRegion(
|
ListenableFuture<? extends Set<String>> getProductCodesForImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +194,7 @@ public interface AMIAsyncClient {
|
||||||
"blockDeviceMapping" })
|
"blockDeviceMapping" })
|
||||||
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
||||||
ListenableFuture<? extends Map<String, EbsBlockDevice>> getBlockDeviceMappingsForImageInRegion(
|
ListenableFuture<? extends Map<String, EbsBlockDevice>> getBlockDeviceMappingsForImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +205,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"add", "productCodes" })
|
"add", "productCodes" })
|
||||||
ListenableFuture<Void> addProductCodesToImageInRegion(
|
ListenableFuture<Void> addProductCodesToImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
|
@ -216,7 +217,7 @@ public interface AMIAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"remove", "productCodes" })
|
"remove", "productCodes" })
|
||||||
ListenableFuture<Void> removeProductCodesFromImageInRegion(
|
ListenableFuture<Void> removeProductCodesFromImageInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.domain.Permission;
|
import org.jclouds.aws.ec2.domain.Permission;
|
||||||
|
@ -56,7 +58,7 @@ public interface AMIClient {
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
Set<Image> describeImagesInRegion(Region region, DescribeImagesOptions... options);
|
Set<Image> describeImagesInRegion(@Nullable Region region, DescribeImagesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Product Codes of an image.
|
* Returns the Product Codes of an image.
|
||||||
|
@ -72,7 +74,7 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
Set<String> getProductCodesForImageInRegion(Region region, String imageId);
|
Set<String> getProductCodesForImageInRegion(@Nullable Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of device name to block device for the image.
|
* Returns a map of device name to block device for the image.
|
||||||
|
@ -88,7 +90,7 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
Map<String, EbsBlockDevice> getBlockDeviceMappingsForImageInRegion(Region region, String imageId);
|
Map<String, EbsBlockDevice> getBlockDeviceMappingsForImageInRegion(@Nullable Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
* Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
||||||
|
@ -112,7 +114,7 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String createImageInRegion(Region region, String name, String instanceId,
|
String createImageInRegion(@Nullable Region region, String name, String instanceId,
|
||||||
CreateImageOptions... options);
|
CreateImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +134,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deregisterImageInRegion(Region region, String imageId);
|
void deregisterImageInRegion(@Nullable Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
||||||
|
@ -162,7 +164,7 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String registerImageFromManifestInRegion(Region region, String name, String pathToManifest,
|
String registerImageFromManifestInRegion(@Nullable Region region, String name, String pathToManifest,
|
||||||
RegisterImageOptions... options);
|
RegisterImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +199,7 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String registerUnixImageBackedByEbsInRegion(Region region, String name, String ebsSnapshotId,
|
String registerUnixImageBackedByEbsInRegion(@Nullable Region region, String name, String ebsSnapshotId,
|
||||||
RegisterImageBackedByEbsOptions... options);
|
RegisterImageBackedByEbsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +216,7 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
Permission getLaunchPermissionForImageInRegion(Region region, String imageId);
|
Permission getLaunchPermissionForImageInRegion(@Nullable Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@code launchPermission}s to an AMI.
|
* Adds {@code launchPermission}s to an AMI.
|
||||||
|
@ -234,7 +236,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void addLaunchPermissionsToImageInRegion(Region region, Iterable<String> userIds,
|
void addLaunchPermissionsToImageInRegion(@Nullable Region region, Iterable<String> userIds,
|
||||||
Iterable<String> userGroups, String imageId);
|
Iterable<String> userGroups, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +253,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void resetLaunchPermissionsOnImageInRegion(Region region, String imageId);
|
void resetLaunchPermissionsOnImageInRegion(@Nullable Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@code launchPermission}s from an AMI.
|
* Removes {@code launchPermission}s from an AMI.
|
||||||
|
@ -271,7 +273,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void removeLaunchPermissionsFromImageInRegion(Region region, Iterable<String> userIds,
|
void removeLaunchPermissionsFromImageInRegion(@Nullable Region region, Iterable<String> userIds,
|
||||||
Iterable<String> userGroups, String imageId);
|
Iterable<String> userGroups, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -290,7 +292,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void addProductCodesToImageInRegion(Region region, Iterable<String> productCodes, String imageId);
|
void addProductCodesToImageInRegion(@Nullable Region region, Iterable<String> productCodes, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@code productCode}s from an AMI.
|
* Removes {@code productCode}s from an AMI.
|
||||||
|
@ -308,6 +310,6 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void removeProductCodesFromImageInRegion(Region region, Iterable<String> productCodes,
|
void removeProductCodesFromImageInRegion(@Nullable Region region, Iterable<String> productCodes,
|
||||||
String imageId);
|
String imageId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ public interface AvailabilityZoneAndRegionAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeAvailabilityZones")
|
@FormParams(keys = ACTION, values = "DescribeAvailabilityZones")
|
||||||
@XMLResponseParser(DescribeAvailabilityZonesResponseHandler.class)
|
@XMLResponseParser(DescribeAvailabilityZonesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<AvailabilityZoneInfo>> describeAvailabilityZonesInRegion(
|
ListenableFuture<? extends Set<AvailabilityZoneInfo>> describeAvailabilityZonesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
DescribeAvailabilityZonesOptions... options);
|
DescribeAvailabilityZonesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
|
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
|
||||||
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
||||||
|
@ -47,7 +49,7 @@ public interface AvailabilityZoneAndRegionClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAvailabilityZones.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAvailabilityZones.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<AvailabilityZoneInfo> describeAvailabilityZonesInRegion(Region region,
|
Set<AvailabilityZoneInfo> describeAvailabilityZonesInRegion(@Nullable Region region,
|
||||||
DescribeAvailabilityZonesOptions... options);
|
DescribeAvailabilityZonesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -111,7 +112,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeVolumes")
|
@FormParams(keys = ACTION, values = "DescribeVolumes")
|
||||||
@XMLResponseParser(DescribeVolumesResponseHandler.class)
|
@XMLResponseParser(DescribeVolumesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<Volume>> describeVolumesInRegion(
|
ListenableFuture<? extends Set<Volume>> describeVolumesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindVolumeIdsToIndexedFormParams.class) String... volumeIds);
|
@BinderParam(BindVolumeIdsToIndexedFormParams.class) String... volumeIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +122,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteVolume")
|
@FormParams(keys = ACTION, values = "DeleteVolume")
|
||||||
ListenableFuture<Void> deleteVolumeInRegion(
|
ListenableFuture<Void> deleteVolumeInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("VolumeId") String volumeId);
|
@FormParam("VolumeId") String volumeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +133,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DetachVolume")
|
@FormParams(keys = ACTION, values = "DetachVolume")
|
||||||
@ExceptionParser(ReturnVoidOnVolumeAvailable.class)
|
@ExceptionParser(ReturnVoidOnVolumeAvailable.class)
|
||||||
ListenableFuture<Void> detachVolumeInRegion(
|
ListenableFuture<Void> detachVolumeInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("VolumeId") String volumeId, @FormParam("Force") boolean force,
|
@FormParam("VolumeId") String volumeId, @FormParam("Force") boolean force,
|
||||||
DetachVolumeOptions... options);
|
DetachVolumeOptions... options);
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "AttachVolume")
|
@FormParams(keys = ACTION, values = "AttachVolume")
|
||||||
@XMLResponseParser(AttachmentHandler.class)
|
@XMLResponseParser(AttachmentHandler.class)
|
||||||
ListenableFuture<Attachment> attachVolumeInRegion(
|
ListenableFuture<Attachment> attachVolumeInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("VolumeId") String volumeId, @FormParam("InstanceId") String instanceId,
|
@FormParam("VolumeId") String volumeId, @FormParam("InstanceId") String instanceId,
|
||||||
@FormParam("Device") String device);
|
@FormParam("Device") String device);
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "CreateSnapshot")
|
@FormParams(keys = ACTION, values = "CreateSnapshot")
|
||||||
@XMLResponseParser(SnapshotHandler.class)
|
@XMLResponseParser(SnapshotHandler.class)
|
||||||
ListenableFuture<Snapshot> createSnapshotInRegion(
|
ListenableFuture<Snapshot> createSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("VolumeId") String volumeId, CreateSnapshotOptions... options);
|
@FormParam("VolumeId") String volumeId, CreateSnapshotOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +168,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeSnapshots")
|
@FormParams(keys = ACTION, values = "DescribeSnapshots")
|
||||||
@XMLResponseParser(DescribeSnapshotsResponseHandler.class)
|
@XMLResponseParser(DescribeSnapshotsResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<Snapshot>> describeSnapshotsInRegion(
|
ListenableFuture<? extends Set<Snapshot>> describeSnapshotsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
DescribeSnapshotsOptions... options);
|
DescribeSnapshotsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +178,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteSnapshot")
|
@FormParams(keys = ACTION, values = "DeleteSnapshot")
|
||||||
ListenableFuture<Void> deleteSnapshotInRegion(
|
ListenableFuture<Void> deleteSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,7 +189,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = {
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = {
|
||||||
"ModifySnapshotAttribute", "add", "createVolumePermission" })
|
"ModifySnapshotAttribute", "add", "createVolumePermission" })
|
||||||
ListenableFuture<Void> addCreateVolumePermissionsToSnapshotInRegion(
|
ListenableFuture<Void> addCreateVolumePermissionsToSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
@ -201,7 +202,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = {
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = {
|
||||||
"ModifySnapshotAttribute", "remove", "createVolumePermission" })
|
"ModifySnapshotAttribute", "remove", "createVolumePermission" })
|
||||||
ListenableFuture<Void> removeCreateVolumePermissionsFromSnapshotInRegion(
|
ListenableFuture<Void> removeCreateVolumePermissionsFromSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
@ -215,7 +216,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
"createVolumePermission" })
|
"createVolumePermission" })
|
||||||
@XMLResponseParser(PermissionHandler.class)
|
@XMLResponseParser(PermissionHandler.class)
|
||||||
ListenableFuture<Permission> getCreateVolumePermissionForSnapshotInRegion(
|
ListenableFuture<Permission> getCreateVolumePermissionForSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +227,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetSnapshotAttribute",
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetSnapshotAttribute",
|
||||||
"createVolumePermission" })
|
"createVolumePermission" })
|
||||||
ListenableFuture<Void> resetCreateVolumePermissionsOnSnapshotInRegion(
|
ListenableFuture<Void> resetCreateVolumePermissionsOnSnapshotInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.aws.ec2.services;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
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.AvailabilityZone;
|
||||||
|
@ -136,7 +138,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVolumes.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVolumes.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<Volume> describeVolumesInRegion(Region region, String... volumeIds);
|
Set<Volume> describeVolumesInRegion(@Nullable Region region, String... volumeIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an Amazon EBS volume that you own. For more information about Amazon EBS, go to the
|
* Deletes an Amazon EBS volume that you own. For more information about Amazon EBS, go to the
|
||||||
|
@ -157,7 +159,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteVolume.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteVolume.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteVolumeInRegion(Region region, String volumeId);
|
void deleteVolumeInRegion(@Nullable Region region, String volumeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches an Amazon EBS volume to a running instance and exposes it as the specified device.
|
* Attaches an Amazon EBS volume to a running instance and exposes it as the specified device.
|
||||||
|
@ -197,7 +199,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DetachVolume.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DetachVolume.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void detachVolumeInRegion(Region region, String volumeId, boolean force,
|
void detachVolumeInRegion(@Nullable Region region, String volumeId, boolean force,
|
||||||
DetachVolumeOptions... options);
|
DetachVolumeOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,7 +232,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVolume.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVolume.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Attachment attachVolumeInRegion(Region region, String volumeId, String instanceId, String device);
|
Attachment attachVolumeInRegion(@Nullable Region region, String volumeId, String instanceId, String device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a snapshot of an Amazon EBS volume and stores it in Amazon S3. You can use snapshots
|
* Creates a snapshot of an Amazon EBS volume and stores it in Amazon S3. You can use snapshots
|
||||||
|
@ -267,7 +269,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Snapshot createSnapshotInRegion(Region region, String volumeId, CreateSnapshotOptions... options);
|
Snapshot createSnapshotInRegion(@Nullable Region region, String volumeId, CreateSnapshotOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about Amazon EBS snapshots available to the user. Information returned
|
* Returns information about Amazon EBS snapshots available to the user. Information returned
|
||||||
|
@ -328,7 +330,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSnapshots.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSnapshots.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<Snapshot> describeSnapshotsInRegion(Region region, DescribeSnapshotsOptions... options);
|
Set<Snapshot> describeSnapshotsInRegion(@Nullable Region region, DescribeSnapshotsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a snapshot of an Amazon EBS volume that you own. For more information, go to the
|
* Deletes a snapshot of an Amazon EBS volume that you own. For more information, go to the
|
||||||
|
@ -345,7 +347,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSnapshot.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSnapshot.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteSnapshotInRegion(Region region, String snapshotId);
|
void deleteSnapshotInRegion(@Nullable Region region, String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Permission}s of an snapshot.
|
* Returns the {@link Permission}s of an snapshot.
|
||||||
|
@ -361,7 +363,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeSnapshotsOptions
|
* @see DescribeSnapshotsOptions
|
||||||
*/
|
*/
|
||||||
Permission getCreateVolumePermissionForSnapshotInRegion(Region region, String snapshotId);
|
Permission getCreateVolumePermissionForSnapshotInRegion(@Nullable Region region, String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@code createVolumePermission}s to an EBS snapshot.
|
* Adds {@code createVolumePermission}s to an EBS snapshot.
|
||||||
|
@ -382,7 +384,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySnapshotAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySnapshotAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void addCreateVolumePermissionsToSnapshotInRegion(Region region, Iterable<String> userIds,
|
void addCreateVolumePermissionsToSnapshotInRegion(@Nullable Region region, Iterable<String> userIds,
|
||||||
Iterable<String> userGroups, String snapshotId);
|
Iterable<String> userGroups, String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -400,7 +402,7 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetSnapshotAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetSnapshotAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void resetCreateVolumePermissionsOnSnapshotInRegion(Region region, String snapshotId);
|
void resetCreateVolumePermissionsOnSnapshotInRegion(@Nullable Region region, String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@code createVolumePermission}s from an EBS snapshot.
|
* Removes {@code createVolumePermission}s from an EBS snapshot.
|
||||||
|
@ -421,6 +423,6 @@ public interface ElasticBlockStoreClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySnapshotAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySnapshotAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void removeCreateVolumePermissionsFromSnapshotInRegion(Region region, Iterable<String> userIds,
|
void removeCreateVolumePermissionsFromSnapshotInRegion(@Nullable Region region, Iterable<String> userIds,
|
||||||
Iterable<String> userGroups, String snapshotId);
|
Iterable<String> userGroups, String snapshotId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -65,7 +66,7 @@ public interface ElasticIPAddressAsyncClient {
|
||||||
@XMLResponseParser(AllocateAddressResponseHandler.class)
|
@XMLResponseParser(AllocateAddressResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "AllocateAddress")
|
@FormParams(keys = ACTION, values = "AllocateAddress")
|
||||||
ListenableFuture<InetAddress> allocateAddressInRegion(
|
ListenableFuture<InetAddress> allocateAddressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#associateAddressInRegion
|
* @see BaseEC2Client#associateAddressInRegion
|
||||||
|
@ -74,7 +75,7 @@ public interface ElasticIPAddressAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AssociateAddress")
|
@FormParams(keys = ACTION, values = "AssociateAddress")
|
||||||
ListenableFuture<Void> associateAddressInRegion(
|
ListenableFuture<Void> associateAddressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp,
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ public interface ElasticIPAddressAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DisassociateAddress")
|
@FormParams(keys = ACTION, values = "DisassociateAddress")
|
||||||
ListenableFuture<Void> disassociateAddressInRegion(
|
ListenableFuture<Void> disassociateAddressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +96,7 @@ public interface ElasticIPAddressAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "ReleaseAddress")
|
@FormParams(keys = ACTION, values = "ReleaseAddress")
|
||||||
ListenableFuture<Void> releaseAddressInRegion(
|
ListenableFuture<Void> releaseAddressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +107,7 @@ public interface ElasticIPAddressAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeAddresses")
|
@FormParams(keys = ACTION, values = "DescribeAddresses")
|
||||||
@XMLResponseParser(DescribeAddressesResponseHandler.class)
|
@XMLResponseParser(DescribeAddressesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<PublicIpInstanceIdPair>> describeAddressesInRegion(
|
ListenableFuture<? extends Set<PublicIpInstanceIdPair>> describeAddressesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindInetAddressesToIndexedFormParams.class) InetAddress... publicIps);
|
@BinderParam(BindInetAddressesToIndexedFormParams.class) InetAddress... publicIps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.net.InetAddress;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
@ -47,7 +49,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html"
|
||||||
*/
|
*/
|
||||||
InetAddress allocateAddressInRegion(Region region);
|
InetAddress allocateAddressInRegion(@Nullable Region region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates an elastic IP address with an instance. If the IP address is currently assigned to
|
* Associates an elastic IP address with an instance. If the IP address is currently assigned to
|
||||||
|
@ -67,7 +69,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-AssociateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-AssociateAddress.html"
|
||||||
*/
|
*/
|
||||||
void associateAddressInRegion(Region region, InetAddress publicIp, String instanceId);
|
void associateAddressInRegion(@Nullable Region region, InetAddress publicIp, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disassociates the specified elastic IP address from the instance to which it is assigned. This
|
* Disassociates the specified elastic IP address from the instance to which it is assigned. This
|
||||||
|
@ -85,7 +87,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #associateAddress
|
* @see #associateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DisdisassociateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DisdisassociateAddress.html"
|
||||||
*/
|
*/
|
||||||
void disassociateAddressInRegion(Region region, InetAddress publicIp);
|
void disassociateAddressInRegion(@Nullable Region region, InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases an elastic IP address associated with your account.
|
* Releases an elastic IP address associated with your account.
|
||||||
|
@ -101,7 +103,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-ReleaseAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-ReleaseAddress.html"
|
||||||
*/
|
*/
|
||||||
void releaseAddressInRegion(Region region, InetAddress publicIp);
|
void releaseAddressInRegion(@Nullable Region region, InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists elastic IP addresses assigned to your account or provides information about a specific
|
* Lists elastic IP addresses assigned to your account or provides information about a specific
|
||||||
|
@ -119,7 +121,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAddresses.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAddresses.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<PublicIpInstanceIdPair> describeAddressesInRegion(Region region,
|
Set<PublicIpInstanceIdPair> describeAddressesInRegion(@Nullable Region region,
|
||||||
InetAddress... publicIps);
|
InetAddress... publicIps);
|
||||||
|
|
||||||
}
|
}
|
|
@ -77,7 +77,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeInstances")
|
@FormParams(keys = ACTION, values = "DescribeInstances")
|
||||||
@XMLResponseParser(DescribeInstancesResponseHandler.class)
|
@XMLResponseParser(DescribeInstancesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<Reservation>> describeInstancesInRegion(
|
ListenableFuture<? extends Set<Reservation>> describeInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "RunInstances")
|
@FormParams(keys = ACTION, values = "RunInstances")
|
||||||
@XMLResponseParser(RunInstancesResponseHandler.class)
|
@XMLResponseParser(RunInstancesResponseHandler.class)
|
||||||
ListenableFuture<Reservation> runInstancesInRegion(
|
ListenableFuture<Reservation> runInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) AvailabilityZone nullableAvailabilityZone,
|
@Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) AvailabilityZone 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);
|
||||||
|
@ -100,7 +100,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RebootInstances")
|
@FormParams(keys = ACTION, values = "RebootInstances")
|
||||||
ListenableFuture<Void> rebootInstancesInRegion(
|
ListenableFuture<Void> rebootInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "TerminateInstances")
|
@FormParams(keys = ACTION, values = "TerminateInstances")
|
||||||
@XMLResponseParser(InstanceStateChangeHandler.class)
|
@XMLResponseParser(InstanceStateChangeHandler.class)
|
||||||
ListenableFuture<? extends Set<InstanceStateChange>> terminateInstancesInRegion(
|
ListenableFuture<? extends Set<InstanceStateChange>> terminateInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "StopInstances")
|
@FormParams(keys = ACTION, values = "StopInstances")
|
||||||
@XMLResponseParser(InstanceStateChangeHandler.class)
|
@XMLResponseParser(InstanceStateChangeHandler.class)
|
||||||
ListenableFuture<? extends Set<InstanceStateChange>> stopInstancesInRegion(
|
ListenableFuture<? extends Set<InstanceStateChange>> stopInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("Force") boolean force,
|
@FormParam("Force") boolean force,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "StartInstances")
|
@FormParams(keys = ACTION, values = "StartInstances")
|
||||||
@XMLResponseParser(InstanceStateChangeHandler.class)
|
@XMLResponseParser(InstanceStateChangeHandler.class)
|
||||||
ListenableFuture<? extends Set<InstanceStateChange>> startInstancesInRegion(
|
ListenableFuture<? extends Set<InstanceStateChange>> startInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,7 +145,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "userData" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "userData" })
|
||||||
@XMLResponseParser(UnencodeStringValueHandler.class)
|
@XMLResponseParser(UnencodeStringValueHandler.class)
|
||||||
ListenableFuture<String> getUserDataForInstanceInRegion(
|
ListenableFuture<String> getUserDataForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +157,7 @@ public interface InstanceAsyncClient {
|
||||||
"rootDeviceName" })
|
"rootDeviceName" })
|
||||||
@XMLResponseParser(StringValueHandler.class)
|
@XMLResponseParser(StringValueHandler.class)
|
||||||
ListenableFuture<String> getRootDeviceNameForInstanceInRegion(
|
ListenableFuture<String> getRootDeviceNameForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +168,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "ramdisk" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "ramdisk" })
|
||||||
@XMLResponseParser(StringValueHandler.class)
|
@XMLResponseParser(StringValueHandler.class)
|
||||||
ListenableFuture<String> getRamdiskForInstanceInRegion(
|
ListenableFuture<String> getRamdiskForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +179,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "kernel" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "kernel" })
|
||||||
@XMLResponseParser(StringValueHandler.class)
|
@XMLResponseParser(StringValueHandler.class)
|
||||||
ListenableFuture<String> getKernelForInstanceInRegion(
|
ListenableFuture<String> getKernelForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +191,7 @@ public interface InstanceAsyncClient {
|
||||||
"disableApiTermination" })
|
"disableApiTermination" })
|
||||||
@XMLResponseParser(BooleanValueHandler.class)
|
@XMLResponseParser(BooleanValueHandler.class)
|
||||||
ListenableFuture<Boolean> isApiTerminationDisabledForInstanceInRegion(
|
ListenableFuture<Boolean> isApiTerminationDisabledForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +203,7 @@ public interface InstanceAsyncClient {
|
||||||
"instanceType" })
|
"instanceType" })
|
||||||
@XMLResponseParser(InstanceTypeHandler.class)
|
@XMLResponseParser(InstanceTypeHandler.class)
|
||||||
ListenableFuture<InstanceType> getInstanceTypeForInstanceInRegion(
|
ListenableFuture<InstanceType> getInstanceTypeForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,7 +215,7 @@ public interface InstanceAsyncClient {
|
||||||
"instanceInitiatedShutdownBehavior" })
|
"instanceInitiatedShutdownBehavior" })
|
||||||
@XMLResponseParser(InstanceInitiatedShutdownBehaviorHandler.class)
|
@XMLResponseParser(InstanceInitiatedShutdownBehaviorHandler.class)
|
||||||
ListenableFuture<InstanceInitiatedShutdownBehavior> getInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
ListenableFuture<InstanceInitiatedShutdownBehavior> getInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +227,7 @@ public interface InstanceAsyncClient {
|
||||||
"blockDeviceMapping" })
|
"blockDeviceMapping" })
|
||||||
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
||||||
ListenableFuture<? extends Map<String, RunningInstance.EbsBlockDevice>> getBlockDeviceMappingForInstanceInRegion(
|
ListenableFuture<? extends Map<String, RunningInstance.EbsBlockDevice>> getBlockDeviceMappingForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,7 +237,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "ramdisk" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "ramdisk" })
|
||||||
ListenableFuture<Void> resetRamdiskForInstanceInRegion(
|
ListenableFuture<Void> resetRamdiskForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +247,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "kernel" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "kernel" })
|
||||||
ListenableFuture<Void> resetKernelForInstanceInRegion(
|
ListenableFuture<Void> resetKernelForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,7 +257,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "userData" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "userData" })
|
||||||
ListenableFuture<Void> setUserDataForInstanceInRegion(
|
ListenableFuture<Void> setUserDataForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId,
|
@FormParam("InstanceId") String instanceId,
|
||||||
@FormParam("Value") @ParamParser(ConvertUnencodedBytesToBase64EncodedString.class) byte[] unencodedData);
|
@FormParam("Value") @ParamParser(ConvertUnencodedBytesToBase64EncodedString.class) byte[] unencodedData);
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "ramdisk" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "ramdisk" })
|
||||||
ListenableFuture<Void> setRamdiskForInstanceInRegion(
|
ListenableFuture<Void> setRamdiskForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId, @FormParam("Value") String ramdisk);
|
@FormParam("InstanceId") String instanceId, @FormParam("Value") String ramdisk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "kernel" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "kernel" })
|
||||||
ListenableFuture<Void> setKernelForInstanceInRegion(
|
ListenableFuture<Void> setKernelForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId, @FormParam("Value") String kernel);
|
@FormParam("InstanceId") String instanceId, @FormParam("Value") String kernel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +289,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute",
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute",
|
||||||
"disableApiTermination" })
|
"disableApiTermination" })
|
||||||
ListenableFuture<Void> setApiTerminationDisabledForInstanceInRegion(
|
ListenableFuture<Void> setApiTerminationDisabledForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId,
|
@FormParam("InstanceId") String instanceId,
|
||||||
@FormParam("Value") boolean apiTerminationDisabled);
|
@FormParam("Value") boolean apiTerminationDisabled);
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "instanceType" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "instanceType" })
|
||||||
ListenableFuture<Void> setInstanceTypeForInstanceInRegion(
|
ListenableFuture<Void> setInstanceTypeForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId,
|
@FormParam("InstanceId") String instanceId,
|
||||||
@FormParam("Value") InstanceType instanceType);
|
@FormParam("Value") InstanceType instanceType);
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ public interface InstanceAsyncClient {
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute",
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute",
|
||||||
"instanceInitiatedShutdownBehavior" })
|
"instanceInitiatedShutdownBehavior" })
|
||||||
ListenableFuture<Void> setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
ListenableFuture<Void> setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId,
|
@FormParam("InstanceId") String instanceId,
|
||||||
@FormParam("Value") InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior);
|
@FormParam("Value") InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior);
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ public interface InstanceAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION }, values = { "ModifyInstanceAttribute" })
|
@FormParams(keys = { ACTION }, values = { "ModifyInstanceAttribute" })
|
||||||
ListenableFuture<Void> setBlockDeviceMappingForInstanceInRegion(
|
ListenableFuture<Void> setBlockDeviceMappingForInstanceInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId") String instanceId,
|
@FormParam("InstanceId") String instanceId,
|
||||||
@BinderParam(BindBlockDeviceMappingToIndexedFormParams.class) BlockDeviceMapping blockDeviceMapping);
|
@BinderParam(BindBlockDeviceMappingToIndexedFormParams.class) BlockDeviceMapping blockDeviceMapping);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<Reservation> describeInstancesInRegion(Region region, String... instanceIds);
|
Set<Reservation> describeInstancesInRegion(@Nullable Region region, String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches a specified number of instances of an AMI for which you have permissions.
|
* Launches a specified number of instances of an AMI for which you have permissions.
|
||||||
|
@ -134,7 +134,7 @@ public interface InstanceClient {
|
||||||
* />
|
* />
|
||||||
* @see RunInstancesOptions
|
* @see RunInstancesOptions
|
||||||
*/
|
*/
|
||||||
Reservation runInstancesInRegion(Region region,
|
Reservation runInstancesInRegion(@Nullable Region region,
|
||||||
@Nullable AvailabilityZone nullableAvailabilityZone, String imageId, int minCount,
|
@Nullable AvailabilityZone nullableAvailabilityZone, String imageId, int minCount,
|
||||||
int maxCount, RunInstancesOptions... options);
|
int maxCount, RunInstancesOptions... options);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-TerminateInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-TerminateInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<InstanceStateChange> terminateInstancesInRegion(Region region, String... instanceIds);
|
Set<InstanceStateChange> terminateInstancesInRegion(@Nullable Region region, String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops an instance that uses an Amazon EBS volume as its root device.
|
* Stops an instance that uses an Amazon EBS volume as its root device.
|
||||||
|
@ -189,7 +189,7 @@ public interface InstanceClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StopInstances.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StopInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<InstanceStateChange> stopInstancesInRegion(Region region, boolean force,
|
Set<InstanceStateChange> stopInstancesInRegion(@Nullable Region region, boolean force,
|
||||||
String... instanceIds);
|
String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +214,7 @@ public interface InstanceClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StopInstances.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StopInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void rebootInstancesInRegion(Region region, String... instanceIds);
|
void rebootInstancesInRegion(@Nullable Region region, String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts an instance that uses an Amazon EBS volume as its root device.
|
* Starts an instance that uses an Amazon EBS volume as its root device.
|
||||||
|
@ -244,7 +244,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StartInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StartInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<InstanceStateChange> startInstancesInRegion(Region region, String... instanceIds);
|
Set<InstanceStateChange> startInstancesInRegion(@Nullable Region region, String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -255,7 +255,7 @@ public interface InstanceClient {
|
||||||
* which instance to describe the attribute of
|
* which instance to describe the attribute of
|
||||||
* @return unencoded user data
|
* @return unencoded user data
|
||||||
*/
|
*/
|
||||||
String getUserDataForInstanceInRegion(Region region, String instanceId);
|
String getUserDataForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -266,7 +266,7 @@ public interface InstanceClient {
|
||||||
* which instance to describe the attribute of
|
* which instance to describe the attribute of
|
||||||
* @return The root device name (e.g., /dev/sda1).
|
* @return The root device name (e.g., /dev/sda1).
|
||||||
*/
|
*/
|
||||||
String getRootDeviceNameForInstanceInRegion(Region region, String instanceId);
|
String getRootDeviceNameForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -277,7 +277,7 @@ public interface InstanceClient {
|
||||||
* which instance to describe the attribute of
|
* which instance to describe the attribute of
|
||||||
* @return the ID of the RAM disk associated with the AMI.
|
* @return the ID of the RAM disk associated with the AMI.
|
||||||
*/
|
*/
|
||||||
String getRamdiskForInstanceInRegion(Region region, String instanceId);
|
String getRamdiskForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -288,7 +288,7 @@ public interface InstanceClient {
|
||||||
* which instance to describe the attribute of
|
* which instance to describe the attribute of
|
||||||
* @return the ID of the kernel associated with the AMI.
|
* @return the ID of the kernel associated with the AMI.
|
||||||
*/
|
*/
|
||||||
String getKernelForInstanceInRegion(Region region, String instanceId);
|
String getKernelForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -300,7 +300,7 @@ public interface InstanceClient {
|
||||||
* @return Specifies whether the instance can be terminated using the APIs. You must modify this
|
* @return Specifies whether the instance can be terminated using the APIs. You must modify this
|
||||||
* attribute before you can terminate any "locked" instances from the APIs.
|
* attribute before you can terminate any "locked" instances from the APIs.
|
||||||
*/
|
*/
|
||||||
boolean isApiTerminationDisabledForInstanceInRegion(Region region, String instanceId);
|
boolean isApiTerminationDisabledForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -311,7 +311,7 @@ public interface InstanceClient {
|
||||||
* which instance to describe the attribute of
|
* which instance to describe the attribute of
|
||||||
* @return The instance type of the instance.
|
* @return The instance type of the instance.
|
||||||
*/
|
*/
|
||||||
InstanceType getInstanceTypeForInstanceInRegion(Region region, String instanceId);
|
InstanceType getInstanceTypeForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -336,7 +336,7 @@ public interface InstanceClient {
|
||||||
* @return Describes the mapping that defines native device names to use when exposing virtual
|
* @return Describes the mapping that defines native device names to use when exposing virtual
|
||||||
* devices.
|
* devices.
|
||||||
*/
|
*/
|
||||||
Map<String, EbsBlockDevice> getBlockDeviceMappingForInstanceInRegion(Region region,
|
Map<String, EbsBlockDevice> getBlockDeviceMappingForInstanceInRegion(@Nullable Region region,
|
||||||
String instanceId);
|
String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +349,7 @@ public interface InstanceClient {
|
||||||
* which instance to reset the attribute of
|
* which instance to reset the attribute of
|
||||||
* @return the ID of the RAM disk associated with the AMI.
|
* @return the ID of the RAM disk associated with the AMI.
|
||||||
*/
|
*/
|
||||||
String resetRamdiskForInstanceInRegion(Region region, String instanceId);
|
String resetRamdiskForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets an attribute of an instance to its default value.
|
* Resets an attribute of an instance to its default value.
|
||||||
|
@ -361,7 +361,7 @@ public interface InstanceClient {
|
||||||
* which instance to reset the attribute of
|
* which instance to reset the attribute of
|
||||||
* @return the ID of the kernel associated with the AMI.
|
* @return the ID of the kernel associated with the AMI.
|
||||||
*/
|
*/
|
||||||
String resetKernelForInstanceInRegion(Region region, String instanceId);
|
String resetKernelForInstanceInRegion(@Nullable Region region, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the userData used for starting the instance.
|
* Sets the userData used for starting the instance.
|
||||||
|
@ -383,7 +383,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setUserDataForInstanceInRegion(Region region, String instanceId, byte[] unencodedData);
|
void setUserDataForInstanceInRegion(@Nullable Region region, String instanceId, byte[] unencodedData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ramdisk used for starting the instance.
|
* Sets the ramdisk used for starting the instance.
|
||||||
|
@ -405,7 +405,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setRamdiskForInstanceInRegion(Region region, String instanceId, String ramdisk);
|
void setRamdiskForInstanceInRegion(@Nullable Region region, String instanceId, String ramdisk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the kernelId used for starting the instance.
|
* Sets the kernelId used for starting the instance.
|
||||||
|
@ -427,7 +427,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setKernelForInstanceInRegion(Region region, String instanceId, String kernel);
|
void setKernelForInstanceInRegion(@Nullable Region region, String instanceId, String kernel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command works while the instance is running and controls whether or not the api can be
|
* This command works while the instance is running and controls whether or not the api can be
|
||||||
|
@ -443,7 +443,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setApiTerminationDisabledForInstanceInRegion(Region region, String instanceId,
|
void setApiTerminationDisabledForInstanceInRegion(@Nullable Region region, String instanceId,
|
||||||
boolean apiTerminationDisabled);
|
boolean apiTerminationDisabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -466,7 +466,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setInstanceTypeForInstanceInRegion(Region region, String instanceId,
|
void setInstanceTypeForInstanceInRegion(@Nullable Region region, String instanceId,
|
||||||
InstanceType instanceType);
|
InstanceType instanceType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,7 +491,7 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setInstanceInitiatedShutdownBehaviorForInstanceInRegion(Region region, String instanceId,
|
void setInstanceInitiatedShutdownBehaviorForInstanceInRegion(@Nullable Region region, String instanceId,
|
||||||
InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior);
|
InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,6 +538,6 @@ public interface InstanceClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void setBlockDeviceMappingForInstanceInRegion(Region region, String instanceId,
|
void setBlockDeviceMappingForInstanceInRegion(@Nullable Region region, String instanceId,
|
||||||
BlockDeviceMapping blockDeviceMapping);
|
BlockDeviceMapping blockDeviceMapping);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -62,7 +63,7 @@ public interface KeyPairAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "CreateKeyPair")
|
@FormParams(keys = ACTION, values = "CreateKeyPair")
|
||||||
@XMLResponseParser(KeyPairResponseHandler.class)
|
@XMLResponseParser(KeyPairResponseHandler.class)
|
||||||
ListenableFuture<KeyPair> createKeyPairInRegion(
|
ListenableFuture<KeyPair> createKeyPairInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("KeyName") String keyName);
|
@FormParam("KeyName") String keyName);
|
||||||
|
|
||||||
// map resourcenotfoundexception to empty set
|
// map resourcenotfoundexception to empty set
|
||||||
|
@ -74,7 +75,7 @@ public interface KeyPairAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeKeyPairs")
|
@FormParams(keys = ACTION, values = "DescribeKeyPairs")
|
||||||
@XMLResponseParser(DescribeKeyPairsResponseHandler.class)
|
@XMLResponseParser(DescribeKeyPairsResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<KeyPair>> describeKeyPairsInRegion(
|
ListenableFuture<? extends Set<KeyPair>> describeKeyPairsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindKeyNameToIndexedFormParams.class) String... keyPairNames);
|
@BinderParam(BindKeyNameToIndexedFormParams.class) String... keyPairNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +85,7 @@ public interface KeyPairAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteKeyPair")
|
@FormParams(keys = ACTION, values = "DeleteKeyPair")
|
||||||
ListenableFuture<Void> deleteKeyPairInRegion(
|
ListenableFuture<Void> deleteKeyPairInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("KeyName") String keyName);
|
@FormParam("KeyName") String keyName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.aws.ec2.services;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -53,7 +55,7 @@ public interface KeyPairClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
KeyPair createKeyPairInRegion(Region region, String keyName);
|
KeyPair createKeyPairInRegion(@Nullable Region region, String keyName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about key pairs available to you. If you specify key pairs, information
|
* Returns information about key pairs available to you. If you specify key pairs, information
|
||||||
|
@ -70,7 +72,7 @@ public interface KeyPairClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<KeyPair> describeKeyPairsInRegion(Region region, String... keyPairNames);
|
Set<KeyPair> describeKeyPairsInRegion(@Nullable Region region, String... keyPairNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the
|
* Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the
|
||||||
|
@ -88,6 +90,6 @@ public interface KeyPairClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteKeyPair.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteKeyPair.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteKeyPairInRegion(Region region, String keyName);
|
void deleteKeyPairInRegion(@Nullable Region region, String keyName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -61,7 +62,7 @@ public interface MonitoringAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "MonitorInstances")
|
@FormParams(keys = ACTION, values = "MonitorInstances")
|
||||||
@XMLResponseParser(MonitoringStateHandler.class)
|
@XMLResponseParser(MonitoringStateHandler.class)
|
||||||
ListenableFuture<? extends Map<String, MonitoringState>> monitorInstancesInRegion(
|
ListenableFuture<? extends Map<String, MonitoringState>> monitorInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId.0") String instanceId,
|
@FormParam("InstanceId.0") String instanceId,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ public interface MonitoringAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "UnmonitorInstances")
|
@FormParams(keys = ACTION, values = "UnmonitorInstances")
|
||||||
@XMLResponseParser(MonitoringStateHandler.class)
|
@XMLResponseParser(MonitoringStateHandler.class)
|
||||||
ListenableFuture<? extends Map<String, MonitoringState>> unmonitorInstancesInRegion(
|
ListenableFuture<? extends Map<String, MonitoringState>> unmonitorInstancesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("InstanceId.0") String instanceId,
|
@FormParam("InstanceId.0") String instanceId,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.aws.ec2.services;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -48,7 +50,7 @@ public interface MonitoringClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Map<String, MonitoringState> monitorInstancesInRegion(Region region, String instanceId,
|
Map<String, MonitoringState> monitorInstancesInRegion(@Nullable Region region, String instanceId,
|
||||||
String... instanceIds);
|
String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +67,6 @@ public interface MonitoringClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Map<String, MonitoringState> unmonitorInstancesInRegion(Region region, String instanceId,
|
Map<String, MonitoringState> unmonitorInstancesInRegion(@Nullable Region region, String instanceId,
|
||||||
String... instanceIds);
|
String... instanceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -65,7 +66,7 @@ public interface SecurityGroupAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "CreateSecurityGroup")
|
@FormParams(keys = ACTION, values = "CreateSecurityGroup")
|
||||||
ListenableFuture<Void> createSecurityGroupInRegion(
|
ListenableFuture<Void> createSecurityGroupInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String name, @FormParam("GroupDescription") String description);
|
@FormParam("GroupName") String name, @FormParam("GroupDescription") String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +77,7 @@ public interface SecurityGroupAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DeleteSecurityGroup")
|
@FormParams(keys = ACTION, values = "DeleteSecurityGroup")
|
||||||
@ExceptionParser(ReturnVoidOnGroupNotFound.class)
|
@ExceptionParser(ReturnVoidOnGroupNotFound.class)
|
||||||
ListenableFuture<Void> deleteSecurityGroupInRegion(
|
ListenableFuture<Void> deleteSecurityGroupInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String name);
|
@FormParam("GroupName") String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,53 +88,53 @@ public interface SecurityGroupAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "DescribeSecurityGroups")
|
@FormParams(keys = ACTION, values = "DescribeSecurityGroups")
|
||||||
@XMLResponseParser(DescribeSecurityGroupsResponseHandler.class)
|
@XMLResponseParser(DescribeSecurityGroupsResponseHandler.class)
|
||||||
ListenableFuture<? extends SortedSet<SecurityGroup>> describeSecurityGroupsInRegion(
|
ListenableFuture<? extends SortedSet<SecurityGroup>> describeSecurityGroupsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@BinderParam(BindGroupNameToIndexedFormParams.class) String... securityGroupNames);
|
@BinderParam(BindGroupNameToIndexedFormParams.class) String... securityGroupNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(Region, String,UserIdGroupPair)
|
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(@Nullable Region, String,UserIdGroupPair)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||||
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(Region,
|
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(@Nullable Region,
|
||||||
* String,IpProtocol,int,int,String)
|
* String,IpProtocol,int,int,String)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||||
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
||||||
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(Region, String,UserIdGroupPair)
|
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(@Nullable Region, String,UserIdGroupPair)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||||
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(Region,
|
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(@Nullable Region,
|
||||||
* String,IpProtocol,int,int,String)
|
* String,IpProtocol,int,int,String)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||||
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
||||||
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.aws.ec2.services;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
|
@ -59,7 +61,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void createSecurityGroupInRegion(Region region, String name, String description);
|
void createSecurityGroupInRegion(@Nullable Region region, String name, String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a security group that you own.
|
* Deletes a security group that you own.
|
||||||
|
@ -79,7 +81,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSecurityGroup.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSecurityGroup.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteSecurityGroupInRegion(Region region, String name);
|
void deleteSecurityGroupInRegion(@Nullable Region region, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about security groups that you own.
|
* Returns information about security groups that you own.
|
||||||
|
@ -99,7 +101,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<SecurityGroup> describeSecurityGroupsInRegion(Region region,
|
SortedSet<SecurityGroup> describeSecurityGroupsInRegion(@Nullable Region region,
|
||||||
String... securityGroupNames);
|
String... securityGroupNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +125,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void authorizeSecurityGroupIngressInRegion(Region region, String groupName,
|
void authorizeSecurityGroupIngressInRegion(@Nullable Region region, String groupName,
|
||||||
UserIdGroupPair sourceSecurityGroup);
|
UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +164,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void authorizeSecurityGroupIngressInRegion(Region region, String groupName,
|
void authorizeSecurityGroupIngressInRegion(@Nullable Region region, String groupName,
|
||||||
IpProtocol ipProtocol, int fromPort, int toPort, String cidrIp);
|
IpProtocol ipProtocol, int fromPort, int toPort, String cidrIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +189,7 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void revokeSecurityGroupIngressInRegion(Region region, String groupName,
|
void revokeSecurityGroupIngressInRegion(@Nullable Region region, String groupName,
|
||||||
UserIdGroupPair sourceSecurityGroup);
|
UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,6 +229,6 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void revokeSecurityGroupIngressInRegion(Region region, String groupName, IpProtocol ipProtocol,
|
void revokeSecurityGroupIngressInRegion(@Nullable Region region, String groupName, IpProtocol ipProtocol,
|
||||||
int fromPort, int toPort, String cidrIp);
|
int fromPort, int toPort, String cidrIp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Date;
|
||||||
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.domain.Attachment;
|
import org.jclouds.aws.ec2.domain.Attachment;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
@ -40,7 +42,9 @@ public class AttachmentHandler extends ParseSax.HandlerWithResult<Attachment> {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
@Inject
|
@Inject
|
||||||
protected DateService dateService;
|
protected DateService dateService;
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
private String volumeId;
|
private String volumeId;
|
||||||
private String instanceId;
|
private String instanceId;
|
||||||
private String device;
|
private String device;
|
||||||
|
@ -48,8 +52,10 @@ public class AttachmentHandler extends ParseSax.HandlerWithResult<Attachment> {
|
||||||
private Date attachTime;
|
private Date attachTime;
|
||||||
|
|
||||||
public Attachment getResult() {
|
public Attachment getResult() {
|
||||||
return new Attachment(EC2Utils.findRegionInArgsOrNull(request), volumeId, instanceId, device,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
attachmentStatus, attachTime);
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
return new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
|
|
@ -26,7 +26,10 @@ import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
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.Attachment;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
|
@ -43,12 +46,20 @@ import org.xml.sax.Attributes;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
|
public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
|
||||||
|
|
||||||
protected final DateService dateService;
|
protected final DateService dateService;
|
||||||
|
|
||||||
public BaseReservationHandler(DateService dateService) {
|
protected final Region defaultRegion;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BaseReservationHandler(DateService dateService, @EC2 Region defaultRegion) {
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
|
this.defaultRegion = defaultRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -197,11 +208,14 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
|
||||||
this.attachTime = null;
|
this.attachTime = null;
|
||||||
this.deleteOnTermination = true;
|
this.deleteOnTermination = true;
|
||||||
} else if (inInstances && !inProductCodes && !inBlockDeviceMapping) {
|
} else if (inInstances && !inProductCodes && !inBlockDeviceMapping) {
|
||||||
instances.add(new RunningInstance(EC2Utils.findRegionInArgsOrNull(request),
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
amiLaunchIndex, dnsName, imageId, instanceId, instanceState, instanceType,
|
if (region == null)
|
||||||
ipAddress, kernelId, keyName, launchTime, monitoring, availabilityZone, platform,
|
region = defaultRegion;
|
||||||
privateDnsName, privateIpAddress, productCodes, ramdiskId, reason, subnetId,
|
instances.add(new RunningInstance(region, amiLaunchIndex, dnsName, imageId, instanceId,
|
||||||
vpcId, rootDeviceType, rootDeviceName, ebsBlockDevices));
|
instanceState, instanceType, ipAddress, kernelId, keyName, launchTime,
|
||||||
|
monitoring, availabilityZone, platform, privateDnsName, privateIpAddress,
|
||||||
|
productCodes, ramdiskId, reason, subnetId, vpcId, rootDeviceType, rootDeviceName,
|
||||||
|
ebsBlockDevices));
|
||||||
this.amiLaunchIndex = null;
|
this.amiLaunchIndex = null;
|
||||||
this.dnsName = null;
|
this.dnsName = null;
|
||||||
this.imageId = null;
|
this.imageId = null;
|
||||||
|
@ -247,8 +261,11 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Reservation newReservation() {
|
protected Reservation newReservation() {
|
||||||
Reservation info = new Reservation(EC2Utils.findRegionInArgsOrNull(request), groupIds,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
instances, ownerId, requesterId, reservationId);
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
Reservation info = new Reservation(region, groupIds, instances, ownerId, requesterId,
|
||||||
|
reservationId);
|
||||||
this.groupIds = Sets.newTreeSet();
|
this.groupIds = Sets.newTreeSet();
|
||||||
this.instances = Sets.newTreeSet();
|
this.instances = Sets.newTreeSet();
|
||||||
this.ownerId = null;
|
this.ownerId = null;
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -29,6 +28,7 @@ import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
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.Attachment;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.Volume;
|
import org.jclouds.aws.ec2.domain.Volume;
|
||||||
|
@ -53,6 +53,9 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
|
||||||
@Inject
|
@Inject
|
||||||
protected DateService dateService;
|
protected DateService dateService;
|
||||||
@Inject
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
|
@Inject
|
||||||
protected Map<AvailabilityZone, Region> availabilityZoneToRegion;
|
protected Map<AvailabilityZone, Region> availabilityZoneToRegion;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -128,8 +131,8 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
|
||||||
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
if (inAttachmentSet) {
|
if (inAttachmentSet) {
|
||||||
attachments.add(new Attachment(EC2Utils.findRegionInArgsOrNull(request), volumeId,
|
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus,
|
||||||
instanceId, device, attachmentStatus, attachTime));
|
attachTime));
|
||||||
volumeId = null;
|
volumeId = null;
|
||||||
instanceId = null;
|
instanceId = null;
|
||||||
device = null;
|
device = null;
|
||||||
|
@ -163,10 +166,13 @@ 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 = checkNotNull(EC2Utils.findAvailabilityZoneInArgsOrNull(request),
|
AvailabilityZone zone = EC2Utils.findAvailabilityZoneInArgsOrNull(request);
|
||||||
"zone not in args: " + Arrays.asList(request.getArgs()));
|
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));
|
||||||
|
} else {
|
||||||
|
region = defaultRegion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@ import java.net.UnknownHostException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
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.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
@ -43,7 +46,9 @@ public class DescribeAddressesResponseHandler extends
|
||||||
private Set<PublicIpInstanceIdPair> pairs = Sets.newLinkedHashSet();
|
private Set<PublicIpInstanceIdPair> pairs = Sets.newLinkedHashSet();
|
||||||
private InetAddress ipAddress;
|
private InetAddress ipAddress;
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
private String instanceId;
|
private String instanceId;
|
||||||
|
|
||||||
protected String currentOrNull() {
|
protected String currentOrNull() {
|
||||||
|
@ -57,8 +62,10 @@ public class DescribeAddressesResponseHandler extends
|
||||||
} else if (qName.equals("instanceId")) {
|
} else if (qName.equals("instanceId")) {
|
||||||
instanceId = currentOrNull();
|
instanceId = currentOrNull();
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
pairs.add(new PublicIpInstanceIdPair(EC2Utils.findRegionInArgsOrNull(request), ipAddress,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
instanceId));
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
pairs.add(new PublicIpInstanceIdPair(region, ipAddress, instanceId));
|
||||||
ipAddress = null;
|
ipAddress = null;
|
||||||
instanceId = null;
|
instanceId = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,10 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
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.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||||
|
@ -49,7 +52,9 @@ import com.google.common.collect.Sets;
|
||||||
public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<Set<Image>> {
|
public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<Set<Image>> {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
private Set<Image> contents = Sets.newLinkedHashSet();
|
private Set<Image> contents = Sets.newLinkedHashSet();
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
@ -142,7 +147,10 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<Se
|
||||||
this.deleteOnTermination = true;
|
this.deleteOnTermination = true;
|
||||||
} else if (!inProductCodes) {
|
} else if (!inProductCodes) {
|
||||||
try {
|
try {
|
||||||
contents.add(new Image(EC2Utils.findRegionInArgsOrNull(request), architecture,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
contents.add(new Image(region, architecture,
|
||||||
this.name, description, imageId, imageLocation, imageOwnerId, imageState,
|
this.name, description, imageId, imageLocation, imageOwnerId, imageState,
|
||||||
imageType, isPublic, productCodes, kernelId, platform, ramdiskId,
|
imageType, isPublic, productCodes, kernelId, platform, ramdiskId,
|
||||||
rootDeviceType, rootDeviceName, ebsBlockDevices));
|
rootDeviceType, rootDeviceName, ebsBlockDevices));
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.SortedSet;
|
||||||
|
|
||||||
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.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
|
||||||
|
@ -40,8 +42,8 @@ public class DescribeInstancesResponseHandler extends
|
||||||
private SortedSet<Reservation> reservations = Sets.newTreeSet();
|
private SortedSet<Reservation> reservations = Sets.newTreeSet();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DescribeInstancesResponseHandler(DateService dateService) {
|
DescribeInstancesResponseHandler(DateService dateService, @EC2 Region defaultRegion) {
|
||||||
super(dateService);
|
super(dateService, defaultRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,6 +20,10 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
@ -34,6 +38,9 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<Set<KeyPair>> {
|
public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<Set<KeyPair>> {
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private Set<KeyPair> keyPairs = Sets.newLinkedHashSet();
|
private Set<KeyPair> keyPairs = Sets.newLinkedHashSet();
|
||||||
|
@ -49,8 +56,10 @@ public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<
|
||||||
if (qName.equals("keyFingerprint")) {
|
if (qName.equals("keyFingerprint")) {
|
||||||
this.keyFingerprint = currentText.toString().trim();
|
this.keyFingerprint = currentText.toString().trim();
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
keyPairs.add(new KeyPair(EC2Utils.findRegionInArgsOrNull(request), keyName,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
keyFingerprint, null));
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
keyPairs.add(new KeyPair(region, keyName, keyFingerprint, null));
|
||||||
} else if (qName.equals("keyName")) {
|
} else if (qName.equals("keyName")) {
|
||||||
this.keyName = currentText.toString().trim();
|
this.keyName = currentText.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,10 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.domain.IpPermission;
|
import org.jclouds.aws.ec2.domain.IpPermission;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
|
@ -39,6 +43,9 @@ import com.google.common.collect.Sets;
|
||||||
*/
|
*/
|
||||||
public class DescribeSecurityGroupsResponseHandler extends
|
public class DescribeSecurityGroupsResponseHandler extends
|
||||||
ParseSax.HandlerWithResult<SortedSet<SecurityGroup>> {
|
ParseSax.HandlerWithResult<SortedSet<SecurityGroup>> {
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private SortedSet<SecurityGroup> securtyGroups = Sets.newTreeSet();
|
private SortedSet<SecurityGroup> securtyGroups = Sets.newTreeSet();
|
||||||
|
@ -111,8 +118,11 @@ public class DescribeSecurityGroupsResponseHandler extends
|
||||||
this.userId = null;
|
this.userId = null;
|
||||||
this.userIdGroupName = null;
|
this.userIdGroupName = null;
|
||||||
} else if (!inIpPermissions && !inIpRanges && !inGroups) {
|
} else if (!inIpPermissions && !inIpRanges && !inGroups) {
|
||||||
securtyGroups.add(new SecurityGroup(EC2Utils.findRegionInArgsOrNull(request),
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
groupName, ownerId, groupDescription, ipPermissions));
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
securtyGroups.add(new SecurityGroup(region, groupName, ownerId, groupDescription,
|
||||||
|
ipPermissions));
|
||||||
this.groupName = null;
|
this.groupName = null;
|
||||||
this.ownerId = null;
|
this.ownerId = null;
|
||||||
this.groupDescription = null;
|
this.groupDescription = null;
|
||||||
|
|
|
@ -20,6 +20,10 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
|
@ -45,6 +49,9 @@ import com.google.common.collect.Sets;
|
||||||
*/
|
*/
|
||||||
public class InstanceStateChangeHandler extends HandlerWithResult<SortedSet<InstanceStateChange>> {
|
public class InstanceStateChangeHandler extends HandlerWithResult<SortedSet<InstanceStateChange>> {
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
|
|
||||||
SortedSet<InstanceStateChange> instances = Sets.newTreeSet();
|
SortedSet<InstanceStateChange> instances = Sets.newTreeSet();
|
||||||
private InstanceState shutdownState;
|
private InstanceState shutdownState;
|
||||||
|
@ -83,8 +90,10 @@ public class InstanceStateChangeHandler extends HandlerWithResult<SortedSet<Inst
|
||||||
previousState = InstanceState.fromValue(currentOrNull());
|
previousState = InstanceState.fromValue(currentOrNull());
|
||||||
}
|
}
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
instances.add(new InstanceStateChange(EC2Utils.findRegionInArgsOrNull(request),
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
instanceId, shutdownState, previousState));
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
instances.add(new InstanceStateChange(region, instanceId, shutdownState, previousState));
|
||||||
this.instanceId = null;
|
this.instanceId = null;
|
||||||
this.shutdownState = null;
|
this.shutdownState = null;
|
||||||
this.previousState = null;
|
this.previousState = null;
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.xml;
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
@ -30,15 +34,19 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class KeyPairResponseHandler extends ParseSax.HandlerWithResult<KeyPair> {
|
public class KeyPairResponseHandler extends ParseSax.HandlerWithResult<KeyPair> {
|
||||||
|
@Inject
|
||||||
|
@EC2
|
||||||
|
Region defaultRegion;
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private String keyFingerprint;
|
private String keyFingerprint;
|
||||||
private String keyMaterial;
|
private String keyMaterial;
|
||||||
private String keyName;
|
private String keyName;
|
||||||
|
|
||||||
public KeyPair getResult() {
|
public KeyPair getResult() {
|
||||||
return new KeyPair(EC2Utils.findRegionInArgsOrNull(request), keyName, keyFingerprint,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
keyMaterial);
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
return new KeyPair(region, keyName, keyFingerprint, keyMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
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.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
|
||||||
|
@ -34,8 +36,8 @@ import org.jclouds.date.DateService;
|
||||||
public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation> {
|
public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RunInstancesResponseHandler(DateService dateService) {
|
RunInstancesResponseHandler(DateService dateService, @EC2 Region defaultRegion) {
|
||||||
super(dateService);
|
super(dateService, defaultRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Date;
|
||||||
|
|
||||||
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.domain.Snapshot;
|
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||||
import org.jclouds.aws.ec2.domain.Snapshot.Status;
|
import org.jclouds.aws.ec2.domain.Snapshot.Status;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
|
@ -35,8 +37,9 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
public class SnapshotHandler extends ParseSax.HandlerWithResult<Snapshot> {
|
public class SnapshotHandler extends ParseSax.HandlerWithResult<Snapshot> {
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
@Inject
|
protected final DateService dateService;
|
||||||
protected DateService dateService;
|
protected final Region defaultRegion;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String volumeId;
|
private String volumeId;
|
||||||
private int volumeSize;
|
private int volumeSize;
|
||||||
|
@ -47,9 +50,18 @@ public class SnapshotHandler extends ParseSax.HandlerWithResult<Snapshot> {
|
||||||
private String description;
|
private String description;
|
||||||
private String ownerAlias;
|
private String ownerAlias;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SnapshotHandler(DateService dateService, @EC2 Region defaultRegion) {
|
||||||
|
this.dateService = dateService;
|
||||||
|
this.defaultRegion = defaultRegion;
|
||||||
|
}
|
||||||
|
|
||||||
public Snapshot getResult() {
|
public Snapshot getResult() {
|
||||||
Snapshot snapshot = new Snapshot(EC2Utils.findRegionInArgsOrNull(request), id, volumeId,
|
Region region = EC2Utils.findRegionInArgsOrNull(request);
|
||||||
volumeSize, status, startTime, progress, ownerId, description, ownerAlias);
|
if (region == null)
|
||||||
|
region = defaultRegion;
|
||||||
|
Snapshot snapshot = new Snapshot(region, id, volumeId, volumeSize, status, startTime,
|
||||||
|
progress, ownerId, description, ownerAlias);
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.volumeId = null;
|
this.volumeId = null;
|
||||||
this.volumeSize = 0;
|
this.volumeSize = 0;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.blobstore.attr.BlobScopes.CONTAINER;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HEAD;
|
import javax.ws.rs.HEAD;
|
||||||
|
@ -166,7 +167,7 @@ public interface S3AsyncClient {
|
||||||
@ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYou.class)
|
@ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYou.class)
|
||||||
ListenableFuture<Boolean> putBucketInRegion(
|
ListenableFuture<Boolean> putBucketInRegion(
|
||||||
// TODO endpoint based on region
|
// TODO endpoint based on region
|
||||||
@BinderParam(BindRegionToXmlPayload.class) Region region,
|
@BinderParam(BindRegionToXmlPayload.class) @Nullable Region region,
|
||||||
@HostPrefixParam String bucketName, PutBucketOptions... options);
|
@HostPrefixParam String bucketName, PutBucketOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.SortedSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.s3.domain.AccessControlList;
|
import org.jclouds.aws.s3.domain.AccessControlList;
|
||||||
import org.jclouds.aws.s3.domain.BucketLogging;
|
import org.jclouds.aws.s3.domain.BucketLogging;
|
||||||
|
@ -194,7 +196,7 @@ public interface S3Client {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||||
boolean putBucketInRegion(Region region, String bucketName, PutBucketOptions... options);
|
boolean putBucketInRegion(@Nullable Region region, String bucketName, PutBucketOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the bucket, if it is empty.
|
* Deletes the bucket, if it is empty.
|
||||||
|
|
|
@ -24,6 +24,9 @@ import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
||||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT;
|
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT;
|
||||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERVAL;
|
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERVAL;
|
||||||
|
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT_EU_WEST_1;
|
||||||
|
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT_US_STANDARD;
|
||||||
|
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT_US_WEST_1;
|
||||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER;
|
import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER;
|
||||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX;
|
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX;
|
||||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||||
|
@ -45,6 +48,9 @@ public class S3PropertiesBuilder extends PropertiesBuilder {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
|
properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
properties.setProperty(PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com");
|
properties.setProperty(PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_S3_ENDPOINT_US_STANDARD, "https://s3.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_S3_ENDPOINT_US_WEST_1, "https://s3-us-west-1.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_S3_ENDPOINT_EU_WEST_1, "https://s3-eu-west-1.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-amz-meta-");
|
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-amz-meta-");
|
||||||
properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, "60");
|
properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, "60");
|
||||||
properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER);
|
properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.aws.s3.blobstore;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Futures.compose;
|
import static com.google.common.util.concurrent.Futures.compose;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -81,14 +83,15 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
S3AsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
S3AsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, S3AsyncClient async,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
||||||
S3Client sync, BucketToResourceMetadata bucket2ResourceMd,
|
Location defaultLocation, Map<String, ? extends Location> locations,
|
||||||
|
S3AsyncClient async, S3Client sync, BucketToResourceMetadata bucket2ResourceMd,
|
||||||
ContainerToBucketListOptions container2BucketListOptions,
|
ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object,
|
||||||
ObjectToBlobMetadata object2BlobMd,
|
ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
||||||
super(context, blobUtils, service);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.async = checkNotNull(async, "async");
|
this.async = checkNotNull(async, "async");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
|
@ -139,8 +142,9 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
* bucket name
|
* bucket name
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Boolean> createContainerInLocation(String location, String container) {
|
public ListenableFuture<Boolean> createContainerInLocation(Location location, String container) {
|
||||||
return async.putBucketInRegion(Region.fromValue(location), container);
|
location = location != null ? location : defaultLocation;
|
||||||
|
return async.putBucketInRegion(Region.fromValue(location.getId()), container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.aws.s3.blobstore;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -48,6 +49,7 @@ import org.jclouds.blobstore.internal.BaseBlobStore;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
|
|
||||||
|
@ -72,14 +74,15 @@ public class S3BlobStore extends BaseBlobStore {
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
S3BlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, S3Client sync,
|
S3BlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, Location defaultLocation,
|
||||||
|
Map<String, ? extends Location> locations, S3Client sync,
|
||||||
BucketToResourceMetadata bucket2ResourceMd,
|
BucketToResourceMetadata bucket2ResourceMd,
|
||||||
ContainerToBucketListOptions container2BucketListOptions,
|
ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object,
|
||||||
ObjectToBlobMetadata object2BlobMd,
|
ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
||||||
super(context, blobUtils);
|
super(context, blobUtils, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
this.bucket2ResourceMd = checkNotNull(bucket2ResourceMd, "bucket2ResourceMd");
|
this.bucket2ResourceMd = checkNotNull(bucket2ResourceMd, "bucket2ResourceMd");
|
||||||
|
@ -127,8 +130,9 @@ public class S3BlobStore extends BaseBlobStore {
|
||||||
* bucket name
|
* bucket name
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createContainerInLocation(String location, String container) {
|
public boolean createContainerInLocation(Location location, String container) {
|
||||||
return sync.putBucketInRegion(Region.fromValue(location), container);
|
location = location != null ? location : defaultLocation;
|
||||||
|
return sync.putBucketInRegion(Region.fromValue(location.getId()), container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.blobstore.config;
|
package org.jclouds.aws.s3.blobstore.config;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.s3.S3;
|
||||||
import org.jclouds.aws.s3.S3AsyncClient;
|
import org.jclouds.aws.s3.S3AsyncClient;
|
||||||
import org.jclouds.aws.s3.S3Client;
|
import org.jclouds.aws.s3.S3Client;
|
||||||
import org.jclouds.aws.s3.blobstore.S3AsyncBlobStore;
|
import org.jclouds.aws.s3.blobstore.S3AsyncBlobStore;
|
||||||
|
@ -29,7 +36,14 @@ import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -51,4 +65,26 @@ public class S3BlobStoreContextModule extends S3ContextModule {
|
||||||
new TypeLiteral<BlobStoreContextImpl<S3AsyncClient, S3Client>>() {
|
new TypeLiteral<BlobStoreContextImpl<S3AsyncClient, S3Client>>() {
|
||||||
}).in(Scopes.SINGLETON);
|
}).in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
Location getDefaultLocation(@S3 Region region, Map<String, ? extends Location> locations) {
|
||||||
|
return locations.get(region.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
Map<String, ? extends Location> provideLocations(@S3 Set<Region> regions) {
|
||||||
|
Set<Location> locations = Sets.newHashSet();
|
||||||
|
for (Region zone : regions) {
|
||||||
|
locations
|
||||||
|
.add(new LocationImpl(LocationScope.ZONE, zone.toString(), zone.toString(), null));
|
||||||
|
}
|
||||||
|
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(Location from) {
|
||||||
|
return from.getId();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,22 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.blobstore.functions;
|
package org.jclouds.aws.s3.blobstore.functions;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.s3.S3Client;
|
||||||
import org.jclouds.aws.s3.domain.BucketMetadata;
|
import org.jclouds.aws.s3.domain.BucketMetadata;
|
||||||
|
import org.jclouds.blobstore.ContainerNotFoundException;
|
||||||
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageType;
|
import org.jclouds.blobstore.domain.StorageType;
|
||||||
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@ -33,10 +42,37 @@ import com.google.common.base.Function;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BucketToResourceMetadata implements Function<BucketMetadata, StorageMetadata> {
|
public class BucketToResourceMetadata implements Function<BucketMetadata, StorageMetadata> {
|
||||||
|
private final S3Client client;
|
||||||
|
private final Map<String, ? extends Location> locations;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BucketToResourceMetadata(S3Client client, Map<String, ? extends Location> locations) {
|
||||||
|
this.client = client;
|
||||||
|
this.locations = locations;
|
||||||
|
}
|
||||||
|
|
||||||
public StorageMetadata apply(BucketMetadata from) {
|
public StorageMetadata apply(BucketMetadata from) {
|
||||||
MutableStorageMetadata to = new MutableStorageMetadataImpl();
|
MutableStorageMetadata to = new MutableStorageMetadataImpl();
|
||||||
to.setName(from.getName());
|
to.setName(from.getName());
|
||||||
to.setType(StorageType.CONTAINER);
|
to.setType(StorageType.CONTAINER);
|
||||||
|
try {
|
||||||
|
Region region = client.getBucketLocation(from.getName());
|
||||||
|
if (region != null) {
|
||||||
|
Location location = locations.get(region.toString());
|
||||||
|
if (location == null)
|
||||||
|
logger.error("could not get location for region %s in %s", region, locations);
|
||||||
|
to.setLocation(location);
|
||||||
|
} else {
|
||||||
|
logger.error("could not get region for %s", from.getName());
|
||||||
|
}
|
||||||
|
} catch (ContainerNotFoundException e) {
|
||||||
|
logger.error(e,
|
||||||
|
"could not get region for %s, as service suggests the bucket doesn't exist", from
|
||||||
|
.getName());
|
||||||
|
}
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,11 +19,14 @@
|
||||||
package org.jclouds.aws.s3.config;
|
package org.jclouds.aws.s3.config;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.handlers.AWSClientErrorRetryHandler;
|
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||||
|
@ -47,6 +50,8 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientFactory;
|
import org.jclouds.rest.RestClientFactory;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableBiMap;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
@ -94,6 +99,24 @@ public class S3RestClientModule extends AbstractModule {
|
||||||
bindRetryHandlers();
|
bindRetryHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@S3
|
||||||
|
Map<Region, URI> provideRegions(
|
||||||
|
@Named(S3Constants.PROPERTY_S3_ENDPOINT_US_STANDARD) String usstandard,
|
||||||
|
@Named(S3Constants.PROPERTY_S3_ENDPOINT_US_WEST_1) String uswest,
|
||||||
|
@Named(S3Constants.PROPERTY_S3_ENDPOINT_EU_WEST_1) String euwest) {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.US_STANDARD, URI.create(usstandard),
|
||||||
|
Region.US_WEST_1, URI.create(uswest), Region.EU_WEST_1, URI.create(euwest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@S3
|
||||||
|
Set<Region> provideRegions(@S3 Map<Region, URI> map) {
|
||||||
|
return map.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@S3
|
@S3
|
||||||
|
@ -101,6 +124,13 @@ public class S3RestClientModule extends AbstractModule {
|
||||||
return URI.create(endpoint);
|
return URI.create(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@S3
|
||||||
|
Region getDefaultRegion(@S3 URI uri, @S3 Map<Region, URI> map) {
|
||||||
|
return ImmutableBiMap.copyOf(map).inverse().get(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected S3AsyncClient provideAsyncClient(RestClientFactory factory) {
|
protected S3AsyncClient provideAsyncClient(RestClientFactory factory) {
|
||||||
|
|
|
@ -20,11 +20,12 @@
|
||||||
package org.jclouds.aws.s3.functions;
|
package org.jclouds.aws.s3.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.s3.S3;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
|
|
||||||
|
@ -39,16 +40,23 @@ import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindRegionToXmlPayload extends BindToStringPayload {
|
public class BindRegionToXmlPayload extends BindToStringPayload {
|
||||||
|
|
||||||
|
private final Region defaultRegion;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BindRegionToXmlPayload(@S3 Region defaultRegion) {
|
||||||
|
this.defaultRegion = defaultRegion;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindToRequest(HttpRequest request, Object input) {
|
public void bindToRequest(HttpRequest request, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof Region,
|
input = input == null ? defaultRegion : input;
|
||||||
"this binder is only valid for Region!");
|
checkArgument(input instanceof Region, "this binder is only valid for Region!");
|
||||||
Region constraint = (Region) input;
|
Region constraint = (Region) input;
|
||||||
String value = null;
|
String value = null;
|
||||||
switch (constraint) {
|
switch (constraint) {
|
||||||
case US_STANDARD:
|
case US_STANDARD:
|
||||||
case US_EAST_1:
|
case US_EAST_1:
|
||||||
case DEFAULT:// TODO get this from the url
|
// nothing to bind as this is default.
|
||||||
return;
|
return;
|
||||||
case EU_WEST_1:
|
case EU_WEST_1:
|
||||||
value = "EU";
|
value = "EU";
|
||||||
|
@ -59,12 +67,11 @@ public class BindRegionToXmlPayload extends BindToStringPayload {
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("unimplemented location: " + this);
|
throw new IllegalStateException("unimplemented location: " + this);
|
||||||
}
|
}
|
||||||
super
|
String payload = String
|
||||||
.bindToRequest(
|
|
||||||
request,
|
|
||||||
String
|
|
||||||
.format(
|
.format(
|
||||||
"<CreateBucketConfiguration><LocationConstraint>%s</LocationConstraint></CreateBucketConfiguration>",
|
"<CreateBucketConfiguration><LocationConstraint>%s</LocationConstraint></CreateBucketConfiguration>",
|
||||||
value));
|
value);
|
||||||
|
super.bindToRequest(request, payload);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,4 +41,8 @@ public interface S3Constants extends AWSConstants, S3Headers {
|
||||||
*/
|
*/
|
||||||
public static final String PROPERTY_S3_SESSIONINTERVAL = "jclouds.s3.sessioninterval";
|
public static final String PROPERTY_S3_SESSIONINTERVAL = "jclouds.s3.sessioninterval";
|
||||||
|
|
||||||
|
public static final String PROPERTY_S3_ENDPOINT_EU_WEST_1 = "jclouds.s3.endpoint.eu_west_1";
|
||||||
|
public static final String PROPERTY_S3_ENDPOINT_US_STANDARD = "jclouds.s3.endpoint.us_standard";
|
||||||
|
public static final String PROPERTY_S3_ENDPOINT_US_WEST_1 = "jclouds.s3.endpoint.us_west_1";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.sqs.reference.SQSParameters.VERSION;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
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;
|
||||||
|
@ -64,7 +65,7 @@ public interface SQSAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "ListQueues")
|
@FormParams(keys = ACTION, values = "ListQueues")
|
||||||
@ResponseParser(RegexListQueuesResponseHandler.class)
|
@ResponseParser(RegexListQueuesResponseHandler.class)
|
||||||
ListenableFuture<? extends Set<Queue>> listQueuesInRegion(
|
ListenableFuture<? extends Set<Queue>> listQueuesInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
ListQueuesOptions... options);
|
ListQueuesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +76,7 @@ public interface SQSAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "CreateQueue")
|
@FormParams(keys = ACTION, values = "CreateQueue")
|
||||||
@ResponseParser(RegexQueueHandler.class)
|
@ResponseParser(RegexQueueHandler.class)
|
||||||
ListenableFuture<Queue> createQueueInRegion(
|
ListenableFuture<Queue> createQueueInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable Region region,
|
||||||
@FormParam("QueueName") String queueName, CreateQueueOptions... options);
|
@FormParam("QueueName") String queueName, CreateQueueOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.aws.sqs;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.sqs.domain.Queue;
|
import org.jclouds.aws.sqs.domain.Queue;
|
||||||
import org.jclouds.aws.sqs.options.CreateQueueOptions;
|
import org.jclouds.aws.sqs.options.CreateQueueOptions;
|
||||||
|
@ -49,7 +51,7 @@ public interface SQSClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/APIReference/Query_QueryListQueues.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/APIReference/Query_QueryListQueues.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Set<Queue> listQueuesInRegion(Region region, ListQueuesOptions... options);
|
Set<Queue> listQueuesInRegion(@Nullable Region region, ListQueuesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -79,7 +81,7 @@ public interface SQSClient {
|
||||||
* @param options
|
* @param options
|
||||||
* like the visibility timeout (in seconds) to use for this queue.
|
* like the visibility timeout (in seconds) to use for this queue.
|
||||||
*/
|
*/
|
||||||
Queue createQueueInRegion(Region region, String queueName, CreateQueueOptions... options);
|
Queue createQueueInRegion(@Nullable Region region, String queueName, CreateQueueOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DeleteQueue action deletes the queue specified by the queue URL, regardless of whether the
|
* The DeleteQueue action deletes the queue specified by the queue URL, regardless of whether the
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
||||||
|
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT;
|
||||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1;
|
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1;
|
||||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1;
|
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1;
|
||||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1;
|
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1;
|
||||||
|
@ -40,9 +41,12 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
|
properties.setProperty(PROPERTY_SQS_ENDPOINT, "https://queue.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://queue.amazonaws.com");
|
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://queue.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1, "https://us-west-1.queue.amazonaws.com");
|
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1,
|
||||||
properties.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1, "https://eu-west-1.queue.amazonaws.com");
|
"https://us-west-1.queue.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1,
|
||||||
|
"https://eu-west-1.queue.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +68,7 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQSPropertiesBuilder withEndpoint(URI endpoint) {
|
public SQSPropertiesBuilder withEndpoint(URI endpoint) {
|
||||||
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, checkNotNull(endpoint, "endpoint").toString());
|
properties.setProperty(PROPERTY_SQS_ENDPOINT, checkNotNull(endpoint, "endpoint").toString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.jclouds.http.annotation.ServerError;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientFactory;
|
import org.jclouds.rest.RestClientFactory;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableBiMap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -89,6 +90,7 @@ public class SQSRestClientModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@SQS
|
||||||
Map<Region, URI> provideRegions(
|
Map<Region, URI> provideRegions(
|
||||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast,
|
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast,
|
||||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest,
|
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest,
|
||||||
|
@ -99,15 +101,22 @@ public class SQSRestClientModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
RequestSigner provideRequestSigner(FormSigner in) {
|
@SQS
|
||||||
return in;
|
protected URI provideURI(@Named(SQSConstants.PROPERTY_SQS_ENDPOINT) String endpoint) {
|
||||||
|
return URI.create(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@SQS
|
@SQS
|
||||||
protected URI provideURI(@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String endpoint) {
|
Region getDefaultRegion(@SQS URI uri, @SQS Map<Region, URI> map) {
|
||||||
return URI.create(endpoint);
|
return ImmutableBiMap.copyOf(map).inverse().get(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
RequestSigner provideRequestSigner(FormSigner in) {
|
||||||
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bindErrorHandlers() {
|
protected void bindErrorHandlers() {
|
||||||
|
|
|
@ -39,13 +39,13 @@ public class RegionToEndpoint implements Function<Object, URI> {
|
||||||
private final URI defaultUri;
|
private final URI defaultUri;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RegionToEndpoint(Map<Region, URI> regionToEndpoint, @SQS URI defaultUri) {
|
public RegionToEndpoint(@SQS Map<Region, URI> regionToEndpoint, @SQS URI defaultUri) {
|
||||||
this.regionToEndpoint = regionToEndpoint;
|
this.regionToEndpoint = regionToEndpoint;
|
||||||
this.defaultUri = defaultUri;
|
this.defaultUri = defaultUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI apply(Object from) {
|
public URI apply(Object from) {
|
||||||
return from.equals(Region.DEFAULT) ? defaultUri : regionToEndpoint.get(from);
|
return from == null ? defaultUri : regionToEndpoint.get(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@ import org.jclouds.aws.reference.AWSConstants;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface SQSConstants extends AWSConstants {
|
public interface SQSConstants extends AWSConstants {
|
||||||
|
public static final String PROPERTY_SQS_ENDPOINT = "jclouds.sqs.endpoint";
|
||||||
|
|
||||||
public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1";
|
public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1";
|
||||||
public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1";
|
public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1";
|
||||||
public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1";
|
public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1";
|
||||||
|
|
|
@ -26,6 +26,7 @@ import javax.inject.Provider;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.sqs.SQS;
|
||||||
import org.jclouds.aws.sqs.domain.Queue;
|
import org.jclouds.aws.sqs.domain.Queue;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class QueueHandler extends ParseSax.HandlerWithResult<Queue> {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
private final Provider<UriBuilder> uriBuilderProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
QueueHandler(Provider<UriBuilder> uriBuilderProvider, Map<Region, URI> regionMap) {
|
QueueHandler(Provider<UriBuilder> uriBuilderProvider, @SQS Map<Region, URI> regionMap) {
|
||||||
this.uriBuilderProvider = uriBuilderProvider;
|
this.uriBuilderProvider = uriBuilderProvider;
|
||||||
this.regionBiMap = ImmutableBiMap.copyOf(regionMap);
|
this.regionBiMap = ImmutableBiMap.copyOf(regionMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.sqs.SQS;
|
||||||
import org.jclouds.aws.sqs.domain.Queue;
|
import org.jclouds.aws.sqs.domain.Queue;
|
||||||
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
|
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
@ -45,7 +46,7 @@ import com.google.common.base.Throwables;
|
||||||
public class RegexListQueuesResponseHandler extends BaseRegexQueueHandler implements
|
public class RegexListQueuesResponseHandler extends BaseRegexQueueHandler implements
|
||||||
Function<HttpResponse, Set<Queue>> {
|
Function<HttpResponse, Set<Queue>> {
|
||||||
@Inject
|
@Inject
|
||||||
RegexListQueuesResponseHandler(Map<Region, URI> regionMap) {
|
RegexListQueuesResponseHandler(@SQS Map<Region, URI> regionMap) {
|
||||||
super(regionMap);
|
super(regionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.sqs.SQS;
|
||||||
import org.jclouds.aws.sqs.domain.Queue;
|
import org.jclouds.aws.sqs.domain.Queue;
|
||||||
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
|
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
@ -45,7 +46,7 @@ import com.google.inject.internal.Iterables;
|
||||||
public class RegexQueueHandler extends BaseRegexQueueHandler implements
|
public class RegexQueueHandler extends BaseRegexQueueHandler implements
|
||||||
Function<HttpResponse, Queue> {
|
Function<HttpResponse, Queue> {
|
||||||
@Inject
|
@Inject
|
||||||
RegexQueueHandler(Map<Region, URI> regionMap) {
|
RegexQueueHandler(@SQS Map<Region, URI> regionMap) {
|
||||||
super(regionMap);
|
super(regionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,14 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
||||||
import org.jclouds.aws.ec2.domain.*;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||||
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||||
import org.jclouds.aws.ec2.predicates.InstanceHasIpAddress;
|
import org.jclouds.aws.ec2.predicates.InstanceHasIpAddress;
|
||||||
|
@ -105,15 +111,15 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
securityGroupName = instancePrefix + "ingress";
|
securityGroupName = instancePrefix + "ingress";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(null,
|
||||||
securityGroupName);
|
securityGroupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().createSecurityGroupInRegion(null,
|
||||||
securityGroupName, securityGroupName);
|
securityGroupName, securityGroupName);
|
||||||
for (int port : new int[] { 80, 443, 22 }) {
|
for (int port : new int[] { 80, 443, 22 }) {
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null,
|
||||||
securityGroupName, IpProtocol.TCP, port, port, "0.0.0.0/0");
|
securityGroupName, IpProtocol.TCP, port, port, "0.0.0.0/0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,13 +128,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String keyName = instancePrefix + "1";
|
String keyName = instancePrefix + "1";
|
||||||
try {
|
try {
|
||||||
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
client.getKeyPairServices().deleteKeyPairInRegion(null, keyName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
client.getKeyPairServices().deleteKeyPairInRegion(null, keyName);
|
||||||
|
|
||||||
keyPair = client.getKeyPairServices().createKeyPairInRegion(Region.DEFAULT, keyName);
|
keyPair = client.getKeyPairServices().createKeyPairInRegion(null, keyName);
|
||||||
assertNotNull(keyPair);
|
assertNotNull(keyPair);
|
||||||
assertNotNull(keyPair.getKeyMaterial());
|
assertNotNull(keyPair.getKeyMaterial());
|
||||||
assertNotNull(keyPair.getKeyFingerprint());
|
assertNotNull(keyPair.getKeyFingerprint());
|
||||||
|
@ -149,7 +155,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
|
|
||||||
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
||||||
Reservation reservation = client.getInstanceServices().runInstancesInRegion(
|
Reservation reservation = client.getInstanceServices().runInstancesInRegion(
|
||||||
Region.DEFAULT, null, // allow ec2 to chose an availability zone
|
null, null, // allow ec2 to chose an availability zone
|
||||||
"ami-ccf615a5", // alestic ami allows auto-invoke of user data scripts
|
"ami-ccf615a5", // alestic ami allows auto-invoke of user data scripts
|
||||||
1, // minimum instances
|
1, // minimum instances
|
||||||
1, // maximum instances
|
1, // maximum instances
|
||||||
|
@ -180,39 +186,39 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
|
|
||||||
private void verifyInstanceProperties(String script) {
|
private void verifyInstanceProperties(String script) {
|
||||||
assertEquals(script, client.getInstanceServices().getUserDataForInstanceInRegion(
|
assertEquals(script, client.getInstanceServices().getUserDataForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId));
|
null, instanceId));
|
||||||
|
|
||||||
assertEquals(null, client.getInstanceServices().getRootDeviceNameForInstanceInRegion(
|
assertEquals(null, client.getInstanceServices().getRootDeviceNameForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId));
|
null, instanceId));
|
||||||
|
|
||||||
assert client.getInstanceServices().getRamdiskForInstanceInRegion(Region.DEFAULT, instanceId)
|
assert client.getInstanceServices().getRamdiskForInstanceInRegion(null, instanceId)
|
||||||
.startsWith("ari-");
|
.startsWith("ari-");
|
||||||
|
|
||||||
assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId));
|
null, instanceId));
|
||||||
|
|
||||||
assert client.getInstanceServices().getKernelForInstanceInRegion(Region.DEFAULT, instanceId)
|
assert client.getInstanceServices().getKernelForInstanceInRegion(null, instanceId)
|
||||||
.startsWith("aki-");
|
.startsWith("aki-");
|
||||||
|
|
||||||
assertEquals(InstanceType.M1_SMALL, client.getInstanceServices()
|
assertEquals(InstanceType.M1_SMALL, client.getInstanceServices()
|
||||||
.getInstanceTypeForInstanceInRegion(Region.DEFAULT, instanceId));
|
.getInstanceTypeForInstanceInRegion(null, instanceId));
|
||||||
|
|
||||||
assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices()
|
assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices()
|
||||||
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(Region.DEFAULT, instanceId));
|
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId));
|
||||||
|
|
||||||
assertEquals(ImmutableMap.<String, EbsBlockDevice> of(), client.getInstanceServices()
|
assertEquals(ImmutableMap.<String, EbsBlockDevice> of(), client.getInstanceServices()
|
||||||
.getBlockDeviceMappingForInstanceInRegion(Region.DEFAULT, instanceId));
|
.getBlockDeviceMappingForInstanceInRegion(null, instanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setApiTerminationDisabledForInstanceInRegion() {
|
private void setApiTerminationDisabledForInstanceInRegion() {
|
||||||
client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null,
|
||||||
instanceId, true);
|
instanceId, true);
|
||||||
assertEquals(true, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
assertEquals(true, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId));
|
null, instanceId));
|
||||||
client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null,
|
||||||
instanceId, false);
|
instanceId, false);
|
||||||
assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId));
|
null, instanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryToChangeStuff() {
|
private void tryToChangeStuff() {
|
||||||
|
@ -227,7 +233,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
|
|
||||||
private void setUserDataForInstanceInRegion() {
|
private void setUserDataForInstanceInRegion() {
|
||||||
try {
|
try {
|
||||||
client.getInstanceServices().setUserDataForInstanceInRegion(Region.DEFAULT, instanceId,
|
client.getInstanceServices().setUserDataForInstanceInRegion(null, instanceId,
|
||||||
"test".getBytes());
|
"test".getBytes());
|
||||||
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -238,8 +244,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
private void setRamdiskForInstanceInRegion() {
|
private void setRamdiskForInstanceInRegion() {
|
||||||
try {
|
try {
|
||||||
String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(
|
String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId);
|
null, instanceId);
|
||||||
client.getInstanceServices().setRamdiskForInstanceInRegion(Region.DEFAULT, instanceId,
|
client.getInstanceServices().setRamdiskForInstanceInRegion(null, instanceId,
|
||||||
ramdisk);
|
ramdisk);
|
||||||
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -250,8 +256,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
private void setKernelForInstanceInRegion() {
|
private void setKernelForInstanceInRegion() {
|
||||||
try {
|
try {
|
||||||
String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(
|
String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId);
|
null, instanceId);
|
||||||
client.getInstanceServices().setKernelForInstanceInRegion(Region.DEFAULT, instanceId,
|
client.getInstanceServices().setKernelForInstanceInRegion(null, instanceId,
|
||||||
oldKernel);
|
oldKernel);
|
||||||
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -261,7 +267,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
|
|
||||||
private void setInstanceTypeForInstanceInRegion() {
|
private void setInstanceTypeForInstanceInRegion() {
|
||||||
try {
|
try {
|
||||||
client.getInstanceServices().setInstanceTypeForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setInstanceTypeForInstanceInRegion(null,
|
||||||
instanceId, InstanceType.C1_MEDIUM);
|
instanceId, InstanceType.C1_MEDIUM);
|
||||||
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
assert false : "shouldn't be allowed, as instance needs to be stopped";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -272,7 +278,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
private void setBlockDeviceMappingForInstanceInRegion() {
|
private void setBlockDeviceMappingForInstanceInRegion() {
|
||||||
BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
|
BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
|
||||||
try {
|
try {
|
||||||
client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null,
|
||||||
instanceId, blockDeviceMapping);
|
instanceId, blockDeviceMapping);
|
||||||
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
|
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -283,7 +289,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() {
|
private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() {
|
||||||
try {
|
try {
|
||||||
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
||||||
Region.DEFAULT, instanceId, InstanceInitiatedShutdownBehavior.STOP);
|
null, instanceId, InstanceInitiatedShutdownBehavior.STOP);
|
||||||
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
|
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
assertEquals("UnsupportedInstanceAttribute", e.getError().getCode());
|
assertEquals("UnsupportedInstanceAttribute", e.getError().getCode());
|
||||||
|
@ -294,7 +300,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
void testReboot() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
void testReboot() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
RunningInstance instance = getInstance(instanceId);
|
RunningInstance instance = getInstance(instanceId);
|
||||||
System.out.printf("%d: %s rebooting instance %n", System.currentTimeMillis(), instanceId);
|
System.out.printf("%d: %s rebooting instance %n", System.currentTimeMillis(), instanceId);
|
||||||
client.getInstanceServices().rebootInstancesInRegion(Region.DEFAULT, instanceId);
|
client.getInstanceServices().rebootInstancesInRegion(null, instanceId);
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
instance = getInstance(instanceId);
|
instance = getInstance(instanceId);
|
||||||
blockUntilWeCanSshIntoInstance(instance);
|
blockUntilWeCanSshIntoInstance(instance);
|
||||||
|
@ -313,42 +319,42 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
@Test(enabled = false, dependsOnMethods = "testReboot")
|
@Test(enabled = false, dependsOnMethods = "testReboot")
|
||||||
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
address = client.getElasticIPAddressServices().allocateAddressInRegion(Region.DEFAULT);
|
address = client.getElasticIPAddressServices().allocateAddressInRegion(null);
|
||||||
assertNotNull(address);
|
assertNotNull(address);
|
||||||
|
|
||||||
PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressServices()
|
PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressServices()
|
||||||
.describeAddressesInRegion(Region.DEFAULT, address));
|
.describeAddressesInRegion(null, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assert compare.getInstanceId() == null;
|
assert compare.getInstanceId() == null;
|
||||||
|
|
||||||
client.getElasticIPAddressServices().associateAddressInRegion(Region.DEFAULT, address,
|
client.getElasticIPAddressServices().associateAddressInRegion(null, address,
|
||||||
instanceId);
|
instanceId);
|
||||||
|
|
||||||
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
||||||
Region.DEFAULT, address));
|
null, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assertEquals(compare.getInstanceId(), instanceId);
|
assertEquals(compare.getInstanceId(), instanceId);
|
||||||
|
|
||||||
Reservation reservation = Iterables.getOnlyElement(client.getInstanceServices()
|
Reservation reservation = Iterables.getOnlyElement(client.getInstanceServices()
|
||||||
.describeInstancesInRegion(Region.DEFAULT, instanceId));
|
.describeInstancesInRegion(null, instanceId));
|
||||||
|
|
||||||
assertNotNull(Iterables.getOnlyElement(reservation).getIpAddress());
|
assertNotNull(Iterables.getOnlyElement(reservation).getIpAddress());
|
||||||
assertFalse(Iterables.getOnlyElement(reservation).getIpAddress().equals(address));
|
assertFalse(Iterables.getOnlyElement(reservation).getIpAddress().equals(address));
|
||||||
|
|
||||||
doCheckKey(address);
|
doCheckKey(address);
|
||||||
|
|
||||||
client.getElasticIPAddressServices().disassociateAddressInRegion(Region.DEFAULT, address);
|
client.getElasticIPAddressServices().disassociateAddressInRegion(null, address);
|
||||||
|
|
||||||
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
||||||
Region.DEFAULT, address));
|
null, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assert compare.getInstanceId() == null;
|
assert compare.getInstanceId() == null;
|
||||||
|
|
||||||
reservation = Iterables.getOnlyElement(client.getInstanceServices()
|
reservation = Iterables.getOnlyElement(client.getInstanceServices()
|
||||||
.describeInstancesInRegion(Region.DEFAULT, instanceId));
|
.describeInstancesInRegion(null, instanceId));
|
||||||
// assert reservation.getRunningInstances().last().getIpAddress() == null; TODO
|
// assert reservation.getRunningInstances().last().getIpAddress() == null; TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +391,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
private RunningInstance getInstance(String instanceId) {
|
private RunningInstance getInstance(String instanceId) {
|
||||||
// search my account for the instance I just created
|
// search my account for the instance I just created
|
||||||
Set<Reservation> reservations = client.getInstanceServices().describeInstancesInRegion(
|
Set<Reservation> reservations = client.getInstanceServices().describeInstancesInRegion(
|
||||||
Region.DEFAULT, instanceId); // last parameter (ids) narrows the search
|
null, instanceId); // last parameter (ids) narrows the search
|
||||||
|
|
||||||
return Iterables.getOnlyElement(Iterables.getOnlyElement(reservations));
|
return Iterables.getOnlyElement(Iterables.getOnlyElement(reservations));
|
||||||
}
|
}
|
||||||
|
@ -427,13 +433,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
|
||||||
@AfterTest
|
@AfterTest
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
if (address != null)
|
if (address != null)
|
||||||
client.getElasticIPAddressServices().releaseAddressInRegion(Region.DEFAULT, address);
|
client.getElasticIPAddressServices().releaseAddressInRegion(null, address);
|
||||||
if (instanceId != null)
|
if (instanceId != null)
|
||||||
client.getInstanceServices().terminateInstancesInRegion(Region.DEFAULT, instanceId);
|
client.getInstanceServices().terminateInstancesInRegion(null, instanceId);
|
||||||
if (keyPair != null)
|
if (keyPair != null)
|
||||||
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyPair.getKeyName());
|
client.getKeyPairServices().deleteKeyPairInRegion(null, keyPair.getKeyName());
|
||||||
if (securityGroupName != null)
|
if (securityGroupName != null)
|
||||||
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(null,
|
||||||
securityGroupName);
|
securityGroupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,18 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.ec2.domain.Attachment;
|
||||||
import org.jclouds.aws.ec2.domain.*;
|
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
||||||
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
|
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||||
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
|
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||||
|
import org.jclouds.aws.ec2.domain.Volume;
|
||||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||||
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||||
|
@ -147,18 +157,18 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
securityGroupName = INSTANCE_PREFIX + "ingress";
|
securityGroupName = INSTANCE_PREFIX + "ingress";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(null,
|
||||||
securityGroupName);
|
securityGroupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().createSecurityGroupInRegion(null,
|
||||||
securityGroupName, securityGroupName);
|
securityGroupName, securityGroupName);
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null,
|
||||||
securityGroupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0");
|
securityGroupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0");
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null,
|
||||||
securityGroupName, IpProtocol.TCP, 443, 443, "0.0.0.0/0");
|
securityGroupName, IpProtocol.TCP, 443, 443, "0.0.0.0/0");
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null,
|
||||||
securityGroupName, IpProtocol.TCP, 22, 22, "0.0.0.0/0");
|
securityGroupName, IpProtocol.TCP, 22, 22, "0.0.0.0/0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +176,12 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
void testCreateKeyPair() {
|
void testCreateKeyPair() {
|
||||||
String keyName = INSTANCE_PREFIX + "1";
|
String keyName = INSTANCE_PREFIX + "1";
|
||||||
try {
|
try {
|
||||||
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
client.getKeyPairServices().deleteKeyPairInRegion(null, keyName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPair = client.getKeyPairServices().createKeyPairInRegion(Region.DEFAULT, keyName);
|
keyPair = client.getKeyPairServices().createKeyPairInRegion(null, keyName);
|
||||||
assertNotNull(keyPair);
|
assertNotNull(keyPair);
|
||||||
assertNotNull(keyPair.getKeyMaterial());
|
assertNotNull(keyPair.getKeyMaterial());
|
||||||
assertNotNull(keyPair.getKeyFingerprint());
|
assertNotNull(keyPair.getKeyFingerprint());
|
||||||
|
@ -190,7 +200,7 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
try {
|
try {
|
||||||
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
||||||
Reservation reservation = client.getInstanceServices().runInstancesInRegion(
|
Reservation reservation = client.getInstanceServices().runInstancesInRegion(
|
||||||
Region.DEFAULT, null, // allow ec2 to chose an availability zone
|
null, null, // allow ec2 to chose an availability zone
|
||||||
imageId, 1, // minimum instances
|
imageId, 1, // minimum instances
|
||||||
1, // maximum instances
|
1, // maximum instances
|
||||||
withKeyName(keyPair.getKeyName())// key I created above
|
withKeyName(keyPair.getKeyName())// key I created above
|
||||||
|
@ -412,39 +422,39 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUserDataForInstanceInRegion() {
|
private void setUserDataForInstanceInRegion() {
|
||||||
client.getInstanceServices().setUserDataForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setUserDataForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), "test".getBytes());
|
ebsInstance.getId(), "test".getBytes());
|
||||||
assertEquals("test", client.getInstanceServices().getUserDataForInstanceInRegion(
|
assertEquals("test", client.getInstanceServices().getUserDataForInstanceInRegion(
|
||||||
Region.DEFAULT, ebsInstance.getId()));
|
null, ebsInstance.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRamdiskForInstanceInRegion() {
|
private void setRamdiskForInstanceInRegion() {
|
||||||
String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(Region.DEFAULT,
|
String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null,
|
||||||
ebsInstance.getId());
|
ebsInstance.getId());
|
||||||
client.getInstanceServices().setRamdiskForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setRamdiskForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), ramdisk);
|
ebsInstance.getId(), ramdisk);
|
||||||
assertEquals(ramdisk, client.getInstanceServices().getRamdiskForInstanceInRegion(
|
assertEquals(ramdisk, client.getInstanceServices().getRamdiskForInstanceInRegion(
|
||||||
Region.DEFAULT, ebsInstance.getId()));
|
null, ebsInstance.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setKernelForInstanceInRegion() {
|
private void setKernelForInstanceInRegion() {
|
||||||
String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(Region.DEFAULT,
|
String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null,
|
||||||
ebsInstance.getId());
|
ebsInstance.getId());
|
||||||
client.getInstanceServices().setKernelForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setKernelForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), oldKernel);
|
ebsInstance.getId(), oldKernel);
|
||||||
assertEquals(oldKernel, client.getInstanceServices().getKernelForInstanceInRegion(
|
assertEquals(oldKernel, client.getInstanceServices().getKernelForInstanceInRegion(
|
||||||
Region.DEFAULT, ebsInstance.getId()));
|
null, ebsInstance.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInstanceTypeForInstanceInRegion() {
|
private void setInstanceTypeForInstanceInRegion() {
|
||||||
client.getInstanceServices().setInstanceTypeForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setInstanceTypeForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), InstanceType.C1_MEDIUM);
|
ebsInstance.getId(), InstanceType.C1_MEDIUM);
|
||||||
assertEquals(InstanceType.C1_MEDIUM, client.getInstanceServices()
|
assertEquals(InstanceType.C1_MEDIUM, client.getInstanceServices()
|
||||||
.getInstanceTypeForInstanceInRegion(Region.DEFAULT, ebsInstance.getId()));
|
.getInstanceTypeForInstanceInRegion(null, ebsInstance.getId()));
|
||||||
client.getInstanceServices().setInstanceTypeForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setInstanceTypeForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), InstanceType.M1_SMALL);
|
ebsInstance.getId(), InstanceType.M1_SMALL);
|
||||||
assertEquals(InstanceType.M1_SMALL, client.getInstanceServices()
|
assertEquals(InstanceType.M1_SMALL, client.getInstanceServices()
|
||||||
.getInstanceTypeForInstanceInRegion(Region.DEFAULT, ebsInstance.getId()));
|
.getInstanceTypeForInstanceInRegion(null, ebsInstance.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBlockDeviceMappingForInstanceInRegion() {
|
private void setBlockDeviceMappingForInstanceInRegion() {
|
||||||
|
@ -454,11 +464,11 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
blockDeviceMapping.addEbsBlockDevice
|
blockDeviceMapping.addEbsBlockDevice
|
||||||
("/dev/sda1", new RunningInstance.EbsBlockDevice(volumeId, false));
|
("/dev/sda1", new RunningInstance.EbsBlockDevice(volumeId, false));
|
||||||
try {
|
try {
|
||||||
client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(Region.DEFAULT,
|
client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null,
|
||||||
ebsInstance.getId(), blockDeviceMapping);
|
ebsInstance.getId(), blockDeviceMapping);
|
||||||
|
|
||||||
Map<String, RunningInstance.EbsBlockDevice> devices = client
|
Map<String, RunningInstance.EbsBlockDevice> devices = client
|
||||||
.getInstanceServices().getBlockDeviceMappingForInstanceInRegion(Region.DEFAULT,
|
.getInstanceServices().getBlockDeviceMappingForInstanceInRegion(null,
|
||||||
ebsInstance.getId());
|
ebsInstance.getId());
|
||||||
assertEquals(devices.size(), 1);
|
assertEquals(devices.size(), 1);
|
||||||
String deviceName = Iterables.getOnlyElement(devices.keySet());
|
String deviceName = Iterables.getOnlyElement(devices.keySet());
|
||||||
|
@ -480,16 +490,16 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
||||||
Region.DEFAULT, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.STOP);
|
null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.STOP);
|
||||||
|
|
||||||
assertEquals(InstanceInitiatedShutdownBehavior.STOP, client.getInstanceServices()
|
assertEquals(InstanceInitiatedShutdownBehavior.STOP, client.getInstanceServices()
|
||||||
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(Region.DEFAULT,
|
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null,
|
||||||
ebsInstance.getId()));
|
ebsInstance.getId()));
|
||||||
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(
|
||||||
Region.DEFAULT, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.TERMINATE);
|
null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.TERMINATE);
|
||||||
|
|
||||||
assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices()
|
assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices()
|
||||||
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(Region.DEFAULT,
|
.getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null,
|
||||||
ebsInstance.getId()));
|
ebsInstance.getId()));
|
||||||
System.out.println("OK: setInstanceInitiatedShutdownBehaviorForInstanceInRegion");
|
System.out.println("OK: setInstanceInitiatedShutdownBehaviorForInstanceInRegion");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -618,7 +628,7 @@ public class EBSBootEC2ClientLiveTest {
|
||||||
}
|
}
|
||||||
if (securityGroupName != null) {
|
if (securityGroupName != null) {
|
||||||
try {
|
try {
|
||||||
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(null,
|
||||||
securityGroupName);
|
securityGroupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -26,13 +26,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.aws.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
|
import org.jclouds.aws.ec2.xml.BaseEC2HandlerTest;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -44,7 +43,7 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "compute.ImageParserTest")
|
@Test(groups = "unit", testName = "compute.ImageParserTest")
|
||||||
public class ImageParserTest extends BaseHandlerTest {
|
public class ImageParserTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
public void testParseAlesticCanonicalImage() {
|
public void testParseAlesticCanonicalImage() {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/alestic_canonical.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/alestic_canonical.xml");
|
||||||
|
@ -158,7 +157,7 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.reference.EC2Constants;
|
|
||||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||||
|
@ -52,18 +51,8 @@ public class EC2RestClientModuleTest {
|
||||||
new AbstractModule() {
|
new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindConstant().annotatedWith(
|
Jsr330.bindProperties(this.binder(), new EC2PropertiesBuilder("user", "key")
|
||||||
Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to("user");
|
.build());
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(EC2Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_EC2_ENDPOINT))
|
|
||||||
.to("http://localhost");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(EC2Constants.PROPERTY_AWS_EXPIREINTERVAL)).to(30);
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to("1");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS))
|
|
||||||
.to("1");
|
|
||||||
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,22 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.executableBy;
|
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.executableBy;
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||||
|
@ -43,25 +34,13 @@ import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.ImageIdHandler;
|
import org.jclouds.aws.ec2.xml.ImageIdHandler;
|
||||||
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
||||||
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,14 +49,14 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.AMIAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.AMIAsyncClientTest")
|
||||||
public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
||||||
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
||||||
.getClass());
|
.getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "name", "instanceId");
|
"name", "instanceId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -96,9 +75,9 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
||||||
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
||||||
.getClass());
|
.getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "name", "instanceId", new CreateImageOptions().withDescription(
|
"name", "instanceId", new CreateImageOptions().withDescription("description")
|
||||||
"description").noReboot());
|
.noReboot());
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -118,7 +97,7 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
||||||
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT);
|
(Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -140,8 +119,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
||||||
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, executableBy("me").ownedBy("fred", "nancy").imageIds("1", "2"));
|
executableBy("me").ownedBy("fred", "nancy").imageIds("1", "2"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -160,8 +139,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("deregisterImageInRegion", Region.class,
|
Method method = AMIAsyncClient.class.getMethod("deregisterImageInRegion", Region.class,
|
||||||
String.class);
|
String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageId");
|
"imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -180,8 +159,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
||||||
Region.class, String.class, String.class, Array.newInstance(
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
RegisterImageOptions.class, 0).getClass());
|
RegisterImageOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "name", "pathToManifest");
|
"name", "pathToManifest");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -200,9 +179,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
||||||
Region.class, String.class, String.class, Array.newInstance(
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
RegisterImageOptions.class, 0).getClass());
|
RegisterImageOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "name", "pathToManifest", new RegisterImageOptions()
|
"name", "pathToManifest", new RegisterImageOptions().withDescription("description"));
|
||||||
.withDescription("description"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -223,8 +201,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion",
|
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion",
|
||||||
Region.class, String.class, String.class, Array.newInstance(
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageName", "snapshotId");
|
"imageName", "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -244,11 +222,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion",
|
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion",
|
||||||
Region.class, String.class, String.class, Array.newInstance(
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions()
|
"imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription(
|
||||||
.withDescription("description").addBlockDeviceFromSnapshot("/dev/device",
|
"description").addBlockDeviceFromSnapshot("/dev/device", null, "snapshot")
|
||||||
null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock",
|
.addNewBlockDevice("/dev/newdevice", "newblock", 100));
|
||||||
100));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -268,8 +245,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("getProductCodesForImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("getProductCodesForImageInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageId");
|
"imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -288,8 +265,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageId");
|
"imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -308,8 +285,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageId");
|
"imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -328,8 +305,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion",
|
||||||
Region.class, Iterable.class, Iterable.class, String.class);
|
Region.class, Iterable.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -353,8 +330,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion",
|
||||||
Region.class, Iterable.class, Iterable.class, String.class);
|
Region.class, Iterable.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -373,8 +350,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "imageId");
|
"imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -392,8 +369,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("addProductCodesToImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("addProductCodesToImageInRegion",
|
||||||
Region.class, Iterable.class, String.class);
|
Region.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, ImmutableList.of("code1", "code2"), "imageId");
|
ImmutableList.of("code1", "code2"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -413,8 +390,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("removeProductCodesFromImageInRegion",
|
Method method = AMIAsyncClient.class.getMethod("removeProductCodesFromImageInRegion",
|
||||||
Region.class, Iterable.class, String.class);
|
Region.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, ImmutableList.of("code1", "code2"), "imageId");
|
ImmutableList.of("code1", "code2"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -430,63 +407,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<AMIAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private FormSigner filter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeTest
|
|
||||||
protected void setupFactory() {
|
|
||||||
super.setupFactory();
|
|
||||||
this.filter = injector.getInstance(FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class AMIClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() {
|
public void testDescribeImages() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImagesInRegion(region));
|
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImagesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
@ -95,11 +95,11 @@ public class AMIClientLiveTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRegisterImageFromManifest() {
|
public void testRegisterImageFromManifest() {
|
||||||
String imageRegisteredId = client.registerImageFromManifestInRegion(Region.DEFAULT,
|
String imageRegisteredId = client.registerImageFromManifestInRegion(null,
|
||||||
"jcloudstest1", DEFAULT_MANIFEST);
|
"jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(
|
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
Region.DEFAULT, imageIds(imageRegisteredId)));
|
null, imageIds(imageRegisteredId)));
|
||||||
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
||||||
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
||||||
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
||||||
|
@ -110,10 +110,10 @@ public class AMIClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRegisterImageFromManifestOptions() {
|
public void testRegisterImageFromManifestOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(
|
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(
|
||||||
Region.DEFAULT, "jcloudstest2", DEFAULT_MANIFEST, withDescription("adrian"));
|
null, "jcloudstest2", DEFAULT_MANIFEST, withDescription("adrian"));
|
||||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client
|
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client
|
||||||
.describeImagesInRegion(Region.DEFAULT, imageIds(imageRegisteredWithOptionsId)));
|
.describeImagesInRegion(null, imageIds(imageRegisteredWithOptionsId)));
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
||||||
|
@ -126,11 +126,11 @@ public class AMIClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// awaiting EBS functionality to be added to jclouds
|
// awaiting EBS functionality to be added to jclouds
|
||||||
public void testRegisterImageBackedByEBS() {
|
public void testRegisterImageBackedByEBS() {
|
||||||
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(Region.DEFAULT,
|
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null,
|
||||||
"jcloudstest1", DEFAULT_MANIFEST);
|
"jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegistered = Iterables.getOnlyElement(client.describeImagesInRegion(
|
Image imageRegistered = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
Region.DEFAULT, imageIds(imageRegisteredId)));
|
null, imageIds(imageRegisteredId)));
|
||||||
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
||||||
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
||||||
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
||||||
|
@ -141,11 +141,11 @@ public class AMIClientLiveTest {
|
||||||
// awaiting EBS functionality to be added to jclouds
|
// awaiting EBS functionality to be added to jclouds
|
||||||
public void testRegisterImageBackedByEBSOptions() {
|
public void testRegisterImageBackedByEBSOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(
|
String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(
|
||||||
Region.DEFAULT, "jcloudstest2", DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2",
|
null, "jcloudstest2", DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2",
|
||||||
"myvirtual", 1).withDescription("adrian"));
|
"myvirtual", 1).withDescription("adrian"));
|
||||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(
|
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
Region.DEFAULT, imageIds(imageRegisteredWithOptionsId)));
|
null, imageIds(imageRegisteredWithOptionsId)));
|
||||||
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
||||||
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
||||||
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
||||||
|
@ -158,48 +158,48 @@ public class AMIClientLiveTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testCreateImage() {
|
public void testCreateImage() {
|
||||||
// TODO client.createImageInRegion(Region.DEFAULT, name, instanceId, options);
|
// TODO client.createImageInRegion(null, name, instanceId, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddProductCodesToImage() {
|
public void testAddProductCodesToImage() {
|
||||||
// TODO client.addProductCodesToImageInRegion(Region.DEFAULT, productCodes, imageId);
|
// TODO client.addProductCodesToImageInRegion(null, productCodes, imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddLaunchPermissionsToImage() {
|
public void testAddLaunchPermissionsToImage() {
|
||||||
// TODO client.addLaunchPermissionsToImageInRegion(Region.DEFAULT, userIds, userGroups,
|
// TODO client.addLaunchPermissionsToImageInRegion(null, userIds, userGroups,
|
||||||
// imageId);
|
// imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRemoveLaunchPermissionsFromImage() {
|
public void testRemoveLaunchPermissionsFromImage() {
|
||||||
// TODO client.removeLaunchPermissionsFromImageInRegion(Region.DEFAULT, userIds, userGroups,
|
// TODO client.removeLaunchPermissionsFromImageInRegion(null, userIds, userGroups,
|
||||||
// imageId);
|
// imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testResetLaunchPermissionsOnImage() {
|
public void testResetLaunchPermissionsOnImage() {
|
||||||
// TODO client.resetLaunchPermissionsOnImageInRegion(Region.DEFAULT, imageId);
|
// TODO client.resetLaunchPermissionsOnImageInRegion(null, imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLaunchPermissionForImage() {
|
public void testGetLaunchPermissionForImage() {
|
||||||
System.out.println(client.getLaunchPermissionForImageInRegion(Region.DEFAULT, imageId));
|
System.out.println(client.getLaunchPermissionForImageInRegion(null, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetProductCodesForImage() {
|
public void testGetProductCodesForImage() {
|
||||||
System.out.println(client.getProductCodesForImageInRegion(Region.DEFAULT, imageId));
|
System.out.println(client.getProductCodesForImageInRegion(null, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// awaiting ebs support
|
// awaiting ebs support
|
||||||
public void testGetBlockDeviceMappingsForImage() {
|
public void testGetBlockDeviceMappingsForImage() {
|
||||||
System.out.println(client.getBlockDeviceMappingsForImageInRegion(Region.DEFAULT, imageId));
|
System.out.println(client.getBlockDeviceMappingsForImageInRegion(null, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
public void deregisterImages() {
|
public void deregisterImages() {
|
||||||
for (String imageId : imagesToDeregister)
|
for (String imageId : imagesToDeregister)
|
||||||
client.deregisterImageInRegion(Region.DEFAULT, imageId);
|
client.deregisterImageInRegion(null, imageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,44 +18,24 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones;
|
import static org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeRegionsOptions.Builder.regions;
|
import static org.jclouds.aws.ec2.options.DescribeRegionsOptions.Builder.regions;
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
|
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeRegionsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeRegionsResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +45,7 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.AvailabilityZoneAndRegionAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.AvailabilityZoneAndRegionAsyncClientTest")
|
||||||
public class AvailabilityZoneAndRegionAsyncClientTest extends
|
public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
RestClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
||||||
|
|
||||||
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException,
|
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
|
@ -149,54 +129,10 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<AvailabilityZoneAndRegionAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class AvailabilityZoneAndRegionClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeAvailabilityZones() {
|
public void testDescribeAvailabilityZones() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
SortedSet<AvailabilityZoneInfo> allResults = Sets.newTreeSet(client
|
SortedSet<AvailabilityZoneInfo> allResults = Sets.newTreeSet(client
|
||||||
.describeAvailabilityZonesInRegion(region));
|
.describeAvailabilityZonesInRegion(region));
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 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.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
|
import org.jclouds.date.TimeStamp;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
|
import org.jclouds.rest.RestClientTest;
|
||||||
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
|
|
||||||
|
protected FormSigner filter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkFilters(GeneratedHttpRequest<T> httpMethod) {
|
||||||
|
assertEquals(httpMethod.getFilters().size(), 1);
|
||||||
|
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseEC2AsyncClientTest() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeTest
|
||||||
|
protected void setupFactory() {
|
||||||
|
super.setupFactory();
|
||||||
|
this.filter = injector.getInstance(FormSigner.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new AbstractModule() {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder("user", "key")
|
||||||
|
.build(), "properties"));
|
||||||
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
|
bind(Region.class).annotatedWith(EC2.class).toInstance(Region.US_EAST_1);
|
||||||
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
|
public Logger getLogger(String category) {
|
||||||
|
return Logger.NULL;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Provides
|
||||||
|
@TimeStamp
|
||||||
|
String provide() {
|
||||||
|
return "2009-11-08T15:54:08.897Z";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@EC2
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.EU_WEST_1, URI
|
||||||
|
.create("https://ec2.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI
|
||||||
|
.create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
|
||||||
|
.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<AvailabilityZone, Region> provideAvailabilityZoneRegionMap() {
|
||||||
|
return ImmutableMap.<AvailabilityZone, Region> of(AvailabilityZone.US_EAST_1A,
|
||||||
|
Region.US_EAST_1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,23 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.aws.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy;
|
import static org.jclouds.aws.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy;
|
||||||
import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.fromInstance;
|
import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.fromInstance;
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
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;
|
||||||
|
@ -46,24 +37,13 @@ import org.jclouds.aws.ec2.xml.DescribeSnapshotsResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeVolumesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeVolumesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
||||||
import org.jclouds.aws.ec2.xml.SnapshotHandler;
|
import org.jclouds.aws.ec2.xml.SnapshotHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,7 +52,8 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.ElasticBlockStoreAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.ElasticBlockStoreAsyncClientTest")
|
||||||
public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBlockStoreAsyncClient> {
|
public class ElasticBlockStoreAsyncClientTest extends
|
||||||
|
BaseEC2AsyncClientTest<ElasticBlockStoreAsyncClient> {
|
||||||
|
|
||||||
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
||||||
|
@ -80,9 +61,9 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, AvailabilityZone.US_EAST_1A, 20);
|
method, AvailabilityZone.US_EAST_1A, 20);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 74\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 74\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&Size=20");
|
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&Size=20");
|
||||||
|
|
||||||
|
@ -100,9 +81,9 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, AvailabilityZone.US_EAST_1A, "snapshotId");
|
method, AvailabilityZone.US_EAST_1A, "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 88\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 88\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId");
|
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId");
|
||||||
|
|
||||||
|
@ -121,9 +102,9 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 96\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 96\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId&Size=15");
|
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId&Size=15");
|
||||||
|
|
||||||
|
@ -138,7 +119,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "id");
|
method, null, "id");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -156,7 +137,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT);
|
method, (Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -175,7 +156,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "1", "2");
|
method, null, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -194,7 +175,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion",
|
||||||
Region.class, String.class, String.class, String.class);
|
Region.class, String.class, String.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "id", "instanceId", "/device");
|
method, null, "id", "instanceId", "/device");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -214,7 +195,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Region.class, String.class, boolean.class, Array.newInstance(
|
Region.class, String.class, boolean.class, Array.newInstance(
|
||||||
DetachVolumeOptions.class, 0).getClass());
|
DetachVolumeOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "id", false);
|
method, null, "id", false);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -234,9 +215,8 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion",
|
||||||
Region.class, String.class, boolean.class, Array.newInstance(
|
Region.class, String.class, boolean.class, Array.newInstance(
|
||||||
DetachVolumeOptions.class, 0).getClass());
|
DetachVolumeOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
.createRequest(method, Region.DEFAULT, "id", true, fromInstance("instanceId")
|
method, null, "id", true, fromInstance("instanceId").fromDevice("/device"));
|
||||||
.fromDevice("/device"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -257,7 +237,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Region.class, String.class, Array.newInstance(CreateSnapshotOptions.class, 0)
|
Region.class, String.class, Array.newInstance(CreateSnapshotOptions.class, 0)
|
||||||
.getClass());
|
.getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "volumeId");
|
method, null, "volumeId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -277,7 +257,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Region.class, String.class, Array.newInstance(CreateSnapshotOptions.class, 0)
|
Region.class, String.class, Array.newInstance(CreateSnapshotOptions.class, 0)
|
||||||
.getClass());
|
.getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "volumeId", CreateSnapshotOptions.Builder
|
method, null, "volumeId", CreateSnapshotOptions.Builder
|
||||||
.withDescription("description"));
|
.withDescription("description"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
|
@ -297,7 +277,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion",
|
||||||
Region.class, Array.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
Region.class, Array.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT);
|
method, (Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -316,8 +296,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion",
|
||||||
Region.class, Array.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
Region.class, Array.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, ownedBy("o1", "o2").restorableBy("r1", "r2").snapshotIds(
|
method, null, ownedBy("o1", "o2").restorableBy("r1", "r2").snapshotIds("s1", "s2"));
|
||||||
"s1", "s2"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -338,7 +317,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
||||||
"getCreateVolumePermissionForSnapshotInRegion", Region.class, String.class);
|
"getCreateVolumePermissionForSnapshotInRegion", Region.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "snapshotId");
|
method, null, "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -360,8 +339,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
"addCreateVolumePermissionsToSnapshotInRegion", Region.class, Iterable.class,
|
"addCreateVolumePermissionsToSnapshotInRegion", Region.class, Iterable.class,
|
||||||
Iterable.class, String.class);
|
Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"),
|
method, null, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "snapshotId");
|
||||||
"snapshotId");
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -383,8 +361,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
"removeCreateVolumePermissionsFromSnapshotInRegion", Region.class, Iterable.class,
|
"removeCreateVolumePermissionsFromSnapshotInRegion", Region.class, Iterable.class,
|
||||||
Iterable.class, String.class);
|
Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"),
|
method, null, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "snapshotId");
|
||||||
"snapshotId");
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -404,7 +381,7 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
||||||
"resetCreateVolumePermissionsOnSnapshotInRegion", Region.class, String.class);
|
"resetCreateVolumePermissionsOnSnapshotInRegion", Region.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, "snapshotId");
|
method, null, "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -419,60 +396,10 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI
|
|
||||||
.create("https://ec2.amazonaws.com"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<AvailabilityZone, Region> provideAvailabilityZoneRegionMap() {
|
|
||||||
return ImmutableMap.<AvailabilityZone, Region> of(AvailabilityZone.US_EAST_1A,
|
|
||||||
Region.DEFAULT);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeVolumes() {
|
void testDescribeVolumes() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
@ -96,7 +96,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
this.volumeId = expected.getId();
|
this.volumeId = expected.getId();
|
||||||
|
|
||||||
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(Region.DEFAULT,
|
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null,
|
||||||
expected.getId()));
|
expected.getId()));
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals(result.size(), 1);
|
assertEquals(result.size(), 1);
|
||||||
|
@ -106,7 +106,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
|
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
|
||||||
void testCreateSnapshotInRegion() {
|
void testCreateSnapshotInRegion() {
|
||||||
Snapshot snapshot = client.createSnapshotInRegion(Region.DEFAULT, volumeId);
|
Snapshot snapshot = client.createSnapshotInRegion(null, volumeId);
|
||||||
Predicate<Snapshot> snapshotted = new RetryablePredicate<Snapshot>(new SnapshotCompleted(
|
Predicate<Snapshot> snapshotted = new RetryablePredicate<Snapshot>(new SnapshotCompleted(
|
||||||
client), 600, 10, TimeUnit.SECONDS);
|
client), 600, 10, TimeUnit.SECONDS);
|
||||||
assert snapshotted.apply(snapshot);
|
assert snapshotted.apply(snapshot);
|
||||||
|
@ -171,7 +171,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeSnapshots() {
|
void testDescribeSnapshots() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
|
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
@ -187,21 +187,21 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddCreateVolumePermissionsToSnapshot() {
|
public void testAddCreateVolumePermissionsToSnapshot() {
|
||||||
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(Region.DEFAULT, userIds,
|
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(null, userIds,
|
||||||
// userGroups,
|
// userGroups,
|
||||||
// snapshotId);
|
// snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRemoveCreateVolumePermissionsFromSnapshot() {
|
public void testRemoveCreateVolumePermissionsFromSnapshot() {
|
||||||
// TODO client.removeCreateVolumePermissionsFromSnapshotInRegion(Region.DEFAULT, userIds,
|
// TODO client.removeCreateVolumePermissionsFromSnapshotInRegion(null, userIds,
|
||||||
// userGroups,
|
// userGroups,
|
||||||
// snapshotId);
|
// snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testResetCreateVolumePermissionsOnSnapshot() {
|
public void testResetCreateVolumePermissionsOnSnapshot() {
|
||||||
// TODO client.resetCreateVolumePermissionsOnSnapshotInRegion(Region.DEFAULT, snapshotId);
|
// TODO client.resetCreateVolumePermissionsOnSnapshotInRegion(null, snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
|
@ -212,8 +212,8 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testDeleteVolumeInRegion() {
|
void testDeleteVolumeInRegion() {
|
||||||
client.deleteVolumeInRegion(Region.DEFAULT, volumeId);
|
client.deleteVolumeInRegion(null, volumeId);
|
||||||
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(Region.DEFAULT,
|
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null,
|
||||||
volumeId));
|
volumeId));
|
||||||
assertEquals(result.size(), 1);
|
assertEquals(result.size(), 1);
|
||||||
Volume volume = result.iterator().next();
|
Volume volume = result.iterator().next();
|
||||||
|
|
|
@ -18,41 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,14 +40,15 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.ElasticIPAddressAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.ElasticIPAddressAsyncClientTest")
|
||||||
public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAddressAsyncClient> {
|
public class ElasticIPAddressAsyncClientTest extends
|
||||||
|
BaseEC2AsyncClientTest<ElasticIPAddressAsyncClient> {
|
||||||
|
|
||||||
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException,
|
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion",
|
||||||
Region.class, InetAddress.class);
|
Region.class, InetAddress.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, null, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -87,7 +67,7 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion",
|
||||||
Region.class, InetAddress.class, String.class);
|
Region.class, InetAddress.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), "me");
|
method, null, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), "me");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -106,7 +86,7 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion",
|
||||||
Region.class, InetAddress.class);
|
Region.class, InetAddress.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, null, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -124,7 +104,7 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion",
|
||||||
Region.class, Array.newInstance(InetAddress.class, 0).getClass());
|
Region.class, Array.newInstance(InetAddress.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, null, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -143,7 +123,7 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion",
|
||||||
Region.class);
|
Region.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, Region.DEFAULT);
|
method, (Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -157,54 +137,10 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ElasticIPAddressClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeAddresses() {
|
void testDescribeAddresses() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client
|
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client
|
||||||
.describeAddressesInRegion(region));
|
.describeAddressesInRegion(region));
|
||||||
|
|
|
@ -18,21 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceType;
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
|
@ -48,24 +38,12 @@ import org.jclouds.aws.ec2.xml.InstanceTypeHandler;
|
||||||
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.StringValueHandler;
|
import org.jclouds.aws.ec2.xml.StringValueHandler;
|
||||||
import org.jclouds.aws.ec2.xml.UnencodeStringValueHandler;
|
import org.jclouds.aws.ec2.xml.UnencodeStringValueHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,12 +52,12 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.InstanceAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.InstanceAsyncClientTest")
|
||||||
public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient> {
|
public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyncClient> {
|
||||||
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT);
|
(Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -97,8 +75,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "2");
|
"1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -117,8 +95,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("terminateInstancesInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("terminateInstancesInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "2");
|
"1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -137,8 +115,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", Region.class,
|
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", Region.class,
|
||||||
AvailabilityZone.class, String.class, int.class, int.class, Array.newInstance(
|
AvailabilityZone.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, null,
|
||||||
Region.DEFAULT, null, "ami-voo", 1, 1);
|
null, "ami-voo", 1, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -181,8 +159,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
public void testStopInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testStopInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("stopInstancesInRegion", Region.class,
|
Method method = InstanceAsyncClient.class.getMethod("stopInstancesInRegion", Region.class,
|
||||||
boolean.class, Array.newInstance(String.class, 0).getClass());
|
boolean.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, true, "1", "2");
|
true, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -200,8 +178,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
public void testRebootInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRebootInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", Region.class,
|
Method method = InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", Region.class,
|
||||||
Array.newInstance(String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "2");
|
"1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -219,8 +197,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
public void testStartInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testStartInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("startInstancesInRegion", Region.class,
|
Method method = InstanceAsyncClient.class.getMethod("startInstancesInRegion", Region.class,
|
||||||
Array.newInstance(String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "2");
|
"1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -239,8 +217,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -259,8 +237,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -279,8 +257,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -299,8 +277,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod(
|
Method method = InstanceAsyncClient.class.getMethod(
|
||||||
"isApiTerminationDisabledForInstanceInRegion", Region.class, String.class);
|
"isApiTerminationDisabledForInstanceInRegion", Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -319,8 +297,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -339,8 +317,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -360,8 +338,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
Method method = InstanceAsyncClient.class.getMethod(
|
Method method = InstanceAsyncClient.class.getMethod(
|
||||||
"getInstanceInitiatedShutdownBehaviorForInstanceInRegion", Region.class,
|
"getInstanceInitiatedShutdownBehaviorForInstanceInRegion", Region.class,
|
||||||
String.class);
|
String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -381,8 +359,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod(
|
Method method = InstanceAsyncClient.class.getMethod(
|
||||||
"getBlockDeviceMappingForInstanceInRegion", Region.class, String.class);
|
"getBlockDeviceMappingForInstanceInRegion", Region.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1");
|
"1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -401,8 +379,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion",
|
||||||
Region.class, String.class, Array.newInstance(byte.class, 0).getClass());
|
Region.class, String.class, Array.newInstance(byte.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "test".getBytes());
|
"1", "test".getBytes());
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -426,8 +404,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion",
|
||||||
Region.class, String.class, String.class);
|
Region.class, String.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "test");
|
"1", "test");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -445,8 +423,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion",
|
||||||
Region.class, String.class, String.class);
|
Region.class, String.class, String.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "test");
|
"1", "test");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -465,8 +443,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
Method method = InstanceAsyncClient.class.getMethod(
|
Method method = InstanceAsyncClient.class.getMethod(
|
||||||
"setApiTerminationDisabledForInstanceInRegion", Region.class, String.class,
|
"setApiTerminationDisabledForInstanceInRegion", Region.class, String.class,
|
||||||
boolean.class);
|
boolean.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", true);
|
"1", true);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -486,8 +464,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion",
|
Method method = InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion",
|
||||||
Region.class, String.class, InstanceType.class);
|
Region.class, String.class, InstanceType.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", InstanceType.C1_MEDIUM);
|
"1", InstanceType.C1_MEDIUM);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -508,8 +486,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
Method method = InstanceAsyncClient.class.getMethod(
|
Method method = InstanceAsyncClient.class.getMethod(
|
||||||
"setInstanceInitiatedShutdownBehaviorForInstanceInRegion", Region.class,
|
"setInstanceInitiatedShutdownBehaviorForInstanceInRegion", Region.class,
|
||||||
String.class, InstanceInitiatedShutdownBehavior.class);
|
String.class, InstanceInitiatedShutdownBehavior.class);
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", InstanceInitiatedShutdownBehavior.TERMINATE);
|
"1", InstanceInitiatedShutdownBehavior.TERMINATE);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -534,8 +512,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
|
BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
|
||||||
blockDeviceMapping.addEbsBlockDevice("/dev/sda1", new RunningInstance.EbsBlockDevice(
|
blockDeviceMapping.addEbsBlockDevice("/dev/sda1", new RunningInstance.EbsBlockDevice(
|
||||||
"vol-test1", true));
|
"vol-test1", true));
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", blockDeviceMapping);
|
"1", blockDeviceMapping);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -555,63 +533,9 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<InstanceAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private FormSigner filter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeTest
|
|
||||||
protected void setupFactory() {
|
|
||||||
super.setupFactory();
|
|
||||||
this.filter = injector.getInstance(FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class InstanceClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeInstances() {
|
void testDescribeInstances() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
Set<Reservation> allResults = client.describeInstancesInRegion(region);
|
Set<Reservation> allResults = client.describeInstancesInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
|
|
@ -18,39 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,13 +38,13 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.KeyPairAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.KeyPairAsyncClientTest")
|
||||||
public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncClient> {
|
||||||
|
|
||||||
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", Region.class,
|
Method method = KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", Region.class,
|
||||||
String.class);
|
String.class);
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "mykey");
|
"mykey");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -83,7 +62,7 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
||||||
Array.newInstance(String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT);
|
(Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -101,8 +80,8 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
||||||
Array.newInstance(String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method, null,
|
||||||
Region.DEFAULT, "1", "2");
|
"1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -117,54 +96,10 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<KeyPairAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class KeyPairClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeKeyPairs() {
|
void testDescribeKeyPairs() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1)) {
|
Region.US_WEST_1)) {
|
||||||
|
|
||||||
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
||||||
|
@ -83,20 +83,20 @@ public class KeyPairClientLiveTest {
|
||||||
void testCreateKeyPair() {
|
void testCreateKeyPair() {
|
||||||
String keyName = PREFIX + "1";
|
String keyName = PREFIX + "1";
|
||||||
try {
|
try {
|
||||||
client.deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
client.deleteKeyPairInRegion(null, keyName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
client.deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
client.deleteKeyPairInRegion(null, keyName);
|
||||||
|
|
||||||
KeyPair result = client.createKeyPairInRegion(Region.DEFAULT, keyName);
|
KeyPair result = client.createKeyPairInRegion(null, keyName);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertNotNull(result.getKeyMaterial());
|
assertNotNull(result.getKeyMaterial());
|
||||||
assertNotNull(result.getKeyFingerprint());
|
assertNotNull(result.getKeyFingerprint());
|
||||||
assertEquals(result.getKeyName(), keyName);
|
assertEquals(result.getKeyName(), keyName);
|
||||||
|
|
||||||
SortedSet<KeyPair> twoResults = Sets.newTreeSet(client.describeKeyPairsInRegion(
|
SortedSet<KeyPair> twoResults = Sets.newTreeSet(client.describeKeyPairsInRegion(
|
||||||
Region.DEFAULT, keyName));
|
null, keyName));
|
||||||
assertNotNull(twoResults);
|
assertNotNull(twoResults);
|
||||||
assertEquals(twoResults.size(), 1);
|
assertEquals(twoResults.size(), 1);
|
||||||
KeyPair listPair = twoResults.iterator().next();
|
KeyPair listPair = twoResults.iterator().next();
|
||||||
|
|
|
@ -18,38 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,14 +37,14 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.MonitoringAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.MonitoringAsyncClientTest")
|
||||||
public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncClient> {
|
public class MonitoringAsyncClientTest extends BaseEC2AsyncClientTest<MonitoringAsyncClient> {
|
||||||
|
|
||||||
public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException,
|
public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = MonitoringAsyncClient.class.getMethod("unmonitorInstancesInRegion",
|
Method method = MonitoringAsyncClient.class.getMethod("unmonitorInstancesInRegion",
|
||||||
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "instance1", "instance2");
|
null, "instance1", "instance2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -84,7 +63,7 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
Method method = MonitoringAsyncClient.class.getMethod("monitorInstancesInRegion",
|
Method method = MonitoringAsyncClient.class.getMethod("monitorInstancesInRegion",
|
||||||
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "instance1", "instance2");
|
null, "instance1", "instance2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -99,54 +78,10 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<MonitoringAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<MonitoringAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<MonitoringAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<MonitoringAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<MonitoringAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -59,7 +58,7 @@ public class MonitoringClientLiveTest {
|
||||||
// TODO get instance
|
// TODO get instance
|
||||||
public void testMonitorInstances() {
|
public void testMonitorInstances() {
|
||||||
Map<String, MonitoringState> monitoringState = client.monitorInstancesInRegion(
|
Map<String, MonitoringState> monitoringState = client.monitorInstancesInRegion(
|
||||||
Region.DEFAULT, DEFAULT_INSTANCE);
|
null, DEFAULT_INSTANCE);
|
||||||
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ public class MonitoringClientLiveTest {
|
||||||
// TODO get instance
|
// TODO get instance
|
||||||
public void testUnmonitorInstances() {
|
public void testUnmonitorInstances() {
|
||||||
Map<String, MonitoringState> monitoringState = client.unmonitorInstancesInRegion(
|
Map<String, MonitoringState> monitoringState = client.unmonitorInstancesInRegion(
|
||||||
Region.DEFAULT, DEFAULT_INSTANCE);
|
null, DEFAULT_INSTANCE);
|
||||||
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,42 +18,21 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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 java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
|
||||||
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,14 +41,14 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.SecurityGroupAsyncClientTest")
|
@Test(groups = "unit", testName = "ec2.SecurityGroupAsyncClientTest")
|
||||||
public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAsyncClient> {
|
public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<SecurityGroupAsyncClient> {
|
||||||
|
|
||||||
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException,
|
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion",
|
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "name");
|
null, "name");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -89,7 +68,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion",
|
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion",
|
||||||
Region.class, String.class, String.class);
|
Region.class, String.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "name", "description");
|
null, "name", "description");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -109,7 +88,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT);
|
(Region) null);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -128,7 +107,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
||||||
Region.class, Array.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "1", "2");
|
null, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -149,7 +128,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
UserIdGroupPair.class);
|
UserIdGroupPair.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -171,7 +150,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
IpProtocol.class, int.class, int.class, String.class);
|
IpProtocol.class, int.class, int.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -193,7 +172,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
"revokeSecurityGroupIngressInRegion", Region.class, String.class,
|
"revokeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
UserIdGroupPair.class);
|
UserIdGroupPair.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -215,7 +194,7 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
"revokeSecurityGroupIngressInRegion", Region.class, String.class, IpProtocol.class,
|
"revokeSecurityGroupIngressInRegion", Region.class, String.class, IpProtocol.class,
|
||||||
int.class, int.class, String.class);
|
int.class, int.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -231,54 +210,10 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod) {
|
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), FormSigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>>() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
|
||||||
.build(), "properties"));
|
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
|
||||||
public Logger getLogger(String category) {
|
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@TimeStamp
|
|
||||||
String provide() {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<Region, URI> provideMap() {
|
|
||||||
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
|
||||||
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
|
||||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
|
||||||
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,7 @@ public class SecurityGroupClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribe() {
|
void testDescribe() {
|
||||||
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
for (Region region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1)) {
|
||||||
Region.US_WEST_1)) {
|
|
||||||
SortedSet<SecurityGroup> allResults = Sets.newTreeSet(client
|
SortedSet<SecurityGroup> allResults = Sets.newTreeSet(client
|
||||||
.describeSecurityGroupsInRegion(region));
|
.describeSecurityGroupsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
@ -90,13 +89,13 @@ public class SecurityGroupClientLiveTest {
|
||||||
String groupName = PREFIX + "1";
|
String groupName = PREFIX + "1";
|
||||||
String groupDescription = PREFIX + "1 description";
|
String groupDescription = PREFIX + "1 description";
|
||||||
try {
|
try {
|
||||||
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
client.deleteSecurityGroupInRegion(null, groupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
client.deleteSecurityGroupInRegion(null, groupName);
|
||||||
|
|
||||||
client.createSecurityGroupInRegion(Region.DEFAULT, groupName, groupDescription);
|
client.createSecurityGroupInRegion(null, groupName, groupDescription);
|
||||||
|
|
||||||
verifySecurityGroup(groupName, groupDescription);
|
verifySecurityGroup(groupName, groupDescription);
|
||||||
}
|
}
|
||||||
|
@ -107,25 +106,24 @@ public class SecurityGroupClientLiveTest {
|
||||||
String groupName = PREFIX + "ingress";
|
String groupName = PREFIX + "ingress";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
client.deleteSecurityGroupInRegion(null, groupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.createSecurityGroupInRegion(Region.DEFAULT, groupName, groupName);
|
client.createSecurityGroupInRegion(null, groupName, groupName);
|
||||||
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, groupName, IpProtocol.TCP, 80,
|
client.authorizeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80,
|
||||||
80, "0.0.0.0/0");
|
"0.0.0.0/0");
|
||||||
assertEventually(new GroupHasPermission(client, groupName, new IpPermission(80, 80, Sets
|
assertEventually(new GroupHasPermission(client, groupName, new IpPermission(80, 80, Sets
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
client.revokeSecurityGroupIngressInRegion(Region.DEFAULT, groupName, IpProtocol.TCP, 80, 80,
|
client.revokeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80,
|
||||||
"0.0.0.0/0");
|
"0.0.0.0/0");
|
||||||
assertEventually(new GroupHasNoPermissions(client, groupName));
|
assertEventually(new GroupHasNoPermissions(client, groupName));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifySecurityGroup(String groupName, String description) {
|
private void verifySecurityGroup(String groupName, String description) {
|
||||||
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, groupName);
|
||||||
groupName);
|
|
||||||
assertNotNull(oneResult);
|
assertNotNull(oneResult);
|
||||||
assertEquals(oneResult.size(), 1);
|
assertEquals(oneResult.size(), 1);
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
@ -140,38 +138,37 @@ public class SecurityGroupClientLiveTest {
|
||||||
String group2Name = PREFIX + "ingress2";
|
String group2Name = PREFIX + "ingress2";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.deleteSecurityGroupInRegion(Region.DEFAULT, group1Name);
|
client.deleteSecurityGroupInRegion(null, group1Name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
client.deleteSecurityGroupInRegion(Region.DEFAULT, group2Name);
|
client.deleteSecurityGroupInRegion(null, group2Name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.createSecurityGroupInRegion(Region.DEFAULT, group1Name, group1Name);
|
client.createSecurityGroupInRegion(null, group1Name, group1Name);
|
||||||
client.createSecurityGroupInRegion(Region.DEFAULT, group2Name, group2Name);
|
client.createSecurityGroupInRegion(null, group2Name, group2Name);
|
||||||
ensureGroupsExist(group1Name, group2Name);
|
ensureGroupsExist(group1Name, group2Name);
|
||||||
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, group1Name, IpProtocol.TCP, 80,
|
client.authorizeSecurityGroupIngressInRegion(null, group1Name, IpProtocol.TCP, 80, 80,
|
||||||
80, "0.0.0.0/0");
|
"0.0.0.0/0");
|
||||||
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
|
||||||
group1Name);
|
|
||||||
assertNotNull(oneResult);
|
assertNotNull(oneResult);
|
||||||
assertEquals(oneResult.size(), 1);
|
assertEquals(oneResult.size(), 1);
|
||||||
SecurityGroup group = oneResult.iterator().next();
|
SecurityGroup group = oneResult.iterator().next();
|
||||||
assertEquals(group.getName(), group1Name);
|
assertEquals(group.getName(), group1Name);
|
||||||
|
|
||||||
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, group2Name, new UserIdGroupPair(
|
client.authorizeSecurityGroupIngressInRegion(null, group2Name, new UserIdGroupPair(group
|
||||||
group.getOwnerId(), group1Name));
|
.getOwnerId(), group1Name));
|
||||||
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
client.revokeSecurityGroupIngressInRegion(Region.DEFAULT, group2Name, new UserIdGroupPair(
|
client.revokeSecurityGroupIngressInRegion(null, group2Name, new UserIdGroupPair(group
|
||||||
group.getOwnerId(), group1Name));
|
.getOwnerId(), group1Name));
|
||||||
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,8 +185,7 @@ public class SecurityGroupClientLiveTest {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group);
|
||||||
Region.DEFAULT, group);
|
|
||||||
assertNotNull(oneResult);
|
assertNotNull(oneResult);
|
||||||
assertEquals(oneResult.size(), 1);
|
assertEquals(oneResult.size(), 1);
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
@ -211,8 +207,7 @@ public class SecurityGroupClientLiveTest {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group);
|
||||||
group);
|
|
||||||
assertNotNull(oneResult);
|
assertNotNull(oneResult);
|
||||||
assertEquals(oneResult.size(), 1);
|
assertEquals(oneResult.size(), 1);
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
@ -224,8 +219,8 @@ public class SecurityGroupClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureGroupsExist(String group1Name, String group2Name) {
|
private void ensureGroupsExist(String group1Name, String group2Name) {
|
||||||
SortedSet<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
SortedSet<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(null, group1Name,
|
||||||
group1Name, group2Name);
|
group2Name);
|
||||||
assertNotNull(twoResults);
|
assertNotNull(twoResults);
|
||||||
assertEquals(twoResults.size(), 2);
|
assertEquals(twoResults.size(), 2);
|
||||||
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.xml;
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
import static org.easymock.EasyMock.expect;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.Attachment;
|
import org.jclouds.aws.ec2.domain.Attachment;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -37,13 +37,13 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.AttachmentHandlerTest")
|
@Test(groups = "unit", testName = "ec2.AttachmentHandlerTest")
|
||||||
public class AttachmentHandlerTest extends BaseHandlerTest {
|
public class AttachmentHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
DateService dateService = injector.getInstance(DateService.class);
|
DateService dateService = injector.getInstance(DateService.class);
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/attach.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/attach.xml");
|
||||||
|
|
||||||
Attachment expected = new Attachment(Region.DEFAULT, "vol-4d826724", "i-6058a509",
|
Attachment expected = new Attachment(defaultRegion, "vol-4d826724", "i-6058a509", "/dev/sdh",
|
||||||
"/dev/sdh", Attachment.Status.ATTACHING, dateService
|
Attachment.Status.ATTACHING, dateService
|
||||||
.iso8601DateParse("2008-05-07T11:51:50.000Z"));
|
.iso8601DateParse("2008-05-07T11:51:50.000Z"));
|
||||||
|
|
||||||
AttachmentHandler handler = injector.getInstance(AttachmentHandler.class);
|
AttachmentHandler handler = injector.getInstance(AttachmentHandler.class);
|
||||||
|
@ -55,7 +55,7 @@ public class AttachmentHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
|
expect(request.getArgs()).andReturn(new Object[] { null });
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 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.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class BaseEC2HandlerTest extends BaseHandlerTest {
|
||||||
|
protected Region defaultRegion = Region.US_EAST_1;
|
||||||
|
|
||||||
|
public BaseEC2HandlerTest() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
@Override
|
||||||
|
protected void setUpInjector() {
|
||||||
|
injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@EC2
|
||||||
|
Region provideDefaultRegion() {
|
||||||
|
return defaultRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<AvailabilityZone, Region> provideAvailabilityZoneRegionMap() {
|
||||||
|
return ImmutableMap.<AvailabilityZone, Region> of(AvailabilityZone.US_EAST_1A,
|
||||||
|
Region.US_EAST_1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
assert factory != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,27 +24,18 @@ import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
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.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.Volume;
|
import org.jclouds.aws.ec2.domain.Volume;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CreateVolumeResponseHandler}
|
* Tests behavior of {@code CreateVolumeResponseHandler}
|
||||||
|
@ -52,35 +43,13 @@ import com.google.inject.Provides;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.CreateVolumeResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.CreateVolumeResponseHandlerTest")
|
||||||
public class CreateVolumeResponseHandlerTest extends BaseHandlerTest {
|
public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
@BeforeTest
|
|
||||||
@Override
|
|
||||||
protected void setUpInjector() {
|
|
||||||
injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<AvailabilityZone, Region> provideAvailabilityZoneRegionMap() {
|
|
||||||
return ImmutableMap.<AvailabilityZone, Region> of(AvailabilityZone.US_EAST_1A,
|
|
||||||
Region.DEFAULT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
factory = injector.getInstance(ParseSax.Factory.class);
|
|
||||||
assert factory != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
DateService dateService = injector.getInstance(DateService.class);
|
DateService dateService = injector.getInstance(DateService.class);
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/created_volume.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/created_volume.xml");
|
||||||
|
|
||||||
Volume expected = new Volume(Region.DEFAULT, "vol-2a21e543", 1, null,
|
Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null,
|
||||||
AvailabilityZone.US_EAST_1A, Volume.Status.CREATING, dateService
|
AvailabilityZone.US_EAST_1A, Volume.Status.CREATING, dateService
|
||||||
.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets
|
.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets
|
||||||
.<Attachment> newLinkedHashSet());
|
.<Attachment> newLinkedHashSet());
|
||||||
|
@ -94,7 +63,7 @@ public class CreateVolumeResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,7 @@ import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -43,7 +41,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeAddressesResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeAddressesResponseHandlerTest")
|
||||||
public class DescribeAddressesResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeAddressesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() throws UnknownHostException {
|
public void testApplyInputStream() throws UnknownHostException {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_addresses.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_addresses.xml");
|
||||||
|
@ -54,14 +52,14 @@ public class DescribeAddressesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
Set<PublicIpInstanceIdPair> result = factory.create(handler).parse(is);
|
Set<PublicIpInstanceIdPair> result = factory.create(handler).parse(is);
|
||||||
|
|
||||||
assertEquals(result, ImmutableList.of(new PublicIpInstanceIdPair(Region.DEFAULT, InetAddress
|
assertEquals(result, ImmutableList.of(new PublicIpInstanceIdPair(defaultRegion, InetAddress
|
||||||
.getByName("67.202.55.255"), "i-f15ebb98"), new PublicIpInstanceIdPair(
|
.getByName("67.202.55.255"), "i-f15ebb98"), new PublicIpInstanceIdPair(
|
||||||
Region.DEFAULT, InetAddress.getByName("67.202.55.233"), null)));
|
defaultRegion, InetAddress.getByName("67.202.55.233"), null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,14 +27,12 @@ import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||||
import org.jclouds.aws.ec2.domain.Image.ImageState;
|
import org.jclouds.aws.ec2.domain.Image.ImageState;
|
||||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -48,13 +46,13 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeImagesResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeImagesResponseHandlerTest")
|
||||||
public class DescribeImagesResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeImagesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
public void testUNIX() {
|
public void testUNIX() {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_images.xml");
|
||||||
SortedSet<Image> contents = Sets.newTreeSet();
|
SortedSet<Image> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Image(Region.DEFAULT, Architecture.I386, null, null, "ami-be3adfd7",
|
contents.add(new Image(defaultRegion, Architecture.I386, null, null, "ami-be3adfd7",
|
||||||
"ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532",
|
"ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532",
|
||||||
ImageState.AVAILABLE, ImageType.MACHINE, false,
|
ImageState.AVAILABLE, ImageType.MACHINE, false,
|
||||||
Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c",
|
Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c",
|
||||||
|
@ -69,7 +67,7 @@ public class DescribeImagesResponseHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_windows.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_windows.xml");
|
||||||
SortedSet<Image> contents = Sets.newTreeSet();
|
SortedSet<Image> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Image(Region.DEFAULT, Architecture.X86_64, null, null, "ami-02eb086b",
|
contents.add(new Image(defaultRegion, Architecture.X86_64, null, null, "ami-02eb086b",
|
||||||
"aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml",
|
"aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml",
|
||||||
"771350841976", ImageState.AVAILABLE, ImageType.MACHINE, true, Sets
|
"771350841976", ImageState.AVAILABLE, ImageType.MACHINE, true, Sets
|
||||||
.<String> newHashSet("5771E9A6"), null, "windows", null,
|
.<String> newHashSet("5771E9A6"), null, "windows", null,
|
||||||
|
@ -84,7 +82,7 @@ public class DescribeImagesResponseHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_ebs.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_ebs.xml");
|
||||||
SortedSet<Image> contents = Sets.newTreeSet();
|
SortedSet<Image> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Image(Region.DEFAULT, Architecture.I386, "websrv_2009-12-10",
|
contents.add(new Image(defaultRegion, Architecture.I386, "websrv_2009-12-10",
|
||||||
"Web Server AMI", "ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852",
|
"Web Server AMI", "ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852",
|
||||||
ImageState.AVAILABLE, ImageType.MACHINE, true, Sets.<String> newHashSet(), null,
|
ImageState.AVAILABLE, ImageType.MACHINE, true, Sets.<String> newHashSet(), null,
|
||||||
"windows", null, RootDeviceType.EBS, "/dev/sda1", ImmutableMap
|
"windows", null, RootDeviceType.EBS, "/dev/sda1", ImmutableMap
|
||||||
|
@ -107,7 +105,7 @@ public class DescribeImagesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
|
expect(request.getArgs()).andReturn(new Object[] { null });
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
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.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
|
@ -38,7 +37,6 @@ import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.RunningInstance.EbsBlockDevice;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
|
@ -54,7 +52,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeInstancesResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeInstancesResponseHandlerTest")
|
||||||
public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
private DateService dateService;
|
private DateService dateService;
|
||||||
|
|
||||||
|
@ -71,8 +69,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_running.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_running.xml");
|
||||||
Set<Reservation> contents = Sets.newTreeSet();
|
Set<Reservation> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Reservation(Region.DEFAULT, ImmutableSet.of("adriancole.ec2ingress"),
|
contents.add(new Reservation(defaultRegion, ImmutableSet.of("adriancole.ec2ingress"),
|
||||||
ImmutableSet.of(new RunningInstance(Region.DEFAULT, "0",
|
ImmutableSet.of(new RunningInstance(defaultRegion, "0",
|
||||||
"ec2-174-129-81-68.compute-1.amazonaws.com", "ami-1fd73376", "i-0799056f",
|
"ec2-174-129-81-68.compute-1.amazonaws.com", "ami-1fd73376", "i-0799056f",
|
||||||
InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress
|
InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress
|
||||||
.getByName("174.129.81.68"), "aki-a71cf9ce", "adriancole.ec21",
|
.getByName("174.129.81.68"), "aki-a71cf9ce", "adriancole.ec21",
|
||||||
|
@ -93,8 +91,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances.xml");
|
||||||
Set<Reservation> contents = Sets.newTreeSet();
|
Set<Reservation> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Reservation(Region.DEFAULT, ImmutableSet.of("default"), ImmutableSet.of(
|
contents.add(new Reservation(defaultRegion, ImmutableSet.of("default"), ImmutableSet.of(
|
||||||
new RunningInstance(Region.DEFAULT, "23", "ec2-72-44-33-4.compute-1.amazonaws.com",
|
new RunningInstance(defaultRegion, "23", "ec2-72-44-33-4.compute-1.amazonaws.com",
|
||||||
"ami-6ea54007", "i-28a64341", InstanceState.RUNNING, InstanceType.M1_LARGE,
|
"ami-6ea54007", "i-28a64341", InstanceState.RUNNING, InstanceType.M1_LARGE,
|
||||||
(InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService
|
(InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService
|
||||||
.iso8601DateParse("2007-08-07T11:54:42.000Z"), false,
|
.iso8601DateParse("2007-08-07T11:54:42.000Z"), false,
|
||||||
|
@ -102,7 +100,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
ImmutableSet.of("774F4FF8"), "ari-badbad00", null, null, null,
|
ImmutableSet.of("774F4FF8"), "ari-badbad00", null, null, null,
|
||||||
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
||||||
.<String, EbsBlockDevice> of()), new RunningInstance(
|
.<String, EbsBlockDevice> of()), new RunningInstance(
|
||||||
Region.DEFAULT, "23", "ec2-72-44-33-6.compute-1.amazonaws.com",
|
defaultRegion, "23", "ec2-72-44-33-6.compute-1.amazonaws.com",
|
||||||
"ami-6ea54007", "i-28a64435", InstanceState.RUNNING, InstanceType.M1_LARGE,
|
"ami-6ea54007", "i-28a64435", InstanceState.RUNNING, InstanceType.M1_LARGE,
|
||||||
(InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService
|
(InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService
|
||||||
.iso8601DateParse("2007-08-07T11:54:42.000Z"), false,
|
.iso8601DateParse("2007-08-07T11:54:42.000Z"), false,
|
||||||
|
@ -122,8 +120,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_ebs.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_ebs.xml");
|
||||||
Set<Reservation> contents = Sets.newTreeSet();
|
Set<Reservation> contents = Sets.newTreeSet();
|
||||||
|
|
||||||
contents.add(new Reservation(Region.DEFAULT, ImmutableSet.of("adriancole.ec2ebsingress"),
|
contents.add(new Reservation(defaultRegion, ImmutableSet.of("adriancole.ec2ebsingress"),
|
||||||
ImmutableSet.of(new RunningInstance(Region.DEFAULT, "0",
|
ImmutableSet.of(new RunningInstance(defaultRegion, "0",
|
||||||
"ec2-75-101-203-146.compute-1.amazonaws.com", "ami-849875ed", "i-e564438d",
|
"ec2-75-101-203-146.compute-1.amazonaws.com", "ami-849875ed", "i-e564438d",
|
||||||
InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress
|
InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress
|
||||||
.getByName("75.101.203.146"), "aki-a71cf9ce",
|
.getByName("75.101.203.146"), "aki-a71cf9ce",
|
||||||
|
@ -153,7 +151,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -41,12 +39,12 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeKeyPairsHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeKeyPairsHandlerTest")
|
||||||
public class DescribeKeyPairsResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeKeyPairsResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_keypairs.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_keypairs.xml");
|
||||||
|
|
||||||
Set<KeyPair> expected = ImmutableSet.of(new KeyPair(Region.DEFAULT, "gsg-keypair",
|
Set<KeyPair> expected = ImmutableSet.of(new KeyPair(defaultRegion, "gsg-keypair",
|
||||||
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", null));
|
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", null));
|
||||||
|
|
||||||
DescribeKeyPairsResponseHandler handler = injector
|
DescribeKeyPairsResponseHandler handler = injector
|
||||||
|
@ -58,7 +56,7 @@ public class DescribeKeyPairsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
|
expect(request.getArgs()).andReturn(new Object[] { null });
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,10 @@ import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.IpPermission;
|
import org.jclouds.aws.ec2.domain.IpPermission;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -45,19 +43,18 @@ import com.google.common.collect.ImmutableSortedSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeSecurityGroupsHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeSecurityGroupsHandlerTest")
|
||||||
public class DescribeSecurityGroupsResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeSecurityGroupsResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_securitygroups.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_securitygroups.xml");
|
||||||
|
|
||||||
SortedSet<SecurityGroup> expected = ImmutableSortedSet.of(new SecurityGroup(Region.DEFAULT,
|
SortedSet<SecurityGroup> expected = ImmutableSortedSet.of(new SecurityGroup(defaultRegion,
|
||||||
"WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", ImmutableSortedSet
|
"WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", ImmutableSortedSet
|
||||||
.of(new IpPermission(80, 80, ImmutableSortedSet.<UserIdGroupPair> of(),
|
.of(new IpPermission(80, 80, ImmutableSortedSet.<UserIdGroupPair> of(),
|
||||||
IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0")))),
|
IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0")))),
|
||||||
new SecurityGroup(Region.DEFAULT, "RangedPortsBySource",
|
new SecurityGroup(defaultRegion, "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
|
||||||
"UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A", ImmutableSortedSet
|
"Group A", ImmutableSortedSet.of(new IpPermission(6000, 7000,
|
||||||
.of(new IpPermission(6000, 7000, ImmutableSortedSet
|
ImmutableSortedSet.<UserIdGroupPair> of(), IpProtocol.TCP,
|
||||||
.<UserIdGroupPair> of(), IpProtocol.TCP,
|
|
||||||
ImmutableSortedSet.<String> of()))));
|
ImmutableSortedSet.<String> of()))));
|
||||||
|
|
||||||
DescribeSecurityGroupsResponseHandler handler = injector
|
DescribeSecurityGroupsResponseHandler handler = injector
|
||||||
|
@ -70,7 +67,7 @@ public class DescribeSecurityGroupsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,8 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.Snapshot;
|
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -42,13 +40,13 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeSnapshotsResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeSnapshotsResponseHandlerTest")
|
||||||
public class DescribeSnapshotsResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeSnapshotsResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
DateService dateService = injector.getInstance(DateService.class);
|
DateService dateService = injector.getInstance(DateService.class);
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_snapshots.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_snapshots.xml");
|
||||||
|
|
||||||
Set<Snapshot> expected = Sets.newLinkedHashSet();
|
Set<Snapshot> expected = Sets.newLinkedHashSet();
|
||||||
expected.add(new Snapshot(Region.DEFAULT, "snap-78a54011", "vol-4d826724", 10,
|
expected.add(new Snapshot(defaultRegion, "snap-78a54011", "vol-4d826724", 10,
|
||||||
Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"),
|
Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"),
|
||||||
80, "218213537122", "Daily Backup", null));
|
80, "218213537122", "Daily Backup", null));
|
||||||
|
|
||||||
|
@ -62,7 +60,7 @@ public class DescribeSnapshotsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
|
expect(request.getArgs()).andReturn(new Object[] { null });
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,28 +24,17 @@ import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
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.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.Volume;
|
import org.jclouds.aws.ec2.domain.Volume;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DescribeVolumesResponseHandler}
|
* Tests behavior of {@code DescribeVolumesResponseHandler}
|
||||||
|
@ -53,43 +42,21 @@ import com.google.inject.Provides;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.DescribeVolumesResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.DescribeVolumesResponseHandlerTest")
|
||||||
public class DescribeVolumesResponseHandlerTest extends BaseHandlerTest {
|
public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
@BeforeTest
|
|
||||||
@Override
|
|
||||||
protected void setUpInjector() {
|
|
||||||
injector = Guice.createInjector(new ParserModule(), new AbstractModule(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
Map<AvailabilityZone, Region> provideAvailabilityZoneRegionMap() {
|
|
||||||
return ImmutableMap.<AvailabilityZone, Region> of(AvailabilityZone.US_EAST_1A,
|
|
||||||
Region.DEFAULT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
factory = injector.getInstance(ParseSax.Factory.class);
|
|
||||||
assert factory != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
DateService dateService = injector.getInstance(DateService.class);
|
DateService dateService = injector.getInstance(DateService.class);
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_volumes.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_volumes.xml");
|
||||||
|
|
||||||
Set<Volume> expected = Sets.newLinkedHashSet();
|
Set<Volume> expected = Sets.newLinkedHashSet();
|
||||||
expected.add(new Volume(Region.DEFAULT, "vol-2a21e543", 1, null, AvailabilityZone.US_EAST_1A,
|
expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, AvailabilityZone.US_EAST_1A,
|
||||||
Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
|
Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
|
||||||
Sets.<Attachment> newLinkedHashSet()));
|
Sets.<Attachment> newLinkedHashSet()));
|
||||||
expected.add(new Volume(Region.DEFAULT, "vol-4282672b", 800, "snap-536d1b3a",
|
expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
|
||||||
AvailabilityZone.US_EAST_1A, Volume.Status.IN_USE, dateService
|
AvailabilityZone.US_EAST_1A, Volume.Status.IN_USE, dateService
|
||||||
.iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets
|
.iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets
|
||||||
.<Attachment> newHashSet(new Attachment(Region.DEFAULT, "vol-4282672b",
|
.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
|
||||||
"i-6058a509", "/dev/sdh", Attachment.Status.ATTACHED, dateService
|
"/dev/sdh", Attachment.Status.ATTACHED, dateService
|
||||||
.iso8601DateParse("2008-05-07T12:51:50.000Z")))));
|
.iso8601DateParse("2008-05-07T12:51:50.000Z")))));
|
||||||
|
|
||||||
DescribeVolumesResponseHandler handler = injector
|
DescribeVolumesResponseHandler handler = injector
|
||||||
|
@ -102,7 +69,7 @@ public class DescribeVolumesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
|
@ -44,7 +42,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.InstanceStateChangeHandlerTest")
|
@Test(groups = "unit", testName = "ec2.InstanceStateChangeHandlerTest")
|
||||||
public class InstanceStateChangeHandlerTest extends BaseHandlerTest {
|
public class InstanceStateChangeHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
private DateService dateService;
|
private DateService dateService;
|
||||||
|
|
||||||
|
@ -60,7 +58,7 @@ public class InstanceStateChangeHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/terminate_instances.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/terminate_instances.xml");
|
||||||
|
|
||||||
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(Region.DEFAULT,
|
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion,
|
||||||
"i-3ea74257", InstanceState.SHUTTING_DOWN, InstanceState.RUNNING));
|
"i-3ea74257", InstanceState.SHUTTING_DOWN, InstanceState.RUNNING));
|
||||||
|
|
||||||
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
||||||
|
@ -73,7 +71,7 @@ public class InstanceStateChangeHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/start_instances.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/start_instances.xml");
|
||||||
|
|
||||||
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(Region.DEFAULT,
|
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion,
|
||||||
"i-10a64379", InstanceState.PENDING, InstanceState.STOPPED));
|
"i-10a64379", InstanceState.PENDING, InstanceState.STOPPED));
|
||||||
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
||||||
addDefaultRegionToHandler(handler);
|
addDefaultRegionToHandler(handler);
|
||||||
|
@ -85,7 +83,7 @@ public class InstanceStateChangeHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/stop_instances.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/stop_instances.xml");
|
||||||
|
|
||||||
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(Region.DEFAULT,
|
Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion,
|
||||||
"i-10a64379", InstanceState.STOPPING, InstanceState.RUNNING));
|
"i-10a64379", InstanceState.STOPPING, InstanceState.RUNNING));
|
||||||
|
|
||||||
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class);
|
||||||
|
@ -96,7 +94,7 @@ public class InstanceStateChangeHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -38,13 +36,13 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.KeyPairResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.KeyPairResponseHandlerTest")
|
||||||
public class KeyPairResponseHandlerTest extends BaseHandlerTest {
|
public class KeyPairResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/create_keypair.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/create_keypair.xml");
|
||||||
|
|
||||||
KeyPair expected = new KeyPair(
|
KeyPair expected = new KeyPair(
|
||||||
Region.DEFAULT,
|
defaultRegion,
|
||||||
"gsg-keypair",
|
"gsg-keypair",
|
||||||
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f",
|
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f",
|
||||||
"-----BEGIN RSA PRIVATE KEY-----\n"
|
"-----BEGIN RSA PRIVATE KEY-----\n"
|
||||||
|
@ -80,7 +78,7 @@ public class KeyPairResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
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.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceType;
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
|
@ -35,7 +34,6 @@ import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.RunningInstance.EbsBlockDevice;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
|
@ -52,7 +50,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.RunInstancesResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.RunInstancesResponseHandlerTest")
|
||||||
public class RunInstancesResponseHandlerTest extends BaseHandlerTest {
|
public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
|
|
||||||
private DateService dateService;
|
private DateService dateService;
|
||||||
|
|
||||||
|
@ -68,8 +66,8 @@ public class RunInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/run_instances.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/run_instances.xml");
|
||||||
|
|
||||||
Reservation expected = new Reservation(Region.DEFAULT, ImmutableSortedSet.of("default"),
|
Reservation expected = new Reservation(defaultRegion, ImmutableSortedSet.of("default"),
|
||||||
ImmutableSet.of(new RunningInstance(Region.DEFAULT, "0", null, "ami-60a54009",
|
ImmutableSet.of(new RunningInstance(defaultRegion, "0", null, "ami-60a54009",
|
||||||
"i-2ba64342", InstanceState.PENDING, InstanceType.M1_SMALL,
|
"i-2ba64342", InstanceState.PENDING, InstanceType.M1_SMALL,
|
||||||
(InetAddress) null, null, "example-key-name", dateService
|
(InetAddress) null, null, "example-key-name", dateService
|
||||||
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
||||||
|
@ -77,7 +75,7 @@ public class RunInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
.<String> newTreeSet(), null, null, null, null,
|
.<String> newTreeSet(), null, null, null, null,
|
||||||
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
||||||
.<String, EbsBlockDevice> of()), new RunningInstance(
|
.<String, EbsBlockDevice> of()), new RunningInstance(
|
||||||
Region.DEFAULT, "1", null, "ami-60a54009", "i-2bc64242",
|
defaultRegion, "1", null, "ami-60a54009", "i-2bc64242",
|
||||||
InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null,
|
InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null,
|
||||||
"example-key-name", dateService
|
"example-key-name", dateService
|
||||||
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
||||||
|
@ -85,7 +83,7 @@ public class RunInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
.<String> newTreeSet(), null, null, null, null,
|
.<String> newTreeSet(), null, null, null, null,
|
||||||
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
||||||
.<String, EbsBlockDevice> of()), new RunningInstance(
|
.<String, EbsBlockDevice> of()), new RunningInstance(
|
||||||
Region.DEFAULT, "2", null, "ami-60a54009", "i-2be64332",
|
defaultRegion, "2", null, "ami-60a54009", "i-2be64332",
|
||||||
InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null,
|
InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null,
|
||||||
"example-key-name", dateService
|
"example-key-name", dateService
|
||||||
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
.iso8601DateParse("2007-08-07T11:51:50.000Z"), true,
|
||||||
|
@ -104,7 +102,7 @@ public class RunInstancesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,8 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.domain.Snapshot;
|
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -39,14 +37,14 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.SnapshotHandlerTest")
|
@Test(groups = "unit", testName = "ec2.SnapshotHandlerTest")
|
||||||
public class SnapshotHandlerTest extends BaseHandlerTest {
|
public class SnapshotHandlerTest extends BaseEC2HandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
DateService dateService = injector.getInstance(DateService.class);
|
DateService dateService = injector.getInstance(DateService.class);
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/created_snapshot.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/created_snapshot.xml");
|
||||||
|
|
||||||
Snapshot expected = new Snapshot(Region.DEFAULT, "snap-78a54011", "vol-4d826724", 10, Snapshot.Status.PENDING,
|
Snapshot expected = new Snapshot(defaultRegion, "snap-78a54011", "vol-4d826724", 10,
|
||||||
dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"), 60, "213457642086",
|
Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"),
|
||||||
"Daily Backup", null);
|
60, "213457642086", "Daily Backup", null);
|
||||||
|
|
||||||
SnapshotHandler handler = injector.getInstance(SnapshotHandler.class);
|
SnapshotHandler handler = injector.getInstance(SnapshotHandler.class);
|
||||||
addDefaultRegionToHandler(handler);
|
addDefaultRegionToHandler(handler);
|
||||||
|
@ -56,7 +54,7 @@ public class SnapshotHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { null }).atLeastOnce();
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.s3.blobstore.functions.BlobToObject;
|
import org.jclouds.aws.s3.blobstore.functions.BlobToObject;
|
||||||
|
@ -47,7 +46,6 @@ import org.jclouds.aws.s3.options.CopyObjectOptions;
|
||||||
import org.jclouds.aws.s3.options.ListBucketOptions;
|
import org.jclouds.aws.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.aws.s3.options.PutBucketOptions;
|
import org.jclouds.aws.s3.options.PutBucketOptions;
|
||||||
import org.jclouds.aws.s3.options.PutObjectOptions;
|
import org.jclouds.aws.s3.options.PutObjectOptions;
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
|
||||||
import org.jclouds.aws.s3.xml.AccessControlListHandler;
|
import org.jclouds.aws.s3.xml.AccessControlListHandler;
|
||||||
import org.jclouds.aws.s3.xml.BucketLoggingHandler;
|
import org.jclouds.aws.s3.xml.BucketLoggingHandler;
|
||||||
import org.jclouds.aws.s3.xml.CopyObjectHandler;
|
import org.jclouds.aws.s3.xml.CopyObjectHandler;
|
||||||
|
@ -385,7 +383,7 @@ public class S3AsyncClientTest extends RestClientTest<S3AsyncClient> {
|
||||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", Region.class,
|
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", Region.class,
|
||||||
String.class, Array.newInstance(PutBucketOptions.class, 0).getClass());
|
String.class, Array.newInstance(PutBucketOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<S3AsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<S3AsyncClient> httpMethod = processor.createRequest(method,
|
||||||
Region.DEFAULT, "bucket");
|
(Region) null, "bucket");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "PUT http://bucket.stub:8080/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "PUT http://bucket.stub:8080/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Content-Length: 0\nHost: bucket.stub\n");
|
assertHeadersEqual(httpMethod, "Content-Length: 0\nHost: bucket.stub\n");
|
||||||
|
@ -546,13 +544,10 @@ public class S3AsyncClientTest extends RestClientTest<S3AsyncClient> {
|
||||||
}, new TypeLiteral<S3Client>() {
|
}, new TypeLiteral<S3Client>() {
|
||||||
}));
|
}));
|
||||||
install(new S3ObjectModule());
|
install(new S3ObjectModule());
|
||||||
Jsr330.bindProperties(binder(), checkNotNull(new S3PropertiesBuilder(new Properties())
|
Jsr330.bindProperties(binder(), checkNotNull(new S3PropertiesBuilder("user", "key")
|
||||||
.build(), "properties"));
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("http://stub:8080"));
|
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("http://stub:8080"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bind(Region.class).annotatedWith(S3.class).toInstance(Region.US_STANDARD);
|
||||||
"user");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY))
|
|
||||||
.to("key");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 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.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
package org.jclouds.aws.s3.blobstore.config;
|
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.aws.s3.config.S3StubClientModule;
|
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "unit", testName = "s3.S3BlobStoreModuleTest")
|
|
||||||
public class S3BlobStoreModuleTest {
|
|
||||||
|
|
||||||
Injector createInjector() {
|
|
||||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor(),
|
|
||||||
sameThreadExecutor()), new JDKLoggingModule(), new S3StubClientModule(),
|
|
||||||
new S3BlobStoreContextModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT))
|
|
||||||
.to("http://localhost");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to("1");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST)).to("1");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS))
|
|
||||||
.to("1");
|
|
||||||
super.configure();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testContextImplAndSingleton() {
|
|
||||||
Injector i = createInjector();
|
|
||||||
BlobStoreContext context = i.getInstance(BlobStoreContext.class);
|
|
||||||
assertEquals(context.getClass(), BlobStoreContextImpl.class);
|
|
||||||
assertEquals(context, i.getInstance(BlobStoreContext.class));
|
|
||||||
assertEquals(context.getAsyncBlobStore().getContext().getAsyncBlobStore(), context.getAsyncBlobStore());
|
|
||||||
assertEquals(context.getBlobStore().getContext().getBlobStore(), context.getBlobStore());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.config;
|
package org.jclouds.aws.s3.config;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
@ -25,11 +26,10 @@ import static org.testng.Assert.assertFalse;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
import org.jclouds.aws.s3.S3PropertiesBuilder;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
|
@ -55,18 +55,8 @@ public class S3RestClientModuleTest {
|
||||||
new AbstractModule() {
|
new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindConstant().annotatedWith(
|
Jsr330.bindProperties(binder(), checkNotNull(new S3PropertiesBuilder("user",
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user");
|
"key").build(), "properties"));
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT))
|
|
||||||
.to("http://localhost");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to("1");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS))
|
|
||||||
.to("1");
|
|
||||||
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
package org.jclouds.aws.s3.config;
|
package org.jclouds.aws.s3.config;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.s3.S3;
|
import org.jclouds.aws.s3.S3;
|
||||||
import org.jclouds.aws.s3.S3AsyncClient;
|
import org.jclouds.aws.s3.S3AsyncClient;
|
||||||
import org.jclouds.aws.s3.S3Client;
|
import org.jclouds.aws.s3.S3Client;
|
||||||
|
@ -33,6 +35,8 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.internal.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a stub alternative to invoking S3
|
* adds a stub alternative to invoking S3
|
||||||
|
@ -47,6 +51,10 @@ public class S3StubClientModule extends AbstractModule {
|
||||||
install(new TransientBlobStoreModule());
|
install(new TransientBlobStoreModule());
|
||||||
bind(S3AsyncClient.class).to(StubS3AsyncClient.class).asEagerSingleton();
|
bind(S3AsyncClient.class).to(StubS3AsyncClient.class).asEagerSingleton();
|
||||||
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("https://localhost/s3stub"));
|
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("https://localhost/s3stub"));
|
||||||
|
bind(Region.class).annotatedWith(S3.class).toInstance(Region.US_STANDARD);
|
||||||
|
bind(new TypeLiteral<Set<Region>>() {
|
||||||
|
}).annotatedWith(S3.class).toInstance(
|
||||||
|
ImmutableSet.of(Region.US_STANDARD, Region.US_WEST_1, Region.EU_WEST_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.filters;
|
package org.jclouds.aws.s3.filters;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -28,9 +29,8 @@ import javax.ws.rs.core.HttpHeaders;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.aws.s3.S3PropertiesBuilder;
|
||||||
import org.jclouds.aws.s3.config.S3RestClientModule;
|
import org.jclouds.aws.s3.config.S3RestClientModule;
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
|
@ -144,18 +144,8 @@ public class RequestAuthorizeSignatureTest {
|
||||||
new AbstractModule() {
|
new AbstractModule() {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindConstant().annotatedWith(
|
Jsr330.bindProperties(binder(), checkNotNull(
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("foo");
|
new S3PropertiesBuilder("foo", "bar")).build());
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("bar");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2");
|
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to("1");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS))
|
|
||||||
.to("1");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT))
|
|
||||||
.to("https://s3.amazonaws.com");
|
|
||||||
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
bind(UriBuilder.class).to(UriBuilderImpl.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue