mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of git://github.com/jclouds/jclouds into large-blob
This commit is contained in:
commit
589579191c
|
@ -115,7 +115,7 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
|
||||||
|
|
||||||
}));
|
}));
|
||||||
} catch (NoSuchElementException e) {
|
} 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(
|
builder.location(new LocationBuilder().scope(LocationScope.REGION).id(from.getRegion()).description(
|
||||||
from.getRegion()).parent(defaultLocation.get()).build());
|
from.getRegion()).parent(defaultLocation.get()).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.jclouds.ec2.compute.strategy;
|
package org.jclouds.ec2.compute.strategy;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
import static org.jclouds.ec2.util.EC2Utils.getAllRunningInstancesInRegion;
|
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
@ -32,8 +31,10 @@ import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.ec2.EC2Client;
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.RunningInstance;
|
import org.jclouds.ec2.domain.RunningInstance;
|
||||||
|
import org.jclouds.ec2.services.InstanceClient;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
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.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
|
import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +60,7 @@ public class DescribeRegionsOptions extends BaseEC2RequestOptions {
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DescribeRegionsOptions#regions(Region[] )
|
* @see DescribeRegionsOptions#regions(String[] )
|
||||||
*/
|
*/
|
||||||
public static DescribeRegionsOptions regions(String... regions) {
|
public static DescribeRegionsOptions regions(String... regions) {
|
||||||
DescribeRegionsOptions options = new DescribeRegionsOptions();
|
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.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
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.aws.util.AWSUtils;
|
||||||
import org.jclouds.date.DateService;
|
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.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.location.Zone;
|
import org.jclouds.location.Zone;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -46,8 +46,7 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CreateVolumeResponseHandler extends
|
public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
|
||||||
ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -128,8 +127,7 @@ public class CreateVolumeResponseHandler extends
|
||||||
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
if (inAttachmentSet) {
|
if (inAttachmentSet) {
|
||||||
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus,
|
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime));
|
||||||
attachTime));
|
|
||||||
volumeId = null;
|
volumeId = null;
|
||||||
instanceId = null;
|
instanceId = null;
|
||||||
device = null;
|
device = null;
|
||||||
|
@ -142,8 +140,7 @@ public class CreateVolumeResponseHandler extends
|
||||||
}
|
}
|
||||||
|
|
||||||
private Volume newVolume() {
|
private Volume newVolume() {
|
||||||
Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus,
|
Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments);
|
||||||
createTime, attachments);
|
|
||||||
id = null;
|
id = null;
|
||||||
size = 0;
|
size = 0;
|
||||||
snapshotId = null;
|
snapshotId = null;
|
||||||
|
@ -163,14 +160,26 @@ public class CreateVolumeResponseHandler extends
|
||||||
super.setContext(request);
|
super.setContext(request);
|
||||||
region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
String zone = EC2Utils.findAvailabilityZoneInArgsOrNull(getRequest());
|
String zone = findAvailabilityZoneInArgsOrNull(getRequest(), availabilityZoneToRegion.keySet());
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
region = checkNotNull(availabilityZoneToRegion.get(zone), String.format(
|
region = checkNotNull(availabilityZoneToRegion.get(zone),
|
||||||
"zone %s not in %s", zone, availabilityZoneToRegion));
|
String.format("zone %s not in %s", zone, availabilityZoneToRegion));
|
||||||
} else {
|
} else {
|
||||||
region = defaultRegion;
|
region = defaultRegion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
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 java.util.Set;
|
||||||
|
|
||||||
import org.easymock.IArgumentMatcher;
|
import org.easymock.IArgumentMatcher;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -44,7 +43,6 @@ import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.ec2.EC2Client;
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
|
import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
|
||||||
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
|
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.Reservation;
|
import org.jclouds.ec2.domain.Reservation;
|
||||||
import org.jclouds.ec2.domain.RunningInstance;
|
import org.jclouds.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.ec2.options.RunInstancesOptions;
|
import org.jclouds.ec2.options.RunInstancesOptions;
|
||||||
|
@ -65,12 +63,12 @@ public class EC2RunNodesAndAddToSetStrategyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoneAsALocation() {
|
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
|
@Test
|
||||||
public void testRegionAsALocation() {
|
public void testRegionAsALocation() {
|
||||||
assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, Region.AP_SOUTHEAST_1, null);
|
assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, "ap-southeast-1", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // fixtures
|
// // fixtures
|
||||||
|
@ -155,10 +153,10 @@ public class EC2RunNodesAndAddToSetStrategyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id(
|
private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id(
|
||||||
Region.AP_SOUTHEAST_1).description(Region.AP_SOUTHEAST_1).parent(
|
"ap-southeast-1").description("ap-southeast-1").parent(
|
||||||
new LocationBuilder().scope(LocationScope.PROVIDER).id("ec2").description("ec2").build()).build();
|
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(
|
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();
|
REGION_AP_SOUTHEAST_1).build();
|
||||||
|
|
||||||
// /////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
|
import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
|
||||||
import org.jclouds.ec2.options.DescribeRegionsOptions;
|
import org.jclouds.ec2.options.DescribeRegionsOptions;
|
||||||
import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
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
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest")
|
@Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest")
|
||||||
public class AvailabilityZoneAndRegionAsyncClientTest extends
|
public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
||||||
|
|
||||||
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
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);
|
HttpRequest request = processor.createRequest(method, Region.US_WEST_1);
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
|
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones",
|
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);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
||||||
|
@ -69,15 +68,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
|
|
||||||
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
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_EAST_1, availabilityZones(
|
HttpRequest request = processor.createRequest(method, "us-east-1", availabilityZones("us-east-1a", "us-east-1b"));
|
||||||
AvailabilityZone.US_EAST_1A, AvailabilityZone.US_EAST_1B));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(request,
|
assertPayloadEquals(request,
|
||||||
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
|
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
|
||||||
"application/x-www-form-urlencoded", false);
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
|
||||||
|
@ -87,14 +85,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance(
|
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||||
DescribeRegionsOptions.class, 0).getClass());
|
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||||
HttpRequest request = processor.createRequest(method);
|
HttpRequest request = processor.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded",
|
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
||||||
|
@ -104,15 +102,15 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance(
|
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||||
DescribeRegionsOptions.class, 0).getClass());
|
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||||
HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1));
|
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");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(request,
|
assertPayloadEquals(request,
|
||||||
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
|
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
|
||||||
"application/x-www-form-urlencoded", false);
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.EC2ContextBuilder;
|
import org.jclouds.ec2.EC2ContextBuilder;
|
||||||
import org.jclouds.ec2.EC2PropertiesBuilder;
|
import org.jclouds.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.ec2.config.EC2RestClientModule;
|
import org.jclouds.ec2.config.EC2RestClientModule;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
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>> {
|
static class Zones implements javax.inject.Provider<Map<String, String>> {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> get() {
|
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.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable;
|
import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable;
|
||||||
import org.jclouds.ec2.options.CreateSnapshotOptions;
|
import org.jclouds.ec2.options.CreateSnapshotOptions;
|
||||||
import org.jclouds.ec2.options.DescribeSnapshotsOptions;
|
import org.jclouds.ec2.options.DescribeSnapshotsOptions;
|
||||||
|
@ -59,7 +58,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
||||||
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeInAvailabilityZone", String.class,
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeInAvailabilityZone", String.class,
|
||||||
int.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");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
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 {
|
public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
||||||
String.class, String.class);
|
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");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
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 {
|
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
|
||||||
String.class, int.class, String.class);
|
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");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
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.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.ec2.EC2AsyncClient;
|
import org.jclouds.ec2.EC2AsyncClient;
|
||||||
import org.jclouds.ec2.EC2Client;
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.Snapshot;
|
import org.jclouds.ec2.domain.Snapshot;
|
||||||
import org.jclouds.ec2.domain.Volume;
|
import org.jclouds.ec2.domain.Volume;
|
||||||
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
||||||
|
@ -104,8 +103,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeVolumes() {
|
void testDescribeVolumes() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
@ -120,10 +118,10 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateVolumeInAvailabilityZone() {
|
void testCreateVolumeInAvailabilityZone() {
|
||||||
Volume expected = client.createVolumeInAvailabilityZone(AvailabilityZone.US_EAST_1B, 1);
|
Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1);
|
||||||
assertNotNull(expected);
|
assertNotNull(expected);
|
||||||
System.out.println(expected);
|
System.out.println(expected);
|
||||||
assertEquals(expected.getAvailabilityZone(), AvailabilityZone.US_EAST_1B);
|
assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||||
|
|
||||||
this.volumeId = expected.getId();
|
this.volumeId = expected.getId();
|
||||||
|
|
||||||
|
@ -148,9 +146,13 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
this.snapshot = result;
|
this.snapshot = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getDefaultAvailabilityZone(){
|
||||||
|
return "us-east-1a";
|
||||||
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
||||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1A, snapshot.getId());
|
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId());
|
||||||
assertNotNull(volume);
|
assertNotNull(volume);
|
||||||
|
|
||||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
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()));
|
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||||
assertEquals(volume.getId(), result.getId());
|
assertEquals(volume.getId(), result.getId());
|
||||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||||
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1A);
|
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||||
|
|
||||||
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||||
|
@ -168,7 +170,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
||||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1B, 2,
|
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2,
|
||||||
snapshot.getId());
|
snapshot.getId());
|
||||||
assertNotNull(volume);
|
assertNotNull(volume);
|
||||||
|
|
||||||
|
@ -179,7 +181,7 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||||
assertEquals(volume.getId(), result.getId());
|
assertEquals(volume.getId(), result.getId());
|
||||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||||
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1B);
|
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||||
assertEquals(volume.getSize(), 2);
|
assertEquals(volume.getSize(), 2);
|
||||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
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.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||||
|
@ -131,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
||||||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
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"));
|
1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
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 javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
@ -68,7 +67,7 @@ public abstract class BaseEC2HandlerTest extends BaseHandlerTest {
|
||||||
@Provides
|
@Provides
|
||||||
@Zone
|
@Zone
|
||||||
Map<String, String> provideAvailabilityZoneRegionMap() {
|
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);
|
factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.io.InputStream;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.Attachment;
|
import org.jclouds.ec2.domain.Attachment;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.Volume;
|
import org.jclouds.ec2.domain.Volume;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
@ -52,7 +51,7 @@ public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/created_volume.xml");
|
InputStream is = getClass().getResourceAsStream("/created_volume.xml");
|
||||||
|
|
||||||
Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null,
|
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
|
.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets
|
||||||
.<Attachment> newLinkedHashSet());
|
.<Attachment> newLinkedHashSet());
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
@ -66,14 +64,14 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
|
||||||
|
|
||||||
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
||||||
|
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet.<String> of()),
|
new AvailabilityZoneInfo("us-east-1a", "available", "us-east-1", ImmutableSet.<String> of()),
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet
|
new AvailabilityZoneInfo("us-east-1b", "available", "us-east-1", ImmutableSet
|
||||||
.<String> of()),
|
.<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")),
|
.<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()));
|
.<String> of()));
|
||||||
Set<AvailabilityZoneInfo> result = factory.create(
|
Set<AvailabilityZoneInfo> result = factory.create(
|
||||||
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.Attachment;
|
import org.jclouds.ec2.domain.Attachment;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.InstanceState;
|
import org.jclouds.ec2.domain.InstanceState;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
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(
|
"174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
|
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
|
||||||
// MonitoringState.DISABLED,
|
// 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(
|
.privateDnsName("ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId(
|
||||||
"ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
"ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
||||||
"993194456877", null, "r-a3c508cb"));
|
"993194456877", null, "r-a3c508cb"));
|
||||||
|
@ -92,7 +91,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime(
|
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||||
// MonitoringState.DISABLED,
|
// MonitoringState.DISABLED,
|
||||||
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual")
|
.availabilityZone("us-east-1b").virtualizationType("paravirtual")
|
||||||
.privateDnsName("10-251-50-132.ec2.internal")// product codes
|
.privateDnsName("10-251-50-132.ec2.internal")// product codes
|
||||||
// ImmutableSet.of("774F4FF8")
|
// ImmutableSet.of("774F4FF8")
|
||||||
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(),
|
.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")
|
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||||
// MonitoringState.DISABLED,
|
// MonitoringState.DISABLED,
|
||||||
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual")
|
.availabilityZone("us-east-1b").virtualizationType("paravirtual")
|
||||||
.privateDnsName("10-251-50-134.ec2.internal")// product codes
|
.privateDnsName("10-251-50-134.ec2.internal")// product codes
|
||||||
// ImmutableSet.of("774F4FF8")
|
// ImmutableSet.of("774F4FF8")
|
||||||
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
||||||
|
@ -124,7 +123,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
.keyName("adriancole.ec2ebs1")
|
.keyName("adriancole.ec2ebs1")
|
||||||
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
|
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
|
||||||
// MonitoringState.DISABLED
|
// MonitoringState.DISABLED
|
||||||
.availabilityZone(AvailabilityZone.US_EAST_1B)
|
.availabilityZone("us-east-1b")
|
||||||
// "placement"
|
// "placement"
|
||||||
.virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
|
.virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
|
||||||
.privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc")
|
.privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc")
|
||||||
|
|
|
@ -27,10 +27,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.ec2.domain.Attachment;
|
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.Volume;
|
|
||||||
import org.jclouds.date.DateService;
|
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.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -52,11 +51,11 @@ public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/describe_volumes.xml");
|
InputStream is = getClass().getResourceAsStream("/describe_volumes.xml");
|
||||||
|
|
||||||
Set<Volume> expected = Sets.newLinkedHashSet();
|
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"),
|
Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
|
||||||
Sets.<Attachment> newLinkedHashSet()));
|
Sets.<Attachment> newLinkedHashSet()));
|
||||||
expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
|
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
|
.iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets
|
||||||
.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
|
.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
|
||||||
"/dev/sdh", Attachment.Status.ATTACHED, dateService
|
"/dev/sdh", Attachment.Status.ATTACHED, dateService
|
||||||
|
|
|
@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.InstanceState;
|
import org.jclouds.ec2.domain.InstanceState;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.ec2.domain.Reservation;
|
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(
|
.imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
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")
|
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1")
|
||||||
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
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")
|
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2")
|
||||||
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
|
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");
|
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,13 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.s3.config.S3RestClientModule;
|
import org.jclouds.s3.config.S3RestClientModule;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
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.BucketLogging;
|
||||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||||
import org.jclouds.s3.domain.Payer;
|
import org.jclouds.s3.domain.Payer;
|
||||||
import org.jclouds.s3.domain.S3Object;
|
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.ParseObjectFromHeadersAndHttpContent;
|
||||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
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 {
|
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
||||||
PutBucketOptions.class, 0).getClass());
|
PutBucketOptions.class, 0).getClass());
|
||||||
for (String region : Region.ALL_S3) {
|
for (String region : Region.DEFAULT_S3) {
|
||||||
processor.createRequest(method, region, "bucket-name");
|
processor.createRequest(method, region, "bucket-name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest<VCloudClien
|
||||||
VApp app = connection.getVApp(item.getHref());
|
VApp app = connection.getVApp(item.getHref());
|
||||||
assertNotNull(app);
|
assertNotNull(app);
|
||||||
for (Vm vm : app.getChildren()) {
|
for (Vm vm : app.getChildren()) {
|
||||||
assertEquals(connection.getVm(vm.getHref()), vm);
|
// assertEquals(connection.getVm(vm.getHref()), vm);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,15 @@
|
||||||
|
|
||||||
package org.jclouds.aws.domain;
|
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 java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableSet;
|
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 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);
|
return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: make this more dynamic
|
||||||
public static boolean isRegion(String regionName) {
|
public static boolean isRegion(String regionName) {
|
||||||
return Region.EU_WEST_1.equals(regionName) || Region.US_WEST_1.equals(regionName)
|
return Region.DEFAULT_REGIONS.contains(regionName);
|
||||||
|| Region.US_EAST_1.equals(regionName) || Region.US_STANDARD.equals(regionName)
|
|
||||||
|| Region.AP_SOUTHEAST_1.equals(regionName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <R extends HttpRequest> R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) {
|
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()) {
|
for (Object arg : gRequest.getArgs()) {
|
||||||
if (arg instanceof String) {
|
if (arg instanceof String) {
|
||||||
String regionName = (String) arg;
|
String regionName = (String) arg;
|
||||||
//TODO regions may not be amazon regions!
|
// TODO regions may not be amazon regions!
|
||||||
// take from a configured value
|
// take from a configured value
|
||||||
if (isRegion(regionName))
|
if (isRegion(regionName))
|
||||||
return regionName;
|
return regionName;
|
||||||
|
|
|
@ -98,16 +98,16 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
if (qName.equals("Vdc")) {
|
if (qName.endsWith("Vdc")) {
|
||||||
vDC = newReferenceType(attributes);
|
vDC = newReferenceType(attributes);
|
||||||
String status = attributes.get("status");
|
String status = attributes.get("status");
|
||||||
if (status != null)
|
if (status != null)
|
||||||
this.status = VDCStatus.fromValue(Integer.parseInt(status));
|
this.status = VDCStatus.fromValue(Integer.parseInt(status));
|
||||||
} else if (qName.equals("Network")) {
|
} else if (qName.endsWith("Network")) {
|
||||||
putReferenceType(availableNetworks, attributes);
|
putReferenceType(availableNetworks, attributes);
|
||||||
} else if (qName.equals("ResourceEntity")) {
|
} else if (qName.endsWith("ResourceEntity")) {
|
||||||
putReferenceType(resourceEntities, attributes);
|
putReferenceType(resourceEntities, attributes);
|
||||||
} else if (qName.equals("Link") && "up".equals(attributes.get("rel"))) {
|
} else if (qName.endsWith("Link") && "up".equals(attributes.get("rel"))) {
|
||||||
org = newReferenceType(attributes);
|
org = newReferenceType(attributes);
|
||||||
} else {
|
} else {
|
||||||
taskHandler.startElement(uri, localName, qName, attrs);
|
taskHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Properties;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
import org.jclouds.vcloud.domain.Catalog;
|
||||||
import org.jclouds.vcloud.domain.CatalogItem;
|
import org.jclouds.vcloud.domain.CatalogItem;
|
||||||
|
@ -94,9 +95,13 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
|
||||||
VDC response = connection.getVDC(vdc.getHref());
|
VDC response = connection.getVDC(vdc.getHref());
|
||||||
for (ReferenceType resource : response.getAvailableNetworks().values()) {
|
for (ReferenceType resource : response.getAvailableNetworks().values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
|
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
|
||||||
|
try{
|
||||||
OrgNetwork item = connection.getNetwork(resource.getHref());
|
OrgNetwork item = connection.getNetwork(resource.getHref());
|
||||||
assertNotNull(item);
|
assertNotNull(item);
|
||||||
}
|
} catch (AuthorizationException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,11 @@ public interface RunScriptOnNode extends Callable<ExecResponse> {
|
||||||
@Override
|
@Override
|
||||||
ExecResponse call();
|
ExecResponse call();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return statement that will be executed
|
||||||
|
*/
|
||||||
|
Statement getStatement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verifies that the command can execute on the node. For example, if this is ssh, it may attempt
|
* verifies that the command can execute on the node. For example, if this is ssh, it may attempt
|
||||||
* to find a reachable socket. If this is using an API, it may attempt to validate that
|
* to find a reachable socket. If this is using an API, it may attempt to validate that
|
||||||
|
|
|
@ -156,4 +156,9 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode {
|
||||||
return Objects.toStringHelper(this).add("node", node).add("name", name).add("runAsRoot", runAsRoot).toString();
|
return Objects.toStringHelper(this).add("node", node).add("name", name).add("runAsRoot", runAsRoot).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Statement getStatement() {
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -124,4 +124,9 @@ public class RunScriptOnNodeUsingSsh implements RunScriptOnNode {
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Statement getStatement() {
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,7 +36,10 @@ sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder
|
||||||
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
|
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
|
||||||
|
|
||||||
aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
|
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.contextbuilder=org.jclouds.elb.ELBContextBuilder
|
||||||
aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder
|
aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder
|
||||||
|
|
|
@ -20,23 +20,13 @@
|
||||||
package org.jclouds.aws.ec2;
|
package org.jclouds.aws.ec2;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
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.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs;
|
||||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED;
|
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.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.Properties;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import org.jclouds.aws.domain.Region;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in EC2 Clients
|
* Builds properties used in EC2 Clients
|
||||||
|
@ -44,17 +34,9 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder {
|
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
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.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
|
// sometimes, like in ec2, stop takes a very long time, perhaps
|
||||||
// due to volume management. one example spent 2 minutes moving
|
// due to volume management. one example spent 2 minutes moving
|
||||||
// from stopping->stopped state on an ec2 micro
|
// 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",
|
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");
|
"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_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
|
// amazon, alestic, canonical, and rightscale
|
||||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
|
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
|
||||||
// amis that work with the cluster instances
|
// amis that work with the cluster instances
|
||||||
|
|
|
@ -209,7 +209,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> getIso3166Codes() {
|
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 com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||||
|
@ -31,14 +31,13 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.AWSResponseException;
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.ec2.EC2AsyncClient;
|
import org.jclouds.ec2.EC2AsyncClient;
|
||||||
import org.jclouds.ec2.EC2Client;
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.Image;
|
import org.jclouds.ec2.domain.Image;
|
||||||
import org.jclouds.ec2.domain.RootDeviceType;
|
|
||||||
import org.jclouds.ec2.domain.Image.ImageType;
|
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.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.testng.annotations.AfterTest;
|
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.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -69,7 +67,7 @@ public class AMIClientLiveTest {
|
||||||
|
|
||||||
private Set<String> imagesToDeregister = Sets.newHashSet();
|
private Set<String> imagesToDeregister = Sets.newHashSet();
|
||||||
|
|
||||||
protected String provider = "ec2";
|
protected String provider = "aws-ec2";
|
||||||
protected String identity;
|
protected String identity;
|
||||||
protected String credential;
|
protected String credential;
|
||||||
protected String endpoint;
|
protected String endpoint;
|
||||||
|
@ -110,14 +108,13 @@ public class AMIClientLiveTest {
|
||||||
assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0);
|
assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = AWSResponseException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testDescribeImageBadId() {
|
public void testDescribeImageBadId() {
|
||||||
client.describeImagesInRegion(null, imageIds("asdaasdsa"));
|
client.describeImagesInRegion(null, imageIds("asdaasdsa"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() {
|
public void testDescribeImages() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 2 : allResults.size();
|
|
@ -31,13 +31,12 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
||||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.ec2.domain.Image;
|
import org.jclouds.ec2.domain.Image;
|
||||||
import org.jclouds.ec2.domain.RootDeviceType;
|
|
||||||
import org.jclouds.ec2.domain.Image.ImageType;
|
import org.jclouds.ec2.domain.Image.ImageType;
|
||||||
|
import org.jclouds.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContext;
|
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.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -102,7 +100,7 @@ public class AWSAMIClientLiveTest {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
context = new ComputeServiceContextFactory().createContext(provider,
|
context = new ComputeServiceContextFactory().createContext(provider,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||||
client = context.getApi().getAMIServices();
|
client = context.getApi().getAMIServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,8 +114,7 @@ public class AWSAMIClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() {
|
public void testDescribeImages() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 2 : allResults.size();
|
||||||
|
@ -138,7 +135,7 @@ public class AWSAMIClientLiveTest {
|
||||||
String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||||
imageIds(imageRegisteredId)));
|
imageIds(imageRegisteredId)));
|
||||||
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
||||||
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
||||||
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
||||||
|
@ -149,10 +146,10 @@ public class AWSAMIClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRegisterImageFromManifestOptions() {
|
public void testRegisterImageFromManifestOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2",
|
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2",
|
||||||
DEFAULT_MANIFEST, withDescription("adrian"));
|
DEFAULT_MANIFEST, withDescription("adrian"));
|
||||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||||
imageIds(imageRegisteredWithOptionsId)));
|
imageIds(imageRegisteredWithOptionsId)));
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
||||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
||||||
|
@ -167,7 +164,7 @@ public class AWSAMIClientLiveTest {
|
||||||
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegistered = Iterables
|
Image imageRegistered = Iterables
|
||||||
.getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId)));
|
.getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId)));
|
||||||
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
||||||
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
||||||
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
||||||
|
@ -178,18 +175,19 @@ public class AWSAMIClientLiveTest {
|
||||||
// awaiting EBS functionality to be added to jclouds
|
// awaiting EBS functionality to be added to jclouds
|
||||||
public void testRegisterImageBackedByEBSOptions() {
|
public void testRegisterImageBackedByEBSOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2",
|
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);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
|
||||||
imageIds(imageRegisteredWithOptionsId)));
|
imageIds(imageRegisteredWithOptionsId)));
|
||||||
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
||||||
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
||||||
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
||||||
assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1");
|
assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1");
|
||||||
assertEquals(imageRegisteredWithOptions.getDescription(), "adrian");
|
assertEquals(imageRegisteredWithOptions.getDescription(), "adrian");
|
||||||
assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of("/dev/sda1",
|
assertEquals(
|
||||||
new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2",
|
imageRegisteredWithOptions.getEbsBlockDevices().entrySet(),
|
||||||
new Image.EbsBlockDevice("/dev/sda2", 1, true)).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)
|
@Test(enabled = false)
|
||||||
|
|
|
@ -24,11 +24,9 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
|
import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
|
||||||
import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||||
|
@ -132,22 +130,22 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
||||||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
Method method = AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
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(
|
1, 5, new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring().withSecurityGroups(
|
||||||
"group1", "group2"));
|
"group1", "group2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
|
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||||
try {
|
try {
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
request,
|
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);
|
"application/x-www-form-urlencoded", false);
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
// mvn 3.0 osx 10.6.5 somehow sorts differently
|
// mvn 3.0 osx 10.6.5 somehow sorts differently
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
request,
|
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);
|
"application/x-www-form-urlencoded", false);
|
||||||
}
|
}
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
||||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
@ -39,7 +38,6 @@ import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,8 +89,7 @@ public class AWSInstanceClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeInstances() {
|
void testDescribeInstances() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 0 : allResults.size();
|
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.ec2.config.AWSEC2RestClientModule;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
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>> {
|
static class Zones implements javax.inject.Provider<Map<String, String>> {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> get() {
|
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 {
|
public void setupClient() throws FileNotFoundException, IOException {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(
|
context = new ComputeServiceContextFactory().createContext(provider,
|
||||||
new Log4JLoggingModule(), new JschSshClientModule()), overrides);
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides);
|
||||||
keyPair = setupKeyPair();
|
keyPair = setupKeyPair();
|
||||||
|
|
||||||
client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());
|
client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());
|
||||||
|
|
||||||
availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1,
|
availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
||||||
deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS);
|
deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
@ -128,24 +128,25 @@ public class PlacementGroupClientLiveTest {
|
||||||
void testDescribe() {
|
void testDescribe() {
|
||||||
for (String region : newArrayList(Region.US_EAST_1)) {
|
for (String region : newArrayList(Region.US_EAST_1)) {
|
||||||
SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
|
SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
|
||||||
.describePlacementGroupsInRegion(region));
|
.describePlacementGroupsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
PlacementGroup group = allResults.last();
|
PlacementGroup group = allResults.last();
|
||||||
SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
|
SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
|
||||||
.describePlacementGroupsInRegion(region, group.getName()));
|
.describePlacementGroupsInRegion(region, group.getName()));
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
PlacementGroup compare = result.last();
|
PlacementGroup compare = result.last();
|
||||||
assertEquals(compare, group);
|
assertEquals(compare, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String region : newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
try {
|
if (!region.equals(Region.US_EAST_1))
|
||||||
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
|
try {
|
||||||
assert false : "should be unsupported";
|
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
|
||||||
} catch (UnsupportedOperationException e) {
|
assert false : "should be unsupported";
|
||||||
}
|
} catch (UnsupportedOperationException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ public class PlacementGroupClientLiveTest {
|
||||||
private void verifyPlacementGroup(String groupName) {
|
private void verifyPlacementGroup(String groupName) {
|
||||||
assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group;
|
assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group;
|
||||||
Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null,
|
Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null,
|
||||||
groupName);
|
groupName);
|
||||||
assertNotNull(oneResult);
|
assertNotNull(oneResult);
|
||||||
assertEquals(oneResult.size(), 1);
|
assertEquals(oneResult.size(), 1);
|
||||||
group = oneResult.iterator().next();
|
group = oneResult.iterator().next();
|
||||||
|
@ -197,7 +198,7 @@ public class PlacementGroupClientLiveTest {
|
||||||
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
|
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
|
||||||
|
|
||||||
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
|
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
|
||||||
.runScript(buildScript(template.getImage().getOperatingSystem()));
|
.runScript(buildScript(template.getImage().getOperatingSystem()));
|
||||||
|
|
||||||
String group = PREFIX + "cccluster";
|
String group = PREFIX + "cccluster";
|
||||||
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
|
@ -209,7 +210,7 @@ public class PlacementGroupClientLiveTest {
|
||||||
NodeMetadata node = getOnlyElement(nodes);
|
NodeMetadata node = getOnlyElement(nodes);
|
||||||
|
|
||||||
getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null,
|
getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null,
|
||||||
node.getProviderId())));
|
node.getProviderId())));
|
||||||
|
|
||||||
} catch (RunNodesException e) {
|
} catch (RunNodesException e) {
|
||||||
System.err.println(e.getNodeErrors().keySet());
|
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.aws.ec2.domain.MonitoringState;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.Attachment;
|
import org.jclouds.ec2.domain.Attachment;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.InstanceState;
|
import org.jclouds.ec2.domain.InstanceState;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
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(
|
.instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId(
|
||||||
"aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
"aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState(
|
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")
|
.virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal")
|
||||||
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType(
|
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType(
|
||||||
RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb"));
|
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(
|
.instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId(
|
||||||
"aki-ba3adfd3").keyName("example-key-name").launchTime(
|
"aki-ba3adfd3").keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
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(
|
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode(
|
||||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||||
.build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default")
|
.build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default")
|
||||||
|
@ -103,7 +102,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
||||||
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType(
|
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType(
|
||||||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
.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(
|
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode(
|
||||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||||
.build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d"));
|
.build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d"));
|
||||||
|
@ -123,7 +122,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
||||||
.instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId(
|
.instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId(
|
||||||
"aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime(
|
"aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime(
|
||||||
dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState(
|
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(
|
.placementGroup("placement").virtualizationType("hvm").privateDnsName(
|
||||||
"domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress(
|
"domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress(
|
||||||
"10.210.209.157").ramdiskId("ari-a51cf9cc")
|
"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.AWSRunningInstance;
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
|
||||||
import org.jclouds.ec2.domain.InstanceState;
|
import org.jclouds.ec2.domain.InstanceState;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.ec2.domain.Reservation;
|
import org.jclouds.ec2.domain.Reservation;
|
||||||
|
@ -86,19 +85,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
"ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
"ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
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(
|
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId(
|
||||||
"ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
"ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
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(
|
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId(
|
||||||
"ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
"ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
||||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
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");
|
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||||
|
|
||||||
|
|
|
@ -20,49 +20,36 @@
|
||||||
package org.jclouds.aws.s3;
|
package org.jclouds.aws.s3;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
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.AP_SOUTHEAST_1;
|
||||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
import static org.jclouds.aws.domain.Region.US_STANDARD;
|
||||||
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.domain.Region.US_WEST_1;
|
||||||
import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
|
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_REGION;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in S3 Clients
|
* Builds properties used in S3 Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder {
|
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
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG");
|
properties.putAll(Region.regionPropertiesS3());
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_STANDARD, Region.US_WEST_1, "EU",
|
|
||||||
Region.AP_SOUTHEAST_1));
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com");
|
properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ISO3166_CODES, "US");
|
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com");
|
||||||
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 + "." + "EU" + "." + ENDPOINT, "https://s3-eu-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 + "." + AP_SOUTHEAST_1 + "." + ENDPOINT,
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ENDPOINT,
|
"https://s3-ap-southeast-1.amazonaws.com");
|
||||||
"https://s3-ap-southeast-1.amazonaws.com");
|
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT,
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
|
"https://s3-ap-northeast-1.amazonaws.com");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest {
|
public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest {
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> getIso3166Codes() {
|
protected Set<String> getIso3166Codes() {
|
||||||
return ImmutableSet.<String> of("US", "US-CA", "IE", "SG");
|
return ImmutableSet.<String> of("US", "US-CA", "IE", "SG", "JP-13");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public interface CloudSigmaAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#destroyServer
|
* @see CloudSigmaClient#destroyServer
|
||||||
*/
|
*/
|
||||||
@POST
|
@GET
|
||||||
@Path("/servers/{uuid}/destroy")
|
@Path("/servers/{uuid}/destroy")
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
ListenableFuture<Void> destroyServer(@PathParam("uuid") String uuid);
|
ListenableFuture<Void> destroyServer(@PathParam("uuid") String uuid);
|
||||||
|
@ -247,7 +247,7 @@ public interface CloudSigmaAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#destroyDrive
|
* @see CloudSigmaClient#destroyDrive
|
||||||
*/
|
*/
|
||||||
@POST
|
@GET
|
||||||
@Path("/drives/{uuid}/destroy")
|
@Path("/drives/{uuid}/destroy")
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
ListenableFuture<Void> destroyDrive(@PathParam("uuid") String uuid);
|
ListenableFuture<Void> destroyDrive(@PathParam("uuid") String uuid);
|
||||||
|
@ -301,7 +301,7 @@ public interface CloudSigmaAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#destroyVLAN
|
* @see CloudSigmaClient#destroyVLAN
|
||||||
*/
|
*/
|
||||||
@POST
|
@GET
|
||||||
@Path("/resources/vlan/{uuid}/destroy")
|
@Path("/resources/vlan/{uuid}/destroy")
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
ListenableFuture<Void> destroyVLAN(@PathParam("uuid") String uuid);
|
ListenableFuture<Void> destroyVLAN(@PathParam("uuid") String uuid);
|
||||||
|
@ -343,7 +343,7 @@ public interface CloudSigmaAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#destroyStaticIP
|
* @see CloudSigmaClient#destroyStaticIP
|
||||||
*/
|
*/
|
||||||
@POST
|
@GET
|
||||||
@Path("/resources/ip/{uuid}/destroy")
|
@Path("/resources/ip/{uuid}/destroy")
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
ListenableFuture<Void> destroyStaticIP(@PathParam("uuid") String uuid);
|
ListenableFuture<Void> destroyStaticIP(@PathParam("uuid") String uuid);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.cloudsigma.util;
|
package org.jclouds.cloudsigma.util;
|
||||||
|
|
||||||
|
import org.jclouds.cloudsigma.CloudSigmaClient;
|
||||||
import org.jclouds.cloudsigma.domain.IDEDevice;
|
import org.jclouds.cloudsigma.domain.IDEDevice;
|
||||||
import org.jclouds.cloudsigma.domain.Model;
|
import org.jclouds.cloudsigma.domain.Model;
|
||||||
import org.jclouds.cloudsigma.domain.NIC;
|
import org.jclouds.cloudsigma.domain.NIC;
|
||||||
|
@ -69,4 +70,18 @@ public class Servers {
|
||||||
.vnc(new VNC(null, vncPassword, false));
|
.vnc(new VNC(null, vncPassword, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes the input server and changes its primary ip to a new address. To make this happen,
|
||||||
|
* you'll need to invoke {@link CloudSigmaClient#setServerConfiguration}
|
||||||
|
*
|
||||||
|
* @param in
|
||||||
|
* server to change
|
||||||
|
* @param ip
|
||||||
|
* new ip address
|
||||||
|
* @return server with its primary nic set to the new address.
|
||||||
|
*/
|
||||||
|
public static Server changeIP(Server in, String ip) {
|
||||||
|
return Server.Builder.fromServer(in).nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp(ip).build()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -323,7 +323,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class);
|
Method method = CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class);
|
Method method = CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class);
|
Method method = CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class);
|
Method method = CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
|
|
@ -283,10 +283,11 @@ public class CloudSigmaClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(dependsOnMethods = "testSetDriveData")
|
||||||
public void testCreateAndDestroyStaticIP() throws Exception {
|
public void testCreateAndDestroyStaticIP() throws Exception {
|
||||||
StaticIPInfo ip = client.createStaticIP();
|
StaticIPInfo ip = client.createStaticIP();
|
||||||
String id = ip.getAddress();
|
StaticIPInfo ip2 = client.createStaticIP();
|
||||||
|
Server server = null;
|
||||||
try {
|
try {
|
||||||
ip = client.getStaticIPInfo(ip.getAddress());
|
ip = client.getStaticIPInfo(ip.getAddress());
|
||||||
assertNotNull(ip);
|
assertNotNull(ip);
|
||||||
|
@ -299,16 +300,22 @@ public class CloudSigmaClientLiveTest {
|
||||||
Logger.getAnonymousLogger().info("starting server");
|
Logger.getAnonymousLogger().info("starting server");
|
||||||
server = client.createServer(serverRequest);
|
server = client.createServer(serverRequest);
|
||||||
assertEquals(server.getNics().get(0).getDhcp(), ip.getAddress());
|
assertEquals(server.getNics().get(0).getDhcp(), ip.getAddress());
|
||||||
|
client.stopServer(server.getUuid());
|
||||||
|
server = client.setServerConfiguration(server.getUuid(), Servers.changeIP(server, ip2.getAddress()));
|
||||||
|
assertEquals(server.getNics().get(0).getDhcp(), ip2.getAddress());
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyServer(server.getUuid());
|
if (server != null) {
|
||||||
client.destroyDrive(drive.getUuid());
|
client.destroyServer(server.getUuid());
|
||||||
client.destroyStaticIP(id);
|
client.destroyDrive(drive.getUuid());
|
||||||
|
}
|
||||||
|
client.destroyStaticIP(ip.getAddress());
|
||||||
|
client.destroyStaticIP(ip2.getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServerInfo server;
|
protected ServerInfo server;
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testSetDriveData")
|
@Test(dependsOnMethods = "testCreateAndDestroyStaticIP")
|
||||||
public void testCreateAndStartServer() throws Exception {
|
public void testCreateAndStartServer() throws Exception {
|
||||||
Logger.getAnonymousLogger().info("preparing drive");
|
Logger.getAnonymousLogger().info("preparing drive");
|
||||||
prepareDrive();
|
prepareDrive();
|
||||||
|
@ -422,16 +429,10 @@ public class CloudSigmaClientLiveTest {
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
try {
|
if (server != null)
|
||||||
client.destroyServer(server.getUuid());
|
client.destroyServer(server.getUuid());
|
||||||
} catch (Exception e) {
|
if (server != null)
|
||||||
// no need to check null or anything as we swallow all
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
client.destroyDrive(drive.getUuid());
|
client.destroyDrive(drive.getUuid());
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
if (context != null)
|
if (context != null)
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.jclouds.cloudstack;
|
||||||
import org.jclouds.cloudstack.features.AddressAsyncClient;
|
import org.jclouds.cloudstack.features.AddressAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GuestOSAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
|
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.NATAsyncClient;
|
import org.jclouds.cloudstack.features.NATAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
||||||
|
@ -107,4 +108,10 @@ public interface CloudStackAsyncClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
LoadBalancerAsyncClient getLoadBalancerClient();
|
LoadBalancerAsyncClient getLoadBalancerClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to GuestOS features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
GuestOSAsyncClient getGuestOSClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.cloudstack.features.AddressClient;
|
import org.jclouds.cloudstack.features.AddressClient;
|
||||||
import org.jclouds.cloudstack.features.AsyncJobClient;
|
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||||
import org.jclouds.cloudstack.features.FirewallClient;
|
import org.jclouds.cloudstack.features.FirewallClient;
|
||||||
|
import org.jclouds.cloudstack.features.GuestOSClient;
|
||||||
import org.jclouds.cloudstack.features.LoadBalancerClient;
|
import org.jclouds.cloudstack.features.LoadBalancerClient;
|
||||||
import org.jclouds.cloudstack.features.NATClient;
|
import org.jclouds.cloudstack.features.NATClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkClient;
|
import org.jclouds.cloudstack.features.NetworkClient;
|
||||||
|
@ -110,4 +111,10 @@ public interface CloudStackClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
LoadBalancerClient getLoadBalancerClient();
|
LoadBalancerClient getLoadBalancerClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to GuestOS features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
GuestOSClient getGuestOSClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.AsyncJobClient;
|
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||||
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.FirewallClient;
|
import org.jclouds.cloudstack.features.FirewallClient;
|
||||||
|
import org.jclouds.cloudstack.features.GuestOSAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GuestOSClient;
|
||||||
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
|
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.LoadBalancerClient;
|
import org.jclouds.cloudstack.features.LoadBalancerClient;
|
||||||
import org.jclouds.cloudstack.features.NATAsyncClient;
|
import org.jclouds.cloudstack.features.NATAsyncClient;
|
||||||
|
@ -53,6 +55,8 @@ import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||||
|
import org.jclouds.net.IPSocket;
|
||||||
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
|
|
||||||
|
@ -68,18 +72,19 @@ import com.google.common.collect.ImmutableMap;
|
||||||
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {
|
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {
|
||||||
|
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||||
.put(ZoneClient.class, ZoneAsyncClient.class)//
|
.put(ZoneClient.class, ZoneAsyncClient.class)//
|
||||||
.put(TemplateClient.class, TemplateAsyncClient.class)//
|
.put(TemplateClient.class, TemplateAsyncClient.class)//
|
||||||
.put(OfferingClient.class, OfferingAsyncClient.class)//
|
.put(OfferingClient.class, OfferingAsyncClient.class)//
|
||||||
.put(NetworkClient.class, NetworkAsyncClient.class)//
|
.put(NetworkClient.class, NetworkAsyncClient.class)//
|
||||||
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)//
|
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)//
|
||||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||||
.put(AsyncJobClient.class, AsyncJobAsyncClient.class)//
|
.put(AsyncJobClient.class, AsyncJobAsyncClient.class)//
|
||||||
.put(AddressClient.class, AddressAsyncClient.class)//
|
.put(AddressClient.class, AddressAsyncClient.class)//
|
||||||
.put(NATClient.class, NATAsyncClient.class)//
|
.put(NATClient.class, NATAsyncClient.class)//
|
||||||
.put(FirewallClient.class, FirewallAsyncClient.class)//
|
.put(FirewallClient.class, FirewallAsyncClient.class)//
|
||||||
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
|
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
|
||||||
.build();
|
.put(GuestOSClient.class, GuestOSAsyncClient.class)//
|
||||||
|
.build();
|
||||||
|
|
||||||
public CloudStackRestClientModule() {
|
public CloudStackRestClientModule() {
|
||||||
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
||||||
|
@ -88,6 +93,14 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||||
|
bind(SocketOpen.class).toInstance(new SocketOpen() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(IPSocket arg0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.domain;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class OSType implements Comparable<OSType> {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private long id;
|
||||||
|
private long OSCategoryId;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Builder id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder OSCategoryId(long OSCategoryId) {
|
||||||
|
this.OSCategoryId = OSCategoryId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OSType build() {
|
||||||
|
return new OSType(id, OSCategoryId, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for deserialization
|
||||||
|
OSType() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
@SerializedName("oscategoryid")
|
||||||
|
private long OSCategoryId;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public OSType(long id, long OSCategoryId, String description) {
|
||||||
|
this.id = id;
|
||||||
|
this.OSCategoryId = OSCategoryId;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ID of the OS type
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ID of the OS category
|
||||||
|
*/
|
||||||
|
public long getOSCategoryId() {
|
||||||
|
return OSCategoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name/description of the OS type
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (int) (OSCategoryId ^ (OSCategoryId >>> 32));
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + (int) (id ^ (id >>> 32));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
OSType other = (OSType) obj;
|
||||||
|
if (OSCategoryId != other.OSCategoryId)
|
||||||
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (id != other.id)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", OSCategoryId=" + OSCategoryId + ", description=" + description + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(OSType arg0) {
|
||||||
|
return new Long(id).compareTo(arg0.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.OSType;
|
||||||
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.Unwrap;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to cloudstack via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see AsyncJobClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2.0/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(QuerySigner.class)
|
||||||
|
@QueryParams(keys = "response", values = "json")
|
||||||
|
public interface GuestOSAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see GuestOSClient#listOSTypes
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listOsTypes")
|
||||||
|
@Unwrap(depth = 2)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<OSType>> listOSTypes(ListOSTypesOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OSTypeClient#getOSType
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listOsTypes")
|
||||||
|
@Unwrap(depth = 3, edgeCollection = Set.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<OSType> getOSType(@QueryParam("id") long id);
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.OSType;
|
||||||
|
import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to CloudStack Operating System features.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see GuestOSAsyncClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2.0/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface GuestOSClient {
|
||||||
|
/**
|
||||||
|
* Lists all supported OS types for this cloud.
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* if present, how to constrain the list
|
||||||
|
* @return os types matching query, or empty set, if no types are found
|
||||||
|
*/
|
||||||
|
Set<OSType> listOSTypes(ListOSTypesOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a specific os type by id
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* os type to get
|
||||||
|
* @return os type or null if not found
|
||||||
|
*/
|
||||||
|
OSType getOSType(long id);
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.options;
|
||||||
|
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what OSType information is returned
|
||||||
|
*
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listOsTypes.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ListOSTypesOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final ListOSTypesOptions NONE = new ListOSTypesOptions();
|
||||||
|
/**
|
||||||
|
* @param id list by Os type Id
|
||||||
|
*/
|
||||||
|
public ListOSTypesOptions id(long id) {
|
||||||
|
this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param OSCategoryId
|
||||||
|
* list by Os Category id
|
||||||
|
*/
|
||||||
|
public ListOSTypesOptions OSCategoryId(long OSCategoryId) {
|
||||||
|
this.queryParameters.replaceValues("oscategoryid", ImmutableSet.of(OSCategoryId + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* @see ListOSTypesOptions#id
|
||||||
|
*/
|
||||||
|
public static ListOSTypesOptions id(long id) {
|
||||||
|
ListOSTypesOptions options = new ListOSTypesOptions();
|
||||||
|
return options.id(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListOSTypesOptions#OSCategoryId
|
||||||
|
*/
|
||||||
|
public static ListOSTypesOptions OSCategoryId(long id) {
|
||||||
|
ListOSTypesOptions options = new ListOSTypesOptions();
|
||||||
|
return options.OSCategoryId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.features;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code GuestOSAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "GuestOSAsyncClientTest")
|
||||||
|
public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestOSAsyncClient> {
|
||||||
|
|
||||||
|
public void testGetOSType() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = GuestOSAsyncClient.class.getMethod("getOSType", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 11l);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&id=11 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListOSTypes() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listOsTypes HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListOSTypesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, ListOSTypesOptions.Builder.OSCategoryId(11));
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&oscategoryid=11 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<GuestOSAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<GuestOSAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.features;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.OSType;
|
||||||
|
import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code GuestOSClientLiveTest}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "GuestOSClientLiveTest")
|
||||||
|
public class GuestOSClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
public void testListOSTypes() throws Exception {
|
||||||
|
Set<OSType> response = client.getGuestOSClient().listOSTypes();
|
||||||
|
assert null != response;
|
||||||
|
assertTrue(response.size() >= 0);
|
||||||
|
for (OSType type : response) {
|
||||||
|
OSType newDetails = getOnlyElement(client.getGuestOSClient().listOSTypes(
|
||||||
|
ListOSTypesOptions.Builder.id(type.getId())));
|
||||||
|
assertEquals(type.getId(), newDetails.getId());
|
||||||
|
checkIP(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkIP(OSType type) {
|
||||||
|
assertEquals(type.getId(), client.getGuestOSClient().getOSType(type.getId()).getId());
|
||||||
|
assert type.getId() > 0 : type;
|
||||||
|
assert type.getOSCategoryId() > 0 : type;
|
||||||
|
assert type.getDescription() != null : type;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.cloudstack.options;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.ListOSTypesOptions.Builder.OSCategoryId;
|
||||||
|
import static org.jclouds.cloudstack.options.ListOSTypesOptions.Builder.id;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ListOSTypesOptions}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListOSTypesOptionsTest {
|
||||||
|
|
||||||
|
public void testId() {
|
||||||
|
ListOSTypesOptions options = new ListOSTypesOptions().id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIdStatic() {
|
||||||
|
ListOSTypesOptions options = id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOSCategoryId() {
|
||||||
|
ListOSTypesOptions options = new ListOSTypesOptions().OSCategoryId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("oscategoryid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOSCategoryIdStatic() {
|
||||||
|
ListOSTypesOptions options = OSCategoryId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("oscategoryid"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,12 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.16</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
|
@ -18,44 +18,43 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.cloudwatch;
|
package org.jclouds.cloudwatch;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
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_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_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_REGION;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in Cloud Watch Clients
|
* Builds properties used in Cloud Watch Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
|
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
|
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
properties.putAll(Region.regionProperties());
|
||||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
properties.setProperty(PROPERTY_ENDPOINT, "https://monitoring.us-east-1.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT,
|
|
||||||
"https://monitoring.us-east-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
|
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",
|
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",
|
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",
|
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;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,10 +56,9 @@ public class CloudWatchClientLiveTest {
|
||||||
protected void setupCredentials() {
|
protected void setupCredentials() {
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||||
+ ".credential");
|
+ ".credential");
|
||||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
endpoint = System.getProperty("test." + provider + ".endpoint", null);
|
||||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
apiversion = System.getProperty("test." + provider + ".apiversion", null);
|
||||||
+ ".apiversion");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
|
@ -69,8 +67,10 @@ public class CloudWatchClientLiveTest {
|
||||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
overrides.setProperty(provider + ".identity", identity);
|
overrides.setProperty(provider + ".identity", identity);
|
||||||
overrides.setProperty(provider + ".credential", credential);
|
overrides.setProperty(provider + ".credential", credential);
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
if (endpoint != null)
|
||||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||||
|
if (apiversion != null)
|
||||||
|
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class CloudWatchClientLiveTest {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||||
overrides);
|
overrides);
|
||||||
client = context.getApi();
|
client = context.getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +87,7 @@ public class CloudWatchClientLiveTest {
|
||||||
void testGetMetricStatisticsInRegion() {
|
void testGetMetricStatisticsInRegion() {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.MINUTE, -1);
|
cal.add(Calendar.MINUTE, -1);
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null;
|
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");
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
request,
|
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);
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -180,9 +180,19 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
|
||||||
|
|
||||||
protected String provider = "elb";
|
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
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public RestContextSpec<?, ?> createContextSpec() {
|
||||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||||
|
new Properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.Constants.PROPERTY_ENDPOINT;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_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 java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in SQS Clients
|
* Builds properties used in SQS Clients
|
||||||
|
@ -45,17 +40,7 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION);
|
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_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;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.sqs;
|
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 static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -31,7 +29,6 @@ import java.util.Properties;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -48,7 +45,6 @@ import org.jclouds.sqs.xml.RegexListQueuesResponseHandler;
|
||||||
import org.jclouds.sqs.xml.RegexQueueHandler;
|
import org.jclouds.sqs.xml.RegexQueueHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -145,14 +141,6 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
|
||||||
checkFilters(request);
|
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
|
@Override
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
assertEquals(request.getFilters().size(), 1);
|
assertEquals(request.getFilters().size(), 1);
|
||||||
|
@ -172,9 +160,19 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
|
||||||
|
|
||||||
protected String provider = "sqs";
|
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
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
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.Constants;
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.crypto.CryptoStreams;
|
import org.jclouds.crypto.CryptoStreams;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
@ -42,7 +41,6 @@ import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -97,60 +95,61 @@ public class SQSClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testListQueuesInRegion() throws InterruptedException {
|
protected void testListQueues() throws InterruptedException {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
listQueuesInRegion(null);
|
||||||
Region.AP_SOUTHEAST_1)) {
|
}
|
||||||
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
|
|
||||||
assertNotNull(allResults);
|
protected void listQueuesInRegion(String region) throws InterruptedException {
|
||||||
if (allResults.size() >= 1) {
|
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
|
||||||
Queue queue = allResults.last();
|
assertNotNull(allResults);
|
||||||
assertQueueInList(region, queue);
|
if (allResults.size() >= 1) {
|
||||||
}
|
Queue queue = allResults.last();
|
||||||
|
assertQueueInList(region, queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-sqs";
|
public static final String PREFIX = System.getProperty("user.name") + "-sqs";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateQueue() throws InterruptedException {
|
protected void testCreateQueue() throws InterruptedException {
|
||||||
String queueName = PREFIX + "1";
|
createQueueInRegion(null, PREFIX + "1");
|
||||||
|
}
|
||||||
|
|
||||||
for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
public String createQueueInRegion(final String region, String queueName) throws InterruptedException {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
try {
|
||||||
try {
|
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName)));
|
||||||
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName)));
|
if (result.size() >= 1) {
|
||||||
if (result.size() >= 1) {
|
client.deleteQueue(result.last());
|
||||||
client.deleteQueue(result.last());
|
queueName += 1;// cannot recreate a queue within 60 seconds
|
||||||
queueName += 1;// cannot recreate a queue within 60 seconds
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
} 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")
|
@Test(dependsOnMethods = "testCreateQueue")
|
||||||
void testSendMessage() throws InterruptedException, IOException {
|
protected void testSendMessage() throws InterruptedException, IOException {
|
||||||
String message = "hardyharhar";
|
String message = "hardyharhar";
|
||||||
byte[] md5 = CryptoStreams.md5(message.getBytes());
|
byte[] md5 = CryptoStreams.md5(message.getBytes());
|
||||||
for (Queue queue : queues) {
|
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>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.provider</groupId>
|
||||||
|
<artifactId>aws-ec2</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<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_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
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.AP_SOUTHEAST_1;
|
||||||
import static org.jclouds.aws.domain.Region.EU_WEST_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_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_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT;
|
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_REGION;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.elb.ELBAsyncClient;
|
import org.jclouds.elb.ELBAsyncClient;
|
||||||
import org.jclouds.elb.ELBPropertiesBuilder;
|
import org.jclouds.elb.ELBPropertiesBuilder;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in ELB Clients
|
* Builds properties used in ELB Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder {
|
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
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
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_API_VERSION, ELBAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
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");
|
"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");
|
"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");
|
"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");
|
"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");
|
properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.aws.elb;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.elb.ELBClientLiveTest;
|
import org.jclouds.elb.ELBClientLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -35,21 +36,21 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateLoadBalancer() {
|
public void testCreateLoadBalancer() {
|
||||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
createLoadBalancerInRegionZone(region, region + "a", name);
|
createLoadBalancerInRegionZone(region, region + "a", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testDescribeLoadBalancers() {
|
public void testDescribeLoadBalancers() {
|
||||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
describeLoadBalancerInRegion(region);
|
describeLoadBalancerInRegion(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteLoadBalancer() {
|
public void testDeleteLoadBalancer() {
|
||||||
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
deleteLoadBalancerInRegion(region);
|
deleteLoadBalancerInRegion(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.aws.elb;
|
||||||
|
|
||||||
import static org.jclouds.aws.elb.AWSELBPropertiesBuilder.DEFAULT_REGIONS;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.elb.ELBAsyncClient;
|
import org.jclouds.elb.ELBAsyncClient;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,9 +41,14 @@ public class ELBAsyncClientTest extends org.jclouds.elb.ELBAsyncClientTest {
|
||||||
this.provider = "aws-elb";
|
this.provider = "aws-elb";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Properties getProperties() {
|
||||||
|
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class);
|
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);
|
processor.createRequest(method, region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,51 +20,49 @@
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.aws.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
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.AP_SOUTHEAST_1;
|
||||||
import static org.jclouds.aws.domain.Region.EU_WEST_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_EAST_1;
|
||||||
import static org.jclouds.aws.domain.Region.US_WEST_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.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
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.Properties;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in SimpleDB Clients
|
* Builds properties used in SimpleDB Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder {
|
public class AWSSimpleDBPropertiesBuilder 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);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
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_ENDPOINT, "https://sdb.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com");
|
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
|
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
|
||||||
"https://sdb.us-west-1.amazonaws.com");
|
"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");
|
"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");
|
"https://sdb.ap-southeast-1.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
|
||||||
|
"https://sdb.ap-northeast-1.amazonaws.com");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleDBPropertiesBuilder() {
|
public AWSSimpleDBPropertiesBuilder() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleDBPropertiesBuilder(Properties properties) {
|
public AWSSimpleDBPropertiesBuilder(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.aws.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
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.SimpleDBAsyncClient;
|
||||||
|
import org.jclouds.simpledb.SimpleDBAsyncClientTest;
|
||||||
import org.testng.annotations.Test;
|
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
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "aws.SimpleDBAsyncClientTest")
|
@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";
|
this.provider = "aws-simpledb";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO fix this test as it has the wrong arg count
|
@Override
|
||||||
@Test(enabled = false)
|
protected Properties getProperties() {
|
||||||
|
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class);
|
Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class);
|
||||||
for (String region : DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
processor.createRequest(method, region, "domainName");
|
processor.createRequest(method, region, "domainName");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
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.jclouds.simpledb.SimpleDBClientLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void testListDomainsInRegion() throws InterruptedException {
|
void testListDomainsInRegion() throws InterruptedException {
|
||||||
for (String region : DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
listDomainInRegion(region);
|
listDomainInRegion(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,8 +43,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
|
||||||
@Test
|
@Test
|
||||||
void testCreateDomainInRegions() throws InterruptedException {
|
void testCreateDomainInRegions() throws InterruptedException {
|
||||||
String domainName = PREFIX + "1";
|
String domainName = PREFIX + "1";
|
||||||
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
for (String region : DEFAULT_REGIONS) {
|
|
||||||
domainName = createDomainInRegion(region, domainName);
|
domainName = createDomainInRegion(region, domainName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<test.initializer>org.jclouds.ninefold.storage.blobstore.integration.NinefoldStorageTestInitializer</test.initializer>
|
<test.initializer>org.jclouds.ninefold.storage.blobstore.integration.NinefoldStorageTestInitializer</test.initializer>
|
||||||
<test.ninefold-storage.endpoint>http://onlinestorage.ninefold.com</test.ninefold-storage.endpoint>
|
<test.ninefold-storage.endpoint>http://onlinestorage.ninefold.com</test.ninefold-storage.endpoint>
|
||||||
<test.ninefold-storage.apiversion>1.2.7c</test.ninefold-storage.apiversion>
|
<test.ninefold-storage.apiversion>1.4.0</test.ninefold-storage.apiversion>
|
||||||
<test.ninefold-storage.identity>FIXME_IDENTITY</test.ninefold-storage.identity>
|
<test.ninefold-storage.identity>FIXME_IDENTITY</test.ninefold-storage.identity>
|
||||||
<test.ninefold-storage.credential>FIXME_CREDENTIAL</test.ninefold-storage.credential>
|
<test.ninefold-storage.credential>FIXME_CREDENTIAL</test.ninefold-storage.credential>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class NinefoldStoragePropertiesBuilder extends PropertiesBuilder {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "http://onlinestorage.ninefold.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "http://onlinestorage.ninefold.com");
|
||||||
properties.setProperty(PROPERTY_ISO3166_CODES, "AU-NSW");
|
properties.setProperty(PROPERTY_ISO3166_CODES, "AU-NSW");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1.2.7C");
|
properties.setProperty(PROPERTY_API_VERSION, "1.4.0");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.provider</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>savvis</artifactId>
|
<artifactId>savvis-symphony-vpdc</artifactId>
|
||||||
<name>jclouds savvis core</name>
|
<name>jclouds savvis core</name>
|
||||||
<description>jclouds components to access savvis</description>
|
<description>jclouds components to access savvis</description>
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>jclouds-vcloud</artifactId>
|
<artifactId>vcloudexpress</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>vcloudexpress</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
@ -84,6 +84,13 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-jsch</artifactId>
|
<artifactId>jclouds-jsch</artifactId>
|
|
@ -0,0 +1,144 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler;
|
||||||
|
import org.jclouds.vcloud.CommonVCloudClient;
|
||||||
|
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||||
|
import org.jclouds.vcloud.domain.Org;
|
||||||
|
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
||||||
|
import org.jclouds.vcloud.domain.VDC;
|
||||||
|
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||||
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||||
|
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||||
|
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||||
|
import org.jclouds.vcloud.xml.OrgHandler;
|
||||||
|
import org.jclouds.vcloud.xml.VDCHandler;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Symphony VPDC resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="TODO PUBLIC DOC REF" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
|
public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
// savvis doesn't work with accept header
|
||||||
|
@Override
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(OrgHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends Org> findOrgNamed(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
// savvis doesn't work with accept header
|
||||||
|
@Override
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(OrgHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommonVCloudClient#getVDC(URI)
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(VDCHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommonVCloudClient#findVDCInOrgNamed(String, String)
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(VDCHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends VDC> findVDCInOrgNamed(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommonVCloudClient#findNetworkInOrgVDCNamed
|
||||||
|
*//*
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||||
|
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||||
|
|
||||||
|
*//**
|
||||||
|
* @see CommonVCloudClient#getNetwork
|
||||||
|
*//*
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommonVCloudClient#findNetworkInOrgVDCNamed
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(SymphonyVPDCNetworkHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||||
|
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommonVCloudClient#getNetwork
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(SymphonyVPDCNetworkHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VCloudClient#getVApp
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(SymphonyVPDCVAppHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends VCloudExpressVApp> getVApp(@EndpointParam URI vApp);
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.savvis.compute.config.SymphonyVPDCComputeServiceContextModule;
|
import org.jclouds.savvis.vpdc.compute.config.SymphonyVPDCComputeServiceContextModule;
|
||||||
import org.jclouds.savvis.config.SymphonyVPDCRestClientModule;
|
import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.compute.config;
|
package org.jclouds.savvis.vpdc.compute.config;
|
||||||
|
|
||||||
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
|
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.config;
|
package org.jclouds.savvis.vpdc.config;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -25,12 +27,13 @@ import org.jclouds.http.HttpErrorHandler;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
import org.jclouds.savvis.SymphonyVPDCAsyncClient;
|
import org.jclouds.savvis.vpdc.SymphonyVPDCAsyncClient;
|
||||||
import org.jclouds.savvis.SymphonyVPDCClient;
|
import org.jclouds.savvis.vpdc.SymphonyVPDCClient;
|
||||||
import org.jclouds.savvis.handlers.SymphonyVPDCErrorHandler;
|
import org.jclouds.savvis.vpdc.handlers.SymphonyVPDCErrorHandler;
|
||||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudExpressClient;
|
import org.jclouds.vcloud.VCloudExpressClient;
|
||||||
import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule;
|
import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule;
|
||||||
|
import org.jclouds.vcloud.domain.Org;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
@ -52,7 +55,15 @@ public class SymphonyVPDCRestClientModule extends
|
||||||
protected VCloudExpressClient provideVCloudClient(SymphonyVPDCClient in) {
|
protected VCloudExpressClient provideVCloudClient(SymphonyVPDCClient in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected URI provideDefaultTasksList(Org org) {
|
||||||
|
if(org.getTasksList() != null){
|
||||||
|
return org.getTasksList().getHref();
|
||||||
|
}else{
|
||||||
|
return URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||||
|
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||||
|
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* A network that is available in a vDC.
|
||||||
|
*
|
||||||
|
* @author Kedar Dave
|
||||||
|
*/
|
||||||
|
public interface SymphonyVPDCNetwork extends ReferenceType {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Description of the network
|
||||||
|
*/
|
||||||
|
String getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IP addresses of the network’s DNS servers.
|
||||||
|
*/
|
||||||
|
Set<String> getDnsServers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return The IP address of the network’s primary gateway
|
||||||
|
*/
|
||||||
|
String getGateway();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *
|
||||||
|
*
|
||||||
|
* @return the network’s subnet mask
|
||||||
|
*/
|
||||||
|
String getNetmask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the network’s fence modes.
|
||||||
|
*/
|
||||||
|
Set<FenceMode> getFenceModes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return True if the network provides DHCP services
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Boolean isDhcp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Network Address Translation rules for the network
|
||||||
|
*/
|
||||||
|
Set<PortForwardingRule> getNatRules();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Firewall rules for the network
|
||||||
|
*/
|
||||||
|
Set<FirewallRule> getFirewallRules();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,205 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc.domain.internal;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork;
|
||||||
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||||
|
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||||
|
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||||
|
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locations of resources in vCloud
|
||||||
|
*
|
||||||
|
* @author Kedar Dave
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SymphonyVPDCNetworkImpl extends ReferenceTypeImpl implements SymphonyVPDCNetwork {
|
||||||
|
|
||||||
|
/** The serialVersionUID */
|
||||||
|
private static final long serialVersionUID = 8464716396538298809L;
|
||||||
|
protected final String description;
|
||||||
|
protected final Set<String> dnsServers = Sets.newHashSet();
|
||||||
|
protected final String gateway;
|
||||||
|
protected final String netmask;
|
||||||
|
protected final Set<FenceMode> fenceModes = Sets.newHashSet();
|
||||||
|
@Nullable
|
||||||
|
protected final Boolean dhcp;
|
||||||
|
protected final Set<PortForwardingRule> natRules = Sets.newHashSet();
|
||||||
|
protected final Set<FirewallRule> firewallRules = Sets.newHashSet();
|
||||||
|
|
||||||
|
public SymphonyVPDCNetworkImpl(String name, String type, URI id, String description, Set<String> dnsServers,
|
||||||
|
String gateway, String netmask, Set<FenceMode> fenceModes, Boolean dhcp, Set<PortForwardingRule> natRules,
|
||||||
|
Set<FirewallRule> firewallRules) {
|
||||||
|
super(name, type, id);
|
||||||
|
this.description = description;
|
||||||
|
this.dnsServers.addAll(dnsServers);
|
||||||
|
this.gateway = gateway;
|
||||||
|
this.netmask = netmask;
|
||||||
|
this.fenceModes.addAll(fenceModes);
|
||||||
|
this.dhcp = dhcp;
|
||||||
|
this.natRules.addAll(natRules);
|
||||||
|
this.firewallRules.addAll(firewallRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<String> getDnsServers() {
|
||||||
|
return dnsServers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getGateway() {
|
||||||
|
return gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getNetmask() {
|
||||||
|
return netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<FenceMode> getFenceModes() {
|
||||||
|
return fenceModes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Boolean isDhcp() {
|
||||||
|
return dhcp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<PortForwardingRule> getNatRules() {
|
||||||
|
return natRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<FirewallRule> getFirewallRules() {
|
||||||
|
return firewallRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(ReferenceType o) {
|
||||||
|
return (this == o) ? 0 : getHref().compareTo(o.getHref());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
|
||||||
|
result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode());
|
||||||
|
result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode());
|
||||||
|
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
|
||||||
|
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
||||||
|
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
|
||||||
|
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SymphonyVPDCNetworkImpl other = (SymphonyVPDCNetworkImpl) obj;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (dhcp == null) {
|
||||||
|
if (other.dhcp != null)
|
||||||
|
return false;
|
||||||
|
} else if (!dhcp.equals(other.dhcp))
|
||||||
|
return false;
|
||||||
|
if (dnsServers == null) {
|
||||||
|
if (other.dnsServers != null)
|
||||||
|
return false;
|
||||||
|
} else if (!dnsServers.equals(other.dnsServers))
|
||||||
|
return false;
|
||||||
|
if (fenceModes == null) {
|
||||||
|
if (other.fenceModes != null)
|
||||||
|
return false;
|
||||||
|
} else if (!fenceModes.equals(other.fenceModes))
|
||||||
|
return false;
|
||||||
|
if (firewallRules == null) {
|
||||||
|
if (other.firewallRules != null)
|
||||||
|
return false;
|
||||||
|
} else if (!firewallRules.equals(other.firewallRules))
|
||||||
|
return false;
|
||||||
|
if (gateway == null) {
|
||||||
|
if (other.gateway != null)
|
||||||
|
return false;
|
||||||
|
} else if (!gateway.equals(other.gateway))
|
||||||
|
return false;
|
||||||
|
if (natRules == null) {
|
||||||
|
if (other.natRules != null)
|
||||||
|
return false;
|
||||||
|
} else if (!natRules.equals(other.natRules))
|
||||||
|
return false;
|
||||||
|
if (netmask == null) {
|
||||||
|
if (other.netmask != null)
|
||||||
|
return false;
|
||||||
|
} else if (!netmask.equals(other.netmask))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description
|
||||||
|
+ ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules="
|
||||||
|
+ firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask=" + netmask + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.handlers;
|
package org.jclouds.savvis.vpdc.handlers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCNetworkImpl;
|
||||||
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||||
|
import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
|
||||||
|
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||||
|
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
||||||
|
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kedar Dave
|
||||||
|
*/
|
||||||
|
public class SymphonyVPDCNetworkHandler extends ParseSax.HandlerWithResult<SymphonyVPDCNetwork>{
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private ReferenceType ips;
|
||||||
|
private ReferenceType extension;
|
||||||
|
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected ReferenceType network;
|
||||||
|
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
protected Set<String> dnsServers = Sets.newLinkedHashSet();
|
||||||
|
protected String gateway;
|
||||||
|
protected String netmask;
|
||||||
|
protected Set<FenceMode> fenceModes = Sets.newLinkedHashSet();
|
||||||
|
protected Boolean dhcp;
|
||||||
|
protected Set<PortForwardingRule> natRules = Sets.newLinkedHashSet();
|
||||||
|
protected Set<FirewallRule> firewallRules = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
protected String externalIP;
|
||||||
|
protected Integer externalPort;
|
||||||
|
protected String internalIP;
|
||||||
|
protected Integer internalPort;
|
||||||
|
|
||||||
|
protected FirewallPolicy policy;
|
||||||
|
protected String sourceIP;
|
||||||
|
protected int sourcePort;
|
||||||
|
|
||||||
|
public SymphonyVPDCNetwork getResult() {
|
||||||
|
return new SymphonyVPDCNetworkImpl(network.getName(), network.getType(), network.getHref(), description,
|
||||||
|
dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Network")) {
|
||||||
|
network = newReferenceType(attributes);
|
||||||
|
} else if (qName.endsWith("Link")) {
|
||||||
|
if ("IP Addresses".equals(attributes.get("name"))) {
|
||||||
|
ips = newReferenceType(attributes);
|
||||||
|
} else if ("down".equals(attributes.get("rel"))) {
|
||||||
|
extension = newReferenceType(attributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.equals("Description")) {
|
||||||
|
description = currentOrNull();
|
||||||
|
} else if (qName.equals("Dns")) {
|
||||||
|
dnsServers.add(currentOrNull());
|
||||||
|
} else if (qName.equals("Gateway")) {
|
||||||
|
gateway = currentOrNull();
|
||||||
|
} else if (qName.equals("Netmask")) {
|
||||||
|
netmask = currentOrNull();
|
||||||
|
} else if (qName.equals("FenceMode")) {
|
||||||
|
try {
|
||||||
|
fenceModes.add(FenceMode.fromValue(currentOrNull()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
fenceModes.add(FenceMode.BRIDGED);
|
||||||
|
}
|
||||||
|
} else if (qName.equals("Dhcp")) {
|
||||||
|
dhcp = new Boolean(currentOrNull());
|
||||||
|
} else if (qName.equals("NatRule")) {
|
||||||
|
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP));
|
||||||
|
externalIP = null;
|
||||||
|
externalPort = null;
|
||||||
|
internalIP = null;
|
||||||
|
internalPort = null;
|
||||||
|
} else if (qName.equals("ExternalIP")) {
|
||||||
|
externalIP = currentOrNull();
|
||||||
|
} else if (qName.equals("ExternalPort")) {
|
||||||
|
externalPort = Integer.parseInt(currentOrNull());
|
||||||
|
} else if (qName.equals("InternalIP")) {
|
||||||
|
internalIP = currentOrNull();
|
||||||
|
} else if (qName.equals("InternalPort")) {
|
||||||
|
internalPort = Integer.parseInt(currentOrNull());
|
||||||
|
} else if (qName.equals("FirewallRule")) {
|
||||||
|
firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP));
|
||||||
|
policy = null;
|
||||||
|
sourceIP = null;
|
||||||
|
sourcePort = -1;
|
||||||
|
} else if (qName.equals("Policy")) {
|
||||||
|
policy = FirewallPolicy.fromValue(currentOrNull());
|
||||||
|
} else if (qName.equals("SourceIp")) {
|
||||||
|
sourceIP = currentOrNull();
|
||||||
|
} else if (qName.equals("SourcePort")) {
|
||||||
|
sourcePort = Integer.parseInt(currentOrNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String currentOrNull() {
|
||||||
|
String returnVal = currentText.toString().trim();
|
||||||
|
return returnVal.equals("") ? null : returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
|
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||||
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.Status;
|
||||||
|
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
||||||
|
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
||||||
|
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||||
|
import org.jclouds.vcloud.domain.ovf.System;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.ListMultimap;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kedar Dave
|
||||||
|
*/
|
||||||
|
public class SymphonyVPDCVAppHandler extends ParseSax.HandlerWithResult<VCloudExpressVApp> {
|
||||||
|
private final String apiVersion;
|
||||||
|
private final SystemHandler systemHandler;
|
||||||
|
private final ResourceAllocationHandler allocationHandler;
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SymphonyVPDCVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler,
|
||||||
|
ResourceAllocationHandler allocationHandler) {
|
||||||
|
this.apiVersion = apiVersion;
|
||||||
|
this.systemHandler = systemHandler;
|
||||||
|
this.allocationHandler = allocationHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected System system;
|
||||||
|
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
|
||||||
|
protected Status status;
|
||||||
|
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
protected String operatingSystemDescription;
|
||||||
|
protected boolean inOs;
|
||||||
|
protected String networkName;
|
||||||
|
protected String name;
|
||||||
|
protected Integer osType;
|
||||||
|
protected URI location;
|
||||||
|
protected Long size;
|
||||||
|
protected ReferenceType vDC;
|
||||||
|
|
||||||
|
public VCloudExpressVApp getResult() {
|
||||||
|
return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType,
|
||||||
|
operatingSystemDescription, system, allocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("VApp")) {
|
||||||
|
ReferenceType resource = newReferenceType(attributes);
|
||||||
|
name = resource.getName();
|
||||||
|
location = resource.getHref();
|
||||||
|
String statusString = attributes.get("status");
|
||||||
|
if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString))
|
||||||
|
status = Status.OFF;
|
||||||
|
else
|
||||||
|
status = Status.fromValue(statusString);
|
||||||
|
if (attributes.containsKey("size"))
|
||||||
|
size = new Long(attributes.get("size"));
|
||||||
|
} else if (qName.equals("Link")) { // type should never be missing
|
||||||
|
if (attributes.containsKey("type") && attributes.get("type").equals(VCloudExpressMediaType.VDC_XML)) {
|
||||||
|
vDC = newReferenceType(attributes);
|
||||||
|
}
|
||||||
|
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
inOs = true;
|
||||||
|
if (attributes.containsKey("id"))
|
||||||
|
osType = Integer.parseInt(attributes.get("id"));
|
||||||
|
} else if (qName.endsWith("NetworkConnection")) {
|
||||||
|
networkName = attributes.get("Network");
|
||||||
|
} else {
|
||||||
|
systemHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
allocationHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
|
if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
inOs = false;
|
||||||
|
} else if (inOs && qName.endsWith("Description")) {
|
||||||
|
operatingSystemDescription = currentText.toString().trim();
|
||||||
|
} else if (qName.endsWith("IpAddress")) {
|
||||||
|
networkToAddresses.put(networkName, currentText.toString().trim());
|
||||||
|
} else if (qName.equals("System")) {
|
||||||
|
systemHandler.endElement(uri, localName, qName);
|
||||||
|
system = systemHandler.getResult();
|
||||||
|
} else if (qName.equals("Item")) {
|
||||||
|
allocationHandler.endElement(uri, localName, qName);
|
||||||
|
allocations.add(allocationHandler.getResult());
|
||||||
|
} else {
|
||||||
|
systemHandler.endElement(uri, localName, qName);
|
||||||
|
allocationHandler.endElement(uri, localName, qName);
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
systemHandler.characters(ch, start, length);
|
||||||
|
allocationHandler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||||
|
@ -47,11 +47,15 @@ import org.jclouds.rest.RestContextSpec;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.savvis.config.SymphonyVPDCRestClientModule;
|
import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.jclouds.vcloud.CommonVCloudClient;
|
import org.jclouds.vcloud.CommonVCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||||
|
import org.jclouds.vcloud.VCloudExpressLoginAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||||
|
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
@ -69,7 +73,6 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
import org.jclouds.vcloud.xml.OrgHandler;
|
||||||
import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler;
|
|
||||||
import org.jclouds.vcloud.xml.TaskHandler;
|
import org.jclouds.vcloud.xml.TaskHandler;
|
||||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||||
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
||||||
|
@ -85,9 +88,6 @@ import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
import domain.VCloudExpressLoginAsyncClient;
|
|
||||||
import domain.VCloudVersionsAsyncClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests annotation parsing of {@code SymphonyVPDCAsyncClient}
|
* Tests annotation parsing of {@code SymphonyVPDCAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -137,10 +137,9 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(request,
|
||||||
request,
|
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml"))
|
||||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml")).replace(
|
.replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
||||||
"vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
|
||||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -284,11 +283,11 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2 HTTP/1.1");
|
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, OrgNetworkFromVCloudExpressNetworkHandler.class);
|
assertSaxResponseParserClassEquals(method, SymphonyVPDCNetworkHandler.class);
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
|
@ -367,7 +366,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
HttpRequest request = processor.createRequest(method, "org", "vdc");
|
HttpRequest request = processor.createRequest(method, "org", "vdc");
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -394,7 +393,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
HttpRequest request = processor.createRequest(method, null, "vdc");
|
HttpRequest request = processor.createRequest(method, null, "vdc");
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -409,7 +408,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
HttpRequest request = processor.createRequest(method, null, null);
|
HttpRequest request = processor.createRequest(method, null, null);
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -425,7 +424,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"));
|
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -453,7 +452,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
|
Method method = VCloudExpressAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
|
||||||
HttpRequest request = processor.createRequest(method, "org");
|
HttpRequest request = processor.createRequest(method, "org");
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
|
@ -491,11 +490,11 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class);
|
assertSaxResponseParserClassEquals(method, SymphonyVPDCVAppHandler.class);
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
|
@ -673,10 +672,9 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public RestContextSpec<?, ?> createContextSpec() {
|
||||||
Properties restProperties = new Properties();
|
Properties restProperties = new Properties();
|
||||||
restProperties
|
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
||||||
.setProperty("savvis-symphony-vpdc.contextbuilder", "org.jclouds.savvis.SymphonyVPDCContextBuilder");
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
||||||
"org.jclouds.savvis.SymphonyVPDCPropertiesBuilder");
|
SymphonyVPDCPropertiesBuilder.class.getName());
|
||||||
|
|
||||||
Properties overrides = new Properties();
|
Properties overrides = new Properties();
|
||||||
overrides.setProperty("savvis-symphony-vpdc.endpoint",
|
overrides.setProperty("savvis-symphony-vpdc.endpoint",
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -42,17 +42,13 @@ public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest {
|
||||||
|
|
||||||
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
||||||
Properties restProperties = new Properties();
|
Properties restProperties = new Properties();
|
||||||
restProperties
|
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
||||||
.setProperty("savvis-symphony-vpdc.contextbuilder", "org.jclouds.savvis.SymphonyVPDCContextBuilder");
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
||||||
"org.jclouds.savvis.SymphonyVPDCPropertiesBuilder");
|
SymphonyVPDCPropertiesBuilder.class.getName());
|
||||||
|
|
||||||
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
|
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||||
|
|
||||||
System.out.println(context);
|
|
||||||
|
|
||||||
connection = context.getApi();
|
connection = context.getApi();
|
||||||
System.out.println(connection);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.savvis.vpdc.compute;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||||
|
import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder;
|
||||||
|
import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder;
|
||||||
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Kedar Dave
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", enabled = true, sequential = true)
|
||||||
|
public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
public SymphonyVPDCComputeServiceLiveTest() {
|
||||||
|
provider = "savvis-symphony-vpdc";
|
||||||
|
group = "savvis.jclouds";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Properties getRestProperties() {
|
||||||
|
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
||||||
|
Properties restProperties = new Properties();
|
||||||
|
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
||||||
|
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
||||||
|
SymphonyVPDCPropertiesBuilder.class.getName());
|
||||||
|
return restProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JschSshClientModule getSshModule() {
|
||||||
|
return new JschSshClientModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package org.jclouds.savvis.vpdc.compute;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
|
||||||
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder;
|
||||||
|
import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live")
|
||||||
|
public class SymphonyVPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
|
public SymphonyVPDCTemplateBuilderLiveTest() {
|
||||||
|
provider = "savvis-symphony-vpdc";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeClass
|
||||||
|
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
setupCredentials();
|
||||||
|
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
||||||
|
Properties restProperties = new Properties();
|
||||||
|
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
||||||
|
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
||||||
|
SymphonyVPDCPropertiesBuilder.class.getName());
|
||||||
|
|
||||||
|
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
|
||||||
|
ImmutableSet.<Module> of(new Log4JLoggingModule()), setupProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
|
||||||
|
return new Predicate<OsFamilyVersion64Bit>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(OsFamilyVersion64Bit input) {
|
||||||
|
// TODO it seems there are no base vApp Templates available in Savvis
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultTemplateBuilder() throws IOException {
|
||||||
|
Template defaultTemplate = context.getComputeService().templateBuilder().build();
|
||||||
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5");
|
||||||
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
|
||||||
|
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<String> getIso3166Codes() {
|
||||||
|
return ImmutableSet.<String> of("US-FL", "NL-NH");
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.handlers;
|
package org.jclouds.savvis.vpdc.handlers;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.reportMatcher;
|
import static org.easymock.EasyMock.reportMatcher;
|
|
@ -1,70 +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.savvis;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
|
||||||
import org.jclouds.vcloud.domain.Org;
|
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides access to Symphony VPDC resources via their REST API.
|
|
||||||
* <p/>
|
|
||||||
*
|
|
||||||
* @see <a href="TODO PUBLIC DOC REF" />
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
|
||||||
public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
// savvis doesn't work with accept header
|
|
||||||
@Override
|
|
||||||
@GET
|
|
||||||
@XMLResponseParser(OrgHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends Org> findOrgNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
// savvis doesn't work with accept header
|
|
||||||
@Override
|
|
||||||
@GET
|
|
||||||
@XMLResponseParser(OrgHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
|
|
||||||
}
|
|
Loading…
Reference in New Issue