mirror of https://github.com/apache/jclouds.git
Issue 491:support new ap-northeast-1 region in aws
This commit is contained in:
parent
b40c8ccb1b
commit
739bcc4c68
|
@ -115,7 +115,7 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
|
|||
|
||||
}));
|
||||
} catch (NoSuchElementException e) {
|
||||
System.err.printf("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations);
|
||||
logger.error("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations);
|
||||
builder.location(new LocationBuilder().scope(LocationScope.REGION).id(from.getRegion()).description(
|
||||
from.getRegion()).parent(defaultLocation.get()).build());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.ec2.compute.strategy;
|
||||
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static org.jclouds.ec2.util.EC2Utils.getAllRunningInstancesInRegion;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -32,8 +31,10 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.services.InstanceClient;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -66,4 +67,9 @@ public class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client, String region,
|
||||
String id) {
|
||||
return Iterables.concat(client.describeInstancesInRegion(region, id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.ec2.domain;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* Availability zones used for all ec2 instance commands.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AvailabilityZone {
|
||||
|
||||
public static final String EU_WEST_1A = "eu-west-1a";
|
||||
public static final String EU_WEST_1B = "eu-west-1b";
|
||||
public static final String US_EAST_1A = "us-east-1a";
|
||||
public static final String US_EAST_1B = "us-east-1b";
|
||||
public static final String US_EAST_1C = "us-east-1c";
|
||||
public static final String US_EAST_1D = "us-east-1d";
|
||||
public static final String US_WEST_1A = "us-west-1a";
|
||||
public static final String US_WEST_1B = "us-west-1b";
|
||||
public static final String AP_SOUTHEAST_1A = "ap-southeast-1a";
|
||||
public static final String AP_SOUTHEAST_1B = "ap-southeast-1b";
|
||||
|
||||
public static final Set<String> zones = ImmutableSet.of(EU_WEST_1A, EU_WEST_1B,
|
||||
US_EAST_1A, US_EAST_1B, US_EAST_1C, US_EAST_1D,
|
||||
US_WEST_1A, US_WEST_1B, AP_SOUTHEAST_1A, AP_SOUTHEAST_1B);
|
||||
|
||||
}
|
|
@ -22,7 +22,6 @@ package org.jclouds.ec2.options;
|
|||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +60,7 @@ public class DescribeRegionsOptions extends BaseEC2RequestOptions {
|
|||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see DescribeRegionsOptions#regions(Region[] )
|
||||
* @see DescribeRegionsOptions#regions(String[] )
|
||||
*/
|
||||
public static DescribeRegionsOptions regions(String... regions) {
|
||||
DescribeRegionsOptions options = new DescribeRegionsOptions();
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.ec2.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.services.InstanceClient;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2Utils {
|
||||
public static String[] getAvailabilityZonesForRegion(String region) {
|
||||
Set<String> availabilityZones = new HashSet<String>();
|
||||
for (String az : AvailabilityZone.zones) {
|
||||
if (az.startsWith(region))
|
||||
availabilityZones.add(az);
|
||||
}
|
||||
|
||||
return (String[]) availabilityZones.toArray(new String[availabilityZones.size()]);
|
||||
}
|
||||
|
||||
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client, String region,
|
||||
String id) {
|
||||
return Iterables.concat(client.describeInstancesInRegion(region, id));
|
||||
}
|
||||
|
||||
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
|
||||
for (Object arg : gRequest.getArgs()) {
|
||||
if (arg instanceof String) {
|
||||
String zone = (String) arg;
|
||||
if (AvailabilityZone.zones.contains(zone))
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Pattern ELB_PATTERN = Pattern.compile("([^.]+)-[^.]+\\.([^.]+)\\.elb\\.amazonaws\\.com");
|
||||
|
||||
public static Map<String, String> getLoadBalancerNameAndRegionFromDnsName(String dnsName) {
|
||||
Matcher matcher = ELB_PATTERN.matcher(checkNotNull(dnsName, "dnsName"));
|
||||
checkArgument(matcher.find(), "dnsName syntax is " + ELB_PATTERN + " didn't match: " + dnsName);
|
||||
String loadBalancerName = matcher.group(1);
|
||||
String regionName = matcher.group(2);
|
||||
checkArgument((AWSUtils.isRegion(regionName)),
|
||||
String.format("Region (%s) parsed from (%s) is not a valid region", regionName, dnsName));
|
||||
return ImmutableMap.<String, String> of(regionName, loadBalancerName);
|
||||
}
|
||||
}
|
|
@ -28,16 +28,16 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.ec2.util.EC2Utils;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.Zone;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -46,8 +46,7 @@ import com.google.common.collect.Sets;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CreateVolumeResponseHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
|
||||
public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
@Resource
|
||||
|
@ -128,8 +127,7 @@ public class CreateVolumeResponseHandler extends
|
|||
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("item")) {
|
||||
if (inAttachmentSet) {
|
||||
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus,
|
||||
attachTime));
|
||||
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime));
|
||||
volumeId = null;
|
||||
instanceId = null;
|
||||
device = null;
|
||||
|
@ -142,8 +140,7 @@ public class CreateVolumeResponseHandler extends
|
|||
}
|
||||
|
||||
private Volume newVolume() {
|
||||
Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus,
|
||||
createTime, attachments);
|
||||
Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments);
|
||||
id = null;
|
||||
size = 0;
|
||||
snapshotId = null;
|
||||
|
@ -163,14 +160,26 @@ public class CreateVolumeResponseHandler extends
|
|||
super.setContext(request);
|
||||
region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
||||
if (region == null) {
|
||||
String zone = EC2Utils.findAvailabilityZoneInArgsOrNull(getRequest());
|
||||
String zone = findAvailabilityZoneInArgsOrNull(getRequest(), availabilityZoneToRegion.keySet());
|
||||
if (zone != null) {
|
||||
region = checkNotNull(availabilityZoneToRegion.get(zone), String.format(
|
||||
"zone %s not in %s", zone, availabilityZoneToRegion));
|
||||
region = checkNotNull(availabilityZoneToRegion.get(zone),
|
||||
String.format("zone %s not in %s", zone, availabilityZoneToRegion));
|
||||
} else {
|
||||
region = defaultRegion;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest, Set<String> zones) {
|
||||
for (Object arg : gRequest.getArgs()) {
|
||||
if (arg instanceof String) {
|
||||
String zone = (String) arg;
|
||||
if (zones.contains(zone))
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.easymock.IArgumentMatcher;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.config.CustomizationResponse;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
|
@ -44,7 +43,6 @@ import org.jclouds.domain.LocationScope;
|
|||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
|
||||
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.options.RunInstancesOptions;
|
||||
|
@ -65,12 +63,12 @@ public class EC2RunNodesAndAddToSetStrategyTest {
|
|||
|
||||
@Test
|
||||
public void testZoneAsALocation() {
|
||||
assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, Region.AP_SOUTHEAST_1, AvailabilityZone.AP_SOUTHEAST_1A);
|
||||
assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, "ap-southeast-1", "ap-southeast-1a");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionAsALocation() {
|
||||
assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, Region.AP_SOUTHEAST_1, null);
|
||||
assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, "ap-southeast-1", null);
|
||||
}
|
||||
|
||||
// // fixtures
|
||||
|
@ -155,10 +153,10 @@ public class EC2RunNodesAndAddToSetStrategyTest {
|
|||
}
|
||||
|
||||
private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id(
|
||||
Region.AP_SOUTHEAST_1).description(Region.AP_SOUTHEAST_1).parent(
|
||||
new LocationBuilder().scope(LocationScope.PROVIDER).id("ec2").description("ec2").build()).build();
|
||||
"ap-southeast-1").description("ap-southeast-1").parent(
|
||||
new LocationBuilder().scope(LocationScope.PROVIDER).id("aws-ec2").description("aws-ec2").build()).build();
|
||||
private static final Location ZONE_AP_SOUTHEAST_1A = new LocationBuilder().scope(LocationScope.ZONE).id(
|
||||
AvailabilityZone.AP_SOUTHEAST_1A).description(AvailabilityZone.AP_SOUTHEAST_1A).parent(
|
||||
"ap-southeast-1a").description("ap-southeast-1a").parent(
|
||||
REGION_AP_SOUTHEAST_1).build();
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
|
||||
import org.jclouds.ec2.options.DescribeRegionsOptions;
|
||||
import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
||||
|
@ -48,17 +47,17 @@ import com.google.inject.TypeLiteral;
|
|||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest")
|
||||
public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
||||
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
||||
|
||||
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, Region.US_WEST_1);
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
||||
|
@ -69,15 +68,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
|
||||
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, Region.US_EAST_1, availabilityZones(
|
||||
AvailabilityZone.US_EAST_1A, AvailabilityZone.US_EAST_1B));
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1", availabilityZones("us-east-1a", "us-east-1b"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
||||
|
@ -87,14 +85,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
}
|
||||
|
||||
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance(
|
||||
DescribeRegionsOptions.class, 0).getClass());
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded",
|
||||
false);
|
||||
false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
||||
|
@ -104,15 +102,15 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
}
|
||||
|
||||
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance(
|
||||
DescribeRegionsOptions.class, 0).getClass());
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.jclouds.ec2.EC2Client;
|
|||
import org.jclouds.ec2.EC2ContextBuilder;
|
||||
import org.jclouds.ec2.EC2PropertiesBuilder;
|
||||
import org.jclouds.ec2.config.EC2RestClientModule;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -85,7 +84,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
|||
static class Zones implements javax.inject.Provider<Map<String, String>> {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1);
|
||||
return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable;
|
||||
import org.jclouds.ec2.options.CreateSnapshotOptions;
|
||||
import org.jclouds.ec2.options.DescribeSnapshotsOptions;
|
||||
|
@ -59,7 +58,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeInAvailabilityZone", String.class,
|
||||
int.class);
|
||||
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, 20);
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1a", 20);
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -76,7 +75,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, "snapshotId");
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1a", "snapshotId");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -94,7 +93,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
||||
String.class, int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1a", 15, "snapshotId");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.jclouds.aws.domain.Region;
|
|||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.ec2.EC2AsyncClient;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.Snapshot;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
||||
|
@ -104,8 +103,7 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
|
||||
@Test
|
||||
void testDescribeVolumes() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
|
@ -120,10 +118,10 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
|
||||
@Test
|
||||
void testCreateVolumeInAvailabilityZone() {
|
||||
Volume expected = client.createVolumeInAvailabilityZone(AvailabilityZone.US_EAST_1B, 1);
|
||||
Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1);
|
||||
assertNotNull(expected);
|
||||
System.out.println(expected);
|
||||
assertEquals(expected.getAvailabilityZone(), AvailabilityZone.US_EAST_1B);
|
||||
assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
|
||||
this.volumeId = expected.getId();
|
||||
|
||||
|
@ -148,9 +146,13 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
this.snapshot = result;
|
||||
}
|
||||
|
||||
protected String getDefaultAvailabilityZone(){
|
||||
return "us-east-1a";
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1A, snapshot.getId());
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId());
|
||||
assertNotNull(volume);
|
||||
|
||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
||||
|
@ -160,7 +162,7 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||
assertEquals(volume.getId(), result.getId());
|
||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1A);
|
||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||
|
||||
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||
|
@ -168,7 +170,7 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1B, 2,
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2,
|
||||
snapshot.getId());
|
||||
assertNotNull(volume);
|
||||
|
||||
|
@ -179,7 +181,7 @@ public class ElasticBlockStoreClientLiveTest {
|
|||
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||
assertEquals(volume.getId(), result.getId());
|
||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1B);
|
||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
assertEquals(volume.getSize(), 2);
|
||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||
|
@ -131,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo",
|
||||
HttpRequest request = processor.createRequest(method, "eu-west-1", "eu-west-1a", "ami-voo",
|
||||
1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.ec2.utils;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.ec2.util.EC2Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class EC2UtilsTest {
|
||||
|
||||
public void testGetLoadBalancerNameAndRegionFromDnsName() {
|
||||
assertEquals(
|
||||
ImmutableMap.<String, String> of("us-east-1", "my-load-balancer"),
|
||||
EC2Utils
|
||||
.getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.elb.amazonaws.com"));
|
||||
assertEquals(
|
||||
ImmutableMap.<String, String> of("us-east-1", "ec2lb"),
|
||||
EC2Utils
|
||||
.getLoadBalancerNameAndRegionFromDnsName("ec2lb-915583419.us-east-1.elb.amazonaws.com"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testGetLoadBalancerNameAndRegionFromDnsNameFail() {
|
||||
EC2Utils
|
||||
.getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.microsoft.com");
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,6 @@ import java.util.Map;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
|
@ -68,7 +67,7 @@ public abstract class BaseEC2HandlerTest extends BaseHandlerTest {
|
|||
@Provides
|
||||
@Zone
|
||||
Map<String, String> provideAvailabilityZoneRegionMap() {
|
||||
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1);
|
||||
return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
|
||||
}
|
||||
});
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.io.InputStream;
|
|||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
@ -52,7 +51,7 @@ public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
InputStream is = getClass().getResourceAsStream("/created_volume.xml");
|
||||
|
||||
Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null,
|
||||
AvailabilityZone.US_EAST_1A, Volume.Status.CREATING, dateService
|
||||
"us-east-1a", Volume.Status.CREATING, dateService
|
||||
.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets
|
||||
.<Attachment> newLinkedHashSet());
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -66,14 +64,14 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
|
|||
|
||||
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet.<String> of()),
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet
|
||||
new AvailabilityZoneInfo("us-east-1a", "available", "us-east-1", ImmutableSet.<String> of()),
|
||||
new AvailabilityZoneInfo("us-east-1b", "available", "us-east-1", ImmutableSet
|
||||
.<String> of()),
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1, ImmutableSet
|
||||
new AvailabilityZoneInfo("us-east-1c", "available", "us-east-1", ImmutableSet
|
||||
.<String> of("our service is awesome")),
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1, ImmutableSet
|
||||
new AvailabilityZoneInfo("us-east-1d", "downlikeaclown", "us-east-1", ImmutableSet
|
||||
.<String> of()));
|
||||
Set<AvailabilityZoneInfo> result = factory.create(
|
||||
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
|
@ -74,7 +73,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
"174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1C).virtualizationType("paravirtual")
|
||||
.availabilityZone("us-east-1c").virtualizationType("paravirtual")
|
||||
.privateDnsName("ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId(
|
||||
"ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
||||
"993194456877", null, "r-a3c508cb"));
|
||||
|
@ -92,7 +91,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual")
|
||||
.availabilityZone("us-east-1b").virtualizationType("paravirtual")
|
||||
.privateDnsName("10-251-50-132.ec2.internal")// product codes
|
||||
// ImmutableSet.of("774F4FF8")
|
||||
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(),
|
||||
|
@ -102,7 +101,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual")
|
||||
.availabilityZone("us-east-1b").virtualizationType("paravirtual")
|
||||
.privateDnsName("10-251-50-134.ec2.internal")// product codes
|
||||
// ImmutableSet.of("774F4FF8")
|
||||
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
||||
|
@ -124,7 +123,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
.keyName("adriancole.ec2ebs1")
|
||||
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
|
||||
// MonitoringState.DISABLED
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B)
|
||||
.availabilityZone("us-east-1b")
|
||||
// "placement"
|
||||
.virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
|
||||
.privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc")
|
||||
|
|
|
@ -27,10 +27,9 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -52,11 +51,11 @@ public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
InputStream is = getClass().getResourceAsStream("/describe_volumes.xml");
|
||||
|
||||
Set<Volume> expected = Sets.newLinkedHashSet();
|
||||
expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, AvailabilityZone.US_EAST_1A,
|
||||
expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a",
|
||||
Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
|
||||
Sets.<Attachment> newLinkedHashSet()));
|
||||
expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
|
||||
AvailabilityZone.US_EAST_1A, Volume.Status.IN_USE, dateService
|
||||
"us-east-1a", Volume.Status.IN_USE, dateService
|
||||
.iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets
|
||||
.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
|
||||
"/dev/sdh", Attachment.Status.ATTACHED, dateService
|
||||
|
|
|
@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
|
@ -70,19 +69,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
.imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B).build(),
|
||||
.availabilityZone("us-east-1b").build(),
|
||||
|
||||
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1")
|
||||
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B).build(),
|
||||
.availabilityZone("us-east-1b").build(),
|
||||
|
||||
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2")
|
||||
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
||||
.availabilityZone(AvailabilityZone.US_EAST_1B).build())
|
||||
.availabilityZone("us-east-1b").build())
|
||||
|
||||
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.s3.config.S3RestClientModule;
|
||||
import org.jclouds.s3.domain.AccessControlList;
|
||||
import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee;
|
||||
import org.jclouds.s3.domain.AccessControlList.Grant;
|
||||
import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||
import org.jclouds.s3.domain.BucketLogging;
|
||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||
import org.jclouds.s3.domain.Payer;
|
||||
import org.jclouds.s3.domain.S3Object;
|
||||
import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee;
|
||||
import org.jclouds.s3.domain.AccessControlList.Grant;
|
||||
import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
||||
|
@ -87,7 +87,7 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
||||
PutBucketOptions.class, 0).getClass());
|
||||
for (String region : Region.ALL_S3) {
|
||||
for (String region : Region.DEFAULT_S3) {
|
||||
processor.createRequest(method, region, "bucket-name");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,15 @@
|
|||
|
||||
package org.jclouds.aws.domain;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -84,6 +91,36 @@ public class Region {
|
|||
*/
|
||||
public static final String AP_SOUTHEAST_1 = "ap-southeast-1";
|
||||
|
||||
public static Set<String> ALL_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1);
|
||||
public static Set<String> ALL_SQS = ImmutableSet.of(EU_WEST_1, US_STANDARD, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
|
||||
/**
|
||||
* Region in Tokyo, launched March 2, 2011. This region improves latency for Asia-based users
|
||||
*/
|
||||
public static final String AP_NORTHEAST_1 = "ap-northeast-1";
|
||||
|
||||
public static Set<String> DEFAULT_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1, AP_NORTHEAST_1);
|
||||
|
||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1,
|
||||
AP_NORTHEAST_1);
|
||||
|
||||
public static Properties regionPropertiesS3() {
|
||||
|
||||
Properties properties = regionProperties();
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_S3));
|
||||
// note that due to US_STANDARD the codes include US instead of US-VA
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG,JP-13");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ISO3166_CODES, "US");
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU + "." + ISO3166_CODES, "IE");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static Properties regionProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG,JP-13");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA");
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ISO3166_CODES, "JP-13");
|
||||
return properties;
|
||||
}
|
||||
}
|
|
@ -117,10 +117,9 @@ public class AWSUtils {
|
|||
return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms);
|
||||
}
|
||||
|
||||
// TODO: make this more dynamic
|
||||
public static boolean isRegion(String regionName) {
|
||||
return Region.EU_WEST_1.equals(regionName) || Region.US_WEST_1.equals(regionName)
|
||||
|| Region.US_EAST_1.equals(regionName) || Region.US_STANDARD.equals(regionName)
|
||||
|| Region.AP_SOUTHEAST_1.equals(regionName);
|
||||
return Region.DEFAULT_REGIONS.contains(regionName);
|
||||
}
|
||||
|
||||
public static <R extends HttpRequest> R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) {
|
||||
|
@ -162,7 +161,7 @@ public class AWSUtils {
|
|||
for (Object arg : gRequest.getArgs()) {
|
||||
if (arg instanceof String) {
|
||||
String regionName = (String) arg;
|
||||
//TODO regions may not be amazon regions!
|
||||
// TODO regions may not be amazon regions!
|
||||
// take from a configured value
|
||||
if (isRegion(regionName))
|
||||
return regionName;
|
||||
|
|
|
@ -36,7 +36,10 @@ sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder
|
|||
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
|
||||
|
||||
aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
|
||||
aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder
|
||||
aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBuilder
|
||||
|
||||
aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder
|
||||
aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder
|
||||
|
||||
aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder
|
||||
aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder
|
||||
|
|
|
@ -20,23 +20,13 @@
|
|||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_WEST_1;
|
||||
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED;
|
||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
/**
|
||||
* Builds properties used in EC2 Clients
|
||||
|
@ -44,17 +34,9 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder {
|
||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1);
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA");
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
|
||||
|
||||
// sometimes, like in ec2, stop takes a very long time, perhaps
|
||||
// due to volume management. one example spent 2 minutes moving
|
||||
// from stopping->stopped state on an ec2 micro
|
||||
|
@ -65,7 +47,7 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
|||
properties.setProperty("jclouds.ssh.retryable_messages",
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established,connection is closed by foreign host,socket is not established");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
||||
properties.putAll(Region.regionProperties());
|
||||
// amazon, alestic, canonical, and rightscale
|
||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
|
||||
// amis that work with the cluster instances
|
||||
|
|
|
@ -209,7 +209,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|||
|
||||
@Override
|
||||
protected Set<String> getIso3166Codes() {
|
||||
return ImmutableSet.<String> of("US-VA", "US-CA", "IE", "SG");
|
||||
return ImmutableSet.<String> of("US-VA", "US-CA", "IE", "SG", "JP-13");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.ec2.services;
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||
|
@ -31,14 +31,13 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.AWSResponseException;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.ec2.EC2AsyncClient;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.Image;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.services.AMIClient;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.testng.annotations.AfterTest;
|
||||
|
@ -49,7 +48,6 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -69,7 +67,7 @@ public class AMIClientLiveTest {
|
|||
|
||||
private Set<String> imagesToDeregister = Sets.newHashSet();
|
||||
|
||||
protected String provider = "ec2";
|
||||
protected String provider = "aws-ec2";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
|
@ -110,14 +108,13 @@ public class AMIClientLiveTest {
|
|||
assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AWSResponseException.class)
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testDescribeImageBadId() {
|
||||
client.describeImagesInRegion(null, imageIds("asdaasdsa"));
|
||||
}
|
||||
|
||||
public void testDescribeImages() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
|
@ -31,13 +31,12 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.ec2.domain.Image;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
@ -49,7 +48,6 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -102,7 +100,7 @@ public class AWSAMIClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
client = context.getApi().getAMIServices();
|
||||
}
|
||||
|
||||
|
@ -116,8 +114,7 @@ public class AWSAMIClientLiveTest {
|
|||
}
|
||||
|
||||
public void testDescribeImages() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
|
@ -138,7 +135,7 @@ public class AWSAMIClientLiveTest {
|
|||
String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
||||
imagesToDeregister.add(imageRegisteredId);
|
||||
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||
imageIds(imageRegisteredId)));
|
||||
imageIds(imageRegisteredId)));
|
||||
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
||||
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
||||
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
||||
|
@ -149,10 +146,10 @@ public class AWSAMIClientLiveTest {
|
|||
@Test(enabled = false)
|
||||
public void testRegisterImageFromManifestOptions() {
|
||||
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2",
|
||||
DEFAULT_MANIFEST, withDescription("adrian"));
|
||||
DEFAULT_MANIFEST, withDescription("adrian"));
|
||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||
imageIds(imageRegisteredWithOptionsId)));
|
||||
imageIds(imageRegisteredWithOptionsId)));
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
||||
|
@ -167,7 +164,7 @@ public class AWSAMIClientLiveTest {
|
|||
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
||||
imagesToDeregister.add(imageRegisteredId);
|
||||
Image imageRegistered = Iterables
|
||||
.getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId)));
|
||||
.getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId)));
|
||||
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
||||
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
||||
|
@ -178,18 +175,19 @@ public class AWSAMIClientLiveTest {
|
|||
// awaiting EBS functionality to be added to jclouds
|
||||
public void testRegisterImageBackedByEBSOptions() {
|
||||
String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2",
|
||||
DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
|
||||
DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
|
||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||
imageIds(imageRegisteredWithOptionsId)));
|
||||
imageIds(imageRegisteredWithOptionsId)));
|
||||
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
||||
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
||||
assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1");
|
||||
assertEquals(imageRegisteredWithOptions.getDescription(), "adrian");
|
||||
assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of("/dev/sda1",
|
||||
new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2",
|
||||
new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet());
|
||||
assertEquals(
|
||||
imageRegisteredWithOptions.getEbsBlockDevices().entrySet(),
|
||||
ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2",
|
||||
new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet());
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
|
|
|
@ -24,11 +24,9 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
|
||||
import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||
|
@ -132,22 +130,22 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo",
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1", "us-east-1a", "ami-voo",
|
||||
1, 5, new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring().withSecurityGroups(
|
||||
"group1", "group2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
try {
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a",
|
||||
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
} catch (AssertionError e) {
|
||||
// mvn 3.0 osx 10.6.5 somehow sorts differently
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a",
|
||||
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
}
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
|
@ -39,7 +38,6 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -91,8 +89,7 @@ public class AWSInstanceClientLiveTest {
|
|||
|
||||
@Test
|
||||
void testDescribeInstances() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 0 : allResults.size();
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.jclouds.aws.domain.Region;
|
|||
import org.jclouds.aws.ec2.config.AWSEC2RestClientModule;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -59,7 +58,7 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
|
|||
static class Zones implements javax.inject.Provider<Map<String, String>> {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1);
|
||||
return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,14 +112,14 @@ public class PlacementGroupClientLiveTest {
|
|||
public void setupClient() throws FileNotFoundException, IOException {
|
||||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(
|
||||
new Log4JLoggingModule(), new JschSshClientModule()), overrides);
|
||||
context = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides);
|
||||
keyPair = setupKeyPair();
|
||||
|
||||
client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());
|
||||
|
||||
availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1,
|
||||
TimeUnit.SECONDS);
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
@ -128,24 +128,25 @@ public class PlacementGroupClientLiveTest {
|
|||
void testDescribe() {
|
||||
for (String region : newArrayList(Region.US_EAST_1)) {
|
||||
SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
|
||||
.describePlacementGroupsInRegion(region));
|
||||
.describePlacementGroupsInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
PlacementGroup group = allResults.last();
|
||||
SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
|
||||
.describePlacementGroupsInRegion(region, group.getName()));
|
||||
.describePlacementGroupsInRegion(region, group.getName()));
|
||||
assertNotNull(result);
|
||||
PlacementGroup compare = result.last();
|
||||
assertEquals(compare, group);
|
||||
}
|
||||
}
|
||||
|
||||
for (String region : newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
||||
try {
|
||||
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
|
||||
assert false : "should be unsupported";
|
||||
} catch (UnsupportedOperationException e) {
|
||||
}
|
||||
for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
if (!region.equals(Region.US_EAST_1))
|
||||
try {
|
||||
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
|
||||
assert false : "should be unsupported";
|
||||
} catch (UnsupportedOperationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,7 @@ public class PlacementGroupClientLiveTest {
|
|||
private void verifyPlacementGroup(String groupName) {
|
||||
assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group;
|
||||
Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null,
|
||||
groupName);
|
||||
groupName);
|
||||
assertNotNull(oneResult);
|
||||
assertEquals(oneResult.size(), 1);
|
||||
group = oneResult.iterator().next();
|
||||
|
@ -197,7 +198,7 @@ public class PlacementGroupClientLiveTest {
|
|||
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
|
||||
|
||||
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
|
||||
.runScript(buildScript(template.getImage().getOperatingSystem()));
|
||||
.runScript(buildScript(template.getImage().getOperatingSystem()));
|
||||
|
||||
String group = PREFIX + "cccluster";
|
||||
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||
|
@ -209,7 +210,7 @@ public class PlacementGroupClientLiveTest {
|
|||
NodeMetadata node = getOnlyElement(nodes);
|
||||
|
||||
getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null,
|
||||
node.getProviderId())));
|
||||
node.getProviderId())));
|
||||
|
||||
} catch (RunNodesException e) {
|
||||
System.err.println(e.getNodeErrors().keySet());
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
|||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
|
@ -77,7 +76,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
.instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId(
|
||||
"aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1C)
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1c")
|
||||
.virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal")
|
||||
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType(
|
||||
RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb"));
|
||||
|
@ -95,7 +94,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
.instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId(
|
||||
"aki-ba3adfd3").keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B)
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode(
|
||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||
.build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default")
|
||||
|
@ -103,7 +102,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType(
|
||||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B)
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode(
|
||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||
.build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d"));
|
||||
|
@ -123,7 +122,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
.instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId(
|
||||
"aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime(
|
||||
dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B)
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.placementGroup("placement").virtualizationType("hvm").privateDnsName(
|
||||
"domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress(
|
||||
"10.210.209.157").ramdiskId("ari-a51cf9cc")
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.io.InputStream;
|
|||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
|
@ -86,19 +85,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
"ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(),
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId(
|
||||
"ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(),
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId(
|
||||
"ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build())
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
|
||||
|
||||
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||
|
||||
|
|
|
@ -20,49 +20,36 @@
|
|||
package org.jclouds.aws.s3;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_STANDARD;
|
||||
import static org.jclouds.aws.domain.Region.US_WEST_1;
|
||||
import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
|
||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Builds properties used in S3 Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder {
|
||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_STANDARD, Region.US_WEST_1, "EU",
|
||||
Region.AP_SOUTHEAST_1));
|
||||
properties.putAll(Region.regionPropertiesS3());
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ISO3166_CODES, "US");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ENDPOINT,
|
||||
"https://s3-us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ISO3166_CODES, "US-CA");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ISO3166_CODES, "IE");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ENDPOINT,
|
||||
"https://s3-ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ENDPOINT,
|
||||
"https://s3-ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT,
|
||||
"https://s3-ap-northeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest {
|
||||
@Override
|
||||
protected Set<String> getIso3166Codes() {
|
||||
return ImmutableSet.<String> of("US", "US-CA", "IE", "SG");
|
||||
return ImmutableSet.<String> of("US", "US-CA", "IE", "SG", "JP-13");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,12 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
|
|
@ -18,44 +18,43 @@
|
|||
*/
|
||||
|
||||
package org.jclouds.cloudwatch;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
/**
|
||||
* Builds properties used in Cloud Watch Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_ENDPOINT,
|
||||
"https://monitoring.us-east-1.amazonaws.com");
|
||||
properties.putAll(Region.regionProperties());
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://monitoring.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
|
||||
"https://monitoring.us-east-1.amazonaws.com");
|
||||
"https://monitoring.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
|
||||
"https://monitoring.us-west-1.amazonaws.com");
|
||||
"https://monitoring.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
|
||||
"https://monitoring.eu-west-1.amazonaws.com");
|
||||
"https://monitoring.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
|
||||
"https://monitoring.ap-southeast-1.amazonaws.com");
|
||||
"https://monitoring.ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_NORTHEAST_1 + ".endpoint",
|
||||
"https://monitoring.ap-northeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -57,10 +56,9 @@ public class CloudWatchClientLiveTest {
|
|||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
||||
+ ".apiversion");
|
||||
+ ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint", null);
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion", null);
|
||||
}
|
||||
|
||||
protected Properties setupProperties() {
|
||||
|
@ -69,8 +67,10 @@ public class CloudWatchClientLiveTest {
|
|||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class CloudWatchClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||
overrides);
|
||||
overrides);
|
||||
client = context.getApi();
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,7 @@ public class CloudWatchClientLiveTest {
|
|||
void testGetMetricStatisticsInRegion() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, -1);
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
|
|||
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.InstancePort=80&Listeners.member.1.LoadBalancerPort=80",
|
||||
"Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.LoadBalancerPort=80&Listeners.member.1.InstancePort=80",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -180,9 +180,19 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
|
|||
|
||||
protected String provider = "elb";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
overrides.setProperty(provider + ".propertiesbuilder", ELBPropertiesBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".contextbuilder", ELBContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.elb;
|
||||
|
||||
import org.jclouds.rest.Providers;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersInPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "elb") : providers;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,15 +23,10 @@ import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
/**
|
||||
* Builds properties used in SQS Clients
|
||||
|
@ -45,17 +40,7 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
|
|||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||
properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_REGIONS,
|
||||
Joiner.on(',').join(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://sqs.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
|
||||
"https://sqs.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
|
||||
"https://sqs.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
|
||||
"https://sqs.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
|
||||
"https://sqs.ap-southeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.sqs;
|
||||
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.base.Predicates.not;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -31,7 +29,6 @@ import java.util.Properties;
|
|||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -48,7 +45,6 @@ import org.jclouds.sqs.xml.RegexListQueuesResponseHandler;
|
|||
import org.jclouds.sqs.xml.RegexQueueHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -145,14 +141,6 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SQSAsyncClient.class.getMethod("createQueueInRegion", String.class, String.class, Array
|
||||
.newInstance(CreateQueueOptions.class, 0).getClass());
|
||||
for (String region : Iterables.filter(Region.ALL_SQS, not(equalTo("us-standard")))) {
|
||||
processor.createRequest(method, region, "queueName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFilters(HttpRequest request) {
|
||||
assertEquals(request.getFilters().size(), 1);
|
||||
|
@ -172,9 +160,19 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
|
|||
|
||||
protected String provider = "sqs";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".endpoint", "https://sqs.us-east-1.amazonaws.com");
|
||||
overrides.setProperty(provider + ".propertiesbuilder", SQSPropertiesBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".contextbuilder", SQSContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.SortedSet;
|
|||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.AWSResponseException;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.crypto.CryptoStreams;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
@ -42,7 +41,6 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -97,60 +95,61 @@ public class SQSClientLiveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testListQueuesInRegion() throws InterruptedException {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
Queue queue = allResults.last();
|
||||
assertQueueInList(region, queue);
|
||||
}
|
||||
protected void testListQueues() throws InterruptedException {
|
||||
listQueuesInRegion(null);
|
||||
}
|
||||
|
||||
protected void listQueuesInRegion(String region) throws InterruptedException {
|
||||
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
Queue queue = allResults.last();
|
||||
assertQueueInList(region, queue);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String PREFIX = System.getProperty("user.name") + "-sqs";
|
||||
|
||||
@Test
|
||||
void testCreateQueue() throws InterruptedException {
|
||||
String queueName = PREFIX + "1";
|
||||
protected void testCreateQueue() throws InterruptedException {
|
||||
createQueueInRegion(null, PREFIX + "1");
|
||||
}
|
||||
|
||||
for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
try {
|
||||
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName)));
|
||||
if (result.size() >= 1) {
|
||||
client.deleteQueue(result.last());
|
||||
queueName += 1;// cannot recreate a queue within 60 seconds
|
||||
}
|
||||
} catch (Exception e) {
|
||||
public String createQueueInRegion(final String region, String queueName) throws InterruptedException {
|
||||
try {
|
||||
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName)));
|
||||
if (result.size() >= 1) {
|
||||
client.deleteQueue(result.last());
|
||||
queueName += 1;// cannot recreate a queue within 60 seconds
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
Queue queue = null;
|
||||
int tries = 0;
|
||||
while (queue == null && tries < 5) {
|
||||
try {
|
||||
tries++;
|
||||
queue = client.createQueueInRegion(region, queueName);
|
||||
} catch (AWSResponseException e) {
|
||||
queueName += "1";
|
||||
if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO
|
||||
// retry
|
||||
// handler
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (region != null)
|
||||
assertEquals(queue.getRegion(), region);
|
||||
assertEquals(queue.getName(), queueName);
|
||||
assertQueueInList(region, queue);
|
||||
queues.add(queue);
|
||||
}
|
||||
Queue queue = null;
|
||||
int tries = 0;
|
||||
while (queue == null && tries < 5) {
|
||||
try {
|
||||
tries++;
|
||||
queue = client.createQueueInRegion(region, queueName);
|
||||
} catch (AWSResponseException e) {
|
||||
queueName += "1";
|
||||
if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO
|
||||
// retry
|
||||
// handler
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (region != null)
|
||||
assertEquals(queue.getRegion(), region);
|
||||
assertEquals(queue.getName(), queueName);
|
||||
assertQueueInList(region, queue);
|
||||
queues.add(queue);
|
||||
return queueName;
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateQueue")
|
||||
void testSendMessage() throws InterruptedException, IOException {
|
||||
protected void testSendMessage() throws InterruptedException, IOException {
|
||||
String message = "hardyharhar";
|
||||
byte[] md5 = CryptoStreams.md5(message.getBytes());
|
||||
for (Queue queue : queues) {
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.sqs.config;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class SQSRestClientModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return new RestContextFactory().createContextBuilder("sqs", "uid", "key",
|
||||
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testServerErrorHandler() {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getServerErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegions() {
|
||||
Map<String, URI> regionMap = createInjector().getInstance(
|
||||
new Key<Map<String, URI>>(org.jclouds.location.Region.class) {
|
||||
});
|
||||
assertEquals(regionMap, ImmutableMap.<String, URI> of(Region.US_EAST_1, URI
|
||||
.create("https://sqs.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
|
||||
.create("https://sqs.us-west-1.amazonaws.com"), Region.EU_WEST_1, URI
|
||||
.create("https://sqs.eu-west-1.amazonaws.com"), Region.AP_SOUTHEAST_1, URI
|
||||
.create("https://sqs.ap-southeast-1.amazonaws.com")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientErrorHandler() {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getClientErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientRetryHandler() {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getClientErrorRetryHandler().getClass(),
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRedirectionRetryHandler() {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getRedirectionRetryHandler().getClass(),
|
||||
AWSRedirectionRetryHandler.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -74,6 +74,12 @@
|
|||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.provider</groupId>
|
||||
<artifactId>aws-ec2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-log4j</artifactId>
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.aws.elb;
|
|||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
||||
|
@ -28,41 +29,37 @@ import static org.jclouds.aws.domain.Region.US_WEST_1;
|
|||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.elb.ELBAsyncClient;
|
||||
import org.jclouds.elb.ELBPropertiesBuilder;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Builds properties used in ELB Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder {
|
||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
||||
properties.putAll(Region.regionProperties());
|
||||
properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint",
|
||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
|
||||
"https://elasticloadbalancing.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint",
|
||||
"https://elasticloadbalancing.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint",
|
||||
"https://elasticloadbalancing.ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
|
||||
"https://elasticloadbalancing.ap-northeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.aws.elb;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.elb.ELBClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -35,21 +36,21 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest {
|
|||
|
||||
@Test
|
||||
public void testCreateLoadBalancer() {
|
||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
createLoadBalancerInRegionZone(region, region + "a", name);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||
public void testDescribeLoadBalancers() {
|
||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
describeLoadBalancerInRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteLoadBalancer() {
|
||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
deleteLoadBalancerInRegion(region);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,13 @@
|
|||
|
||||
package org.jclouds.aws.elb;
|
||||
|
||||
import static org.jclouds.aws.elb.AWSELBPropertiesBuilder.DEFAULT_REGIONS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.elb.ELBAsyncClient;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -40,9 +41,14 @@ public class ELBAsyncClientTest extends org.jclouds.elb.ELBAsyncClientTest {
|
|||
this.provider = "aws-elb";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||
}
|
||||
|
||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class);
|
||||
for (String region : DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
processor.createRequest(method, region);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,51 +20,49 @@
|
|||
package org.jclouds.aws.simpledb;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_WEST_1;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Builds properties used in SimpleDB Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder {
|
||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
|
||||
public class AWSSimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder {
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
||||
properties.putAll(Region.regionProperties());
|
||||
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
|
||||
"https://sdb.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint",
|
||||
"https://sdb.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint",
|
||||
"https://sdb.ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
|
||||
"https://sdb.ap-northeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public SimpleDBPropertiesBuilder() {
|
||||
public AWSSimpleDBPropertiesBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SimpleDBPropertiesBuilder(Properties properties) {
|
||||
public AWSSimpleDBPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
|
@ -19,12 +19,14 @@
|
|||
|
||||
package org.jclouds.aws.simpledb;
|
||||
|
||||
import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.simpledb.SimpleDBAsyncClient;
|
||||
import org.jclouds.simpledb.SimpleDBAsyncClientTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -34,17 +36,20 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "aws.SimpleDBAsyncClientTest")
|
||||
public class SimpleDBAsyncClientTest extends org.jclouds.simpledb.SimpleDBAsyncClientTest {
|
||||
public class AWSSimpleDBAsyncClientTest extends SimpleDBAsyncClientTest {
|
||||
|
||||
public SimpleDBAsyncClientTest() {
|
||||
public AWSSimpleDBAsyncClientTest() {
|
||||
this.provider = "aws-simpledb";
|
||||
}
|
||||
|
||||
// TODO fix this test as it has the wrong arg count
|
||||
@Test(enabled = false)
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||
}
|
||||
|
||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class);
|
||||
for (String region : DEFAULT_REGIONS) {
|
||||
Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class);
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
processor.createRequest(method, region, "domainName");
|
||||
}
|
||||
}
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
package org.jclouds.aws.simpledb;
|
||||
|
||||
import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.simpledb.SimpleDBClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -36,7 +35,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
|
|||
}
|
||||
@Test
|
||||
void testListDomainsInRegion() throws InterruptedException {
|
||||
for (String region : DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
listDomainInRegion(region);
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +43,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
|
|||
@Test
|
||||
void testCreateDomainInRegions() throws InterruptedException {
|
||||
String domainName = PREFIX + "1";
|
||||
|
||||
for (String region : DEFAULT_REGIONS) {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
domainName = createDomainInRegion(region, domainName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue