mirror of https://github.com/apache/jclouds.git
Issue 29, Issue 76: allowed for null parameters; converted existing ec2 methods to employ Region as a required argument
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2527 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
e7c6cbf492
commit
1c8b5cce44
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.binders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rest.Binder;
|
||||||
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds the AvailabilityZone to a form parameter if set.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class IfNotNullBindAvailabilityZoneToFormParam implements Binder {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void bindToRequest(HttpRequest request, Object input) {
|
||||||
|
if (input != null) {
|
||||||
|
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
|
"this binder is only valid for GeneratedHttpRequests!");
|
||||||
|
checkArgument(input instanceof AvailabilityZone,
|
||||||
|
"this binder is only valid for AvailabilityZone!");
|
||||||
|
((GeneratedHttpRequest<?>) request).addFormParam("Placement.AvailabilityZone",
|
||||||
|
((AvailabilityZone) input).value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceType;
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
|
@ -111,7 +112,9 @@ public class EC2ComputeService implements ComputeService {
|
||||||
keyPair.getKeyName(), securityGroupName);
|
keyPair.getKeyName(), securityGroupName);
|
||||||
|
|
||||||
RunningInstance runningInstance = Iterables
|
RunningInstance runningInstance = Iterables
|
||||||
.getLast(ec2Client.getInstanceServices().runInstances(
|
.getLast(ec2Client.getInstanceServices().runInstancesInRegion(
|
||||||
|
Region.DEFAULT,
|
||||||
|
null,
|
||||||
ami,
|
ami,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
@ -139,12 +142,13 @@ public class EC2ComputeService implements ComputeService {
|
||||||
logger.debug(">> creating keyPair name(%s)", name);
|
logger.debug(">> creating keyPair name(%s)", name);
|
||||||
KeyPair keyPair;
|
KeyPair keyPair;
|
||||||
try {
|
try {
|
||||||
keyPair = ec2Client.getKeyPairServices().createKeyPair(name);
|
keyPair = ec2Client.getKeyPairServices().createKeyPairInRegion(Region.DEFAULT, name);
|
||||||
logger.debug("<< created keyPair(%s)", keyPair.getKeyName());
|
logger.debug("<< created keyPair(%s)", keyPair.getKeyName());
|
||||||
|
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
if (e.getError().getCode().equals("InvalidKeyPair.Duplicate")) {
|
if (e.getError().getCode().equals("InvalidKeyPair.Duplicate")) {
|
||||||
keyPair = ec2Client.getKeyPairServices().describeKeyPairs(name).last();
|
keyPair = Iterables.getLast(ec2Client.getKeyPairServices().describeKeyPairsInRegion(
|
||||||
|
Region.DEFAULT, name));
|
||||||
logger.debug("<< reused keyPair(%s)", keyPair.getKeyName());
|
logger.debug("<< reused keyPair(%s)", keyPair.getKeyName());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -158,13 +162,14 @@ public class EC2ComputeService implements ComputeService {
|
||||||
logger.debug(">> creating securityGroup name(%s)", name);
|
logger.debug(">> creating securityGroup name(%s)", name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ec2Client.getSecurityGroupServices().createSecurityGroup(name, name);
|
ec2Client.getSecurityGroupServices().createSecurityGroupInRegion(Region.DEFAULT, name,
|
||||||
|
name);
|
||||||
logger.debug("<< created securityGroup(%s)", name);
|
logger.debug("<< created securityGroup(%s)", name);
|
||||||
logger.debug(">> authorizing securityGroup name(%s) ports(%s)", name, ImmutableSet
|
logger.debug(">> authorizing securityGroup name(%s) ports(%s)", name, ImmutableSet
|
||||||
.of(ports));
|
.of(ports));
|
||||||
for (int port : ports) {
|
for (int port : ports) {
|
||||||
ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngress(name,
|
ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(
|
||||||
IpProtocol.TCP, port, port, "0.0.0.0/0");
|
Region.DEFAULT, name, IpProtocol.TCP, port, port, "0.0.0.0/0");
|
||||||
}
|
}
|
||||||
logger.debug("<< authorized securityGroup(%s)", name);
|
logger.debug("<< authorized securityGroup(%s)", name);
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
|
@ -205,7 +210,8 @@ public class EC2ComputeService implements ComputeService {
|
||||||
|
|
||||||
private RunningInstance getRunningInstance(String id) {
|
private RunningInstance getRunningInstance(String id) {
|
||||||
RunningInstance runningInstance = Iterables.getLast(Iterables.getLast(
|
RunningInstance runningInstance = Iterables.getLast(Iterables.getLast(
|
||||||
ec2Client.getInstanceServices().describeInstances(id)).getRunningInstances());
|
ec2Client.getInstanceServices().describeInstancesInRegion(Region.DEFAULT, id))
|
||||||
|
.getRunningInstances());
|
||||||
return runningInstance;
|
return runningInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +233,8 @@ public class EC2ComputeService implements ComputeService {
|
||||||
public SortedSet<ServerIdentity> listServers() {
|
public SortedSet<ServerIdentity> listServers() {
|
||||||
logger.debug(">> listing servers");
|
logger.debug(">> listing servers");
|
||||||
SortedSet<ServerIdentity> servers = Sets.newTreeSet();
|
SortedSet<ServerIdentity> servers = Sets.newTreeSet();
|
||||||
for (Reservation reservation : ec2Client.getInstanceServices().describeInstances()) {
|
for (Reservation reservation : ec2Client.getInstanceServices().describeInstancesInRegion(
|
||||||
|
Region.DEFAULT)) {
|
||||||
Iterables.addAll(servers, Iterables.transform(reservation.getRunningInstances(),
|
Iterables.addAll(servers, Iterables.transform(reservation.getRunningInstances(),
|
||||||
new Function<RunningInstance, ServerIdentity>() {
|
new Function<RunningInstance, ServerIdentity>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -246,13 +253,13 @@ public class EC2ComputeService implements ComputeService {
|
||||||
// grab the old keyname
|
// grab the old keyname
|
||||||
String name = runningInstance.getKeyName();
|
String name = runningInstance.getKeyName();
|
||||||
logger.debug(">> terminating instance(%s)", runningInstance.getInstanceId());
|
logger.debug(">> terminating instance(%s)", runningInstance.getInstanceId());
|
||||||
ec2Client.getInstanceServices().terminateInstances(id);
|
ec2Client.getInstanceServices().terminateInstancesInRegion(Region.DEFAULT, id);
|
||||||
logger.debug("<< terminated instance(%s)", runningInstance.getInstanceId());
|
logger.debug("<< terminated instance(%s)", runningInstance.getInstanceId());
|
||||||
logger.debug(">> deleting keyPair(%s)", name);
|
logger.debug(">> deleting keyPair(%s)", name);
|
||||||
ec2Client.getKeyPairServices().deleteKeyPair(name);
|
ec2Client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, name);
|
||||||
logger.debug("<< deleted keyPair(%s)", name);
|
logger.debug("<< deleted keyPair(%s)", name);
|
||||||
logger.debug(">> deleting securityGroup(%s)", name);
|
logger.debug(">> deleting securityGroup(%s)", name);
|
||||||
ec2Client.getSecurityGroupServices().deleteSecurityGroup(name);
|
ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT, name);
|
||||||
logger.debug("<< deleted securityGroup(%s)", name);
|
logger.debug("<< deleted securityGroup(%s)", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -109,19 +109,6 @@ public class RunInstancesOptions extends BaseEC2RequestOptions {
|
||||||
return getFirstFormOrNull("InstanceType");
|
return getFirstFormOrNull("InstanceType");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the placement constraints (Availability Zones) for launching the instances.
|
|
||||||
*/
|
|
||||||
public RunInstancesOptions inAvailabilityZone(String availabilityZone) {
|
|
||||||
formParameters.put("Placement.AvailabilityZone", checkNotNull(availabilityZone,
|
|
||||||
"availabilityZone"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getAvailabilityZone() {
|
|
||||||
return getFirstFormOrNull("Placement.AvailabilityZone");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the kernel with which to launch the instance.
|
* The ID of the kernel with which to launch the instance.
|
||||||
*/
|
*/
|
||||||
|
@ -240,14 +227,6 @@ public class RunInstancesOptions extends BaseEC2RequestOptions {
|
||||||
return options.asType(instanceType);
|
return options.asType(instanceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RunInstancesOptions#inAvailabilityZone(String)
|
|
||||||
*/
|
|
||||||
public static RunInstancesOptions inAvailabilityZone(String availabilityZone) {
|
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
|
||||||
return options.inAvailabilityZone(availabilityZone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see RunInstancesOptions#withKernelId(String)
|
* @see RunInstancesOptions#withKernelId(String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@ import javax.annotation.Resource;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.aws.ec2.services.InstanceClient;
|
import org.jclouds.aws.ec2.services.InstanceClient;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -41,7 +42,8 @@ public class InstanceStateRunning implements Predicate<RunningInstance> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningInstance refresh(String instanceId) {
|
private RunningInstance refresh(String instanceId) {
|
||||||
return Iterables.getLast(Iterables.getLast(client.describeInstances(instanceId))
|
return Iterables.getLast(Iterables.getLast(client.describeInstancesInRegion(
|
||||||
|
Region.DEFAULT,instanceId))
|
||||||
.getRunningInstances());
|
.getRunningInstances());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,10 @@ import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||||
|
@ -53,6 +55,7 @@ import org.jclouds.aws.ec2.xml.LaunchPermissionHandler;
|
||||||
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
|
@ -71,135 +74,156 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
public interface AMIAsyncClient {
|
public interface AMIAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#describeImages
|
* @see AMIClient#describeImagesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DescribeImages")
|
@FormParams(keys = ACTION, values = "DescribeImages")
|
||||||
@XMLResponseParser(DescribeImagesResponseHandler.class)
|
@XMLResponseParser(DescribeImagesResponseHandler.class)
|
||||||
Future<? extends Set<Image>> describeImages(DescribeImagesOptions... options);
|
Future<? extends Set<Image>> describeImagesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
DescribeImagesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#createImage
|
* @see AMIClient#createImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "CreateImage")
|
@FormParams(keys = ACTION, values = "CreateImage")
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
Future<String> createImage(@FormParam("Name") String name,
|
Future<String> createImageInRegion(
|
||||||
@FormParam("InstanceId") String instanceId, CreateImageOptions... options);
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("Name") String name, @FormParam("InstanceId") String instanceId,
|
||||||
|
CreateImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#deregisterImage
|
* @see AMIClient#deregisterImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeregisterImage")
|
@FormParams(keys = ACTION, values = "DeregisterImage")
|
||||||
Future<Void> deregisterImage(@FormParam("ImageId") String imageId);
|
Future<Void> deregisterImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#registerImageFromManifest
|
* @see AMIClient#registerImageFromManifestInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RegisterImage")
|
@FormParams(keys = ACTION, values = "RegisterImage")
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
Future<String> registerImageFromManifest(@FormParam("Name") String imageName,
|
Future<String> registerImageFromManifestInRegion(
|
||||||
@FormParam("ImageLocation") String pathToManifest, RegisterImageOptions... options);
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("Name") String imageName, @FormParam("ImageLocation") String pathToManifest,
|
||||||
|
RegisterImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#registerImageBackedByEbs
|
* @see AMIClient#registerImageBackedByEbsInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "RootDeviceName", "BlockDeviceMapping.0.DeviceName" }, values = {
|
@FormParams(keys = { ACTION, "RootDeviceName", "BlockDeviceMapping.0.DeviceName" }, values = {
|
||||||
"RegisterImage", "/dev/sda1", "/dev/sda1" })
|
"RegisterImage", "/dev/sda1", "/dev/sda1" })
|
||||||
@XMLResponseParser(ImageIdHandler.class)
|
@XMLResponseParser(ImageIdHandler.class)
|
||||||
Future<String> registerImageBackedByEbs(@FormParam("Name") String imageName,
|
Future<String> registerImageBackedByEbsInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("Name") String imageName,
|
||||||
@FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId,
|
@FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId,
|
||||||
RegisterImageBackedByEbsOptions... options);
|
RegisterImageBackedByEbsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#resetLaunchPermissionsOnImage
|
* @see AMIClient#resetLaunchPermissionsOnImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" })
|
||||||
Future<Void> resetLaunchPermissionsOnImage(@FormParam("ImageId") String imageId);
|
Future<Void> resetLaunchPermissionsOnImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#addLaunchPermissionsToImage
|
* @see AMIClient#addLaunchPermissionsToImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"add", "launchPermission" })
|
"add", "launchPermission" })
|
||||||
Future<Void> addLaunchPermissionsToImage(
|
Future<Void> addLaunchPermissionsToImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#removeLaunchPermissionsToImage
|
* @see AMIClient#removeLaunchPermissionsToImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"remove", "launchPermission" })
|
"remove", "launchPermission" })
|
||||||
Future<Void> removeLaunchPermissionsFromImage(
|
Future<Void> removeLaunchPermissionsFromImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#getLaunchPermissionForImage
|
* @see AMIClient#getLaunchPermissionForImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
||||||
"launchPermission" })
|
"launchPermission" })
|
||||||
@XMLResponseParser(LaunchPermissionHandler.class)
|
@XMLResponseParser(LaunchPermissionHandler.class)
|
||||||
Future<LaunchPermission> getLaunchPermissionForImage(@FormParam("ImageId") String imageId);
|
Future<LaunchPermission> getLaunchPermissionForImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#getProductCodesForImage
|
* @see AMIClient#getProductCodesForImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
|
||||||
@XMLResponseParser(ProductCodesHandler.class)
|
@XMLResponseParser(ProductCodesHandler.class)
|
||||||
Future<? extends Set<String>> getProductCodesForImage(@FormParam("ImageId") String imageId);
|
Future<? extends Set<String>> getProductCodesForImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#getBlockDeviceMappingsForImage
|
* @see AMIClient#getBlockDeviceMappingsForImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
||||||
"blockDeviceMapping" })
|
"blockDeviceMapping" })
|
||||||
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
||||||
Future<? extends Map<String, EbsBlockDevice>> getBlockDeviceMappingsForImage(
|
Future<? extends Map<String, EbsBlockDevice>> getBlockDeviceMappingsForImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#addProductCodesToImage
|
* @see AMIClient#addProductCodesToImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"add", "productCodes" })
|
"add", "productCodes" })
|
||||||
Future<Void> addProductCodesToImage(
|
Future<Void> addProductCodesToImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AMIClient#removeProductCodesToImage
|
* @see AMIClient#removeProductCodesToImageInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||||
"remove", "productCodes" })
|
"remove", "productCodes" })
|
||||||
Future<Void> removeProductCodesFromImage(
|
Future<Void> removeProductCodesFromImageInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||||
@FormParam("ImageId") String imageId);
|
@FormParam("ImageId") String imageId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
|
@ -51,6 +52,8 @@ public interface AMIClient {
|
||||||
* private images that you own, and private images owned by other users for which you have
|
* private images that you own, and private images owned by other users for which you have
|
||||||
* explicit launch permissions.
|
* explicit launch permissions.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @see InstanceClient#describeInstances
|
* @see InstanceClient#describeInstances
|
||||||
* @see #describeImageAttribute
|
* @see #describeImageAttribute
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html"
|
||||||
|
@ -58,11 +61,13 @@ public interface AMIClient {
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
Set<Image> describeImages(DescribeImagesOptions... options);
|
Set<Image> describeImagesInRegion(Region region, DescribeImagesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link LaunchPermission}s of an image.
|
* Returns the {@link LaunchPermission}s of an image.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* The ID of the AMI for which an attribute will be described
|
* The ID of the AMI for which an attribute will be described
|
||||||
* @see #describeImages
|
* @see #describeImages
|
||||||
|
@ -72,11 +77,13 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
LaunchPermission getLaunchPermissionForImage(String imageId);
|
LaunchPermission getLaunchPermissionForImageInRegion(Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Product Codes of an image.
|
* Returns the Product Codes of an image.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* The ID of the AMI for which an attribute will be described
|
* The ID of the AMI for which an attribute will be described
|
||||||
* @see #describeImages
|
* @see #describeImages
|
||||||
|
@ -86,11 +93,13 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
Set<String> getProductCodesForImage(String imageId);
|
Set<String> getProductCodesForImageInRegion(Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of device name to block device for the image.
|
* Returns a map of device name to block device for the image.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* The ID of the AMI for which an attribute will be described
|
* The ID of the AMI for which an attribute will be described
|
||||||
* @see #describeImages
|
* @see #describeImages
|
||||||
|
@ -100,11 +109,13 @@ public interface AMIClient {
|
||||||
* />
|
* />
|
||||||
* @see DescribeImagesOptions
|
* @see DescribeImagesOptions
|
||||||
*/
|
*/
|
||||||
Map<String, EbsBlockDevice> getBlockDeviceMappingsForImage(String imageId);
|
Map<String, EbsBlockDevice> getBlockDeviceMappingsForImageInRegion(Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
* Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param name
|
* @param name
|
||||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||||
|
@ -122,13 +133,16 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String createImage(String name, String instanceId, CreateImageOptions... options);
|
String createImageInRegion(Region region, String name, String instanceId,
|
||||||
|
CreateImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Deregisters the specified AMI. Once deregistered, the AMI cannot be used to launch new
|
* Deregisters the specified AMI. Once deregistered, the AMI cannot be used to launch new
|
||||||
* instances.
|
* instances.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* Unique ID of the AMI which was assigned during registration. To register an AMI, use
|
* Unique ID of the AMI which was assigned during registration. To register an AMI, use
|
||||||
* RegisterImage. To view the AMI IDs of AMIs that belong to your account. use
|
* RegisterImage. To view the AMI IDs of AMIs that belong to your account. use
|
||||||
|
@ -139,7 +153,7 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deregisterImage(String imageId);
|
void deregisterImageInRegion(Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
||||||
|
@ -151,6 +165,8 @@ public interface AMIClient {
|
||||||
* <h3>Note</h3> Any modifications to an AMI backed by Amazon S3 invalidates this registration.
|
* <h3>Note</h3> Any modifications to an AMI backed by Amazon S3 invalidates this registration.
|
||||||
* If you make changes to an image, deregister the previous image and register the new image.
|
* If you make changes to an image, deregister the previous image and register the new image.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param name
|
* @param name
|
||||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||||
|
@ -167,7 +183,7 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String registerImageFromManifest(String name, String pathToManifest,
|
String registerImageFromManifestInRegion(Region region, String name, String pathToManifest,
|
||||||
RegisterImageOptions... options);
|
RegisterImageOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,6 +199,8 @@ public interface AMIClient {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Amazon EBS snapshots are not guaranteed to be bootable.
|
* Amazon EBS snapshots are not guaranteed to be bootable.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param name
|
* @param name
|
||||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||||
|
@ -200,12 +218,14 @@ public interface AMIClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
String registerImageBackedByEbs(String name, String ebsSnapshotId,
|
String registerImageBackedByEbsInRegion(Region region, String name, String ebsSnapshotId,
|
||||||
RegisterImageBackedByEbsOptions... options);
|
RegisterImageBackedByEbsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@code launchPermission}s to an AMI.
|
* Adds {@code launchPermission}s to an AMI.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param userIds
|
* @param userIds
|
||||||
* AWS Access Key ID.
|
* AWS Access Key ID.
|
||||||
* @param userGroups
|
* @param userGroups
|
||||||
|
@ -219,12 +239,14 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void addLaunchPermissionsToImage(Iterable<String> userIds, Iterable<String> userGroups,
|
void addLaunchPermissionsToImageInRegion(Region region, Iterable<String> userIds,
|
||||||
String imageId);
|
Iterable<String> userGroups, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the {@code launchPermission}s on an AMI.
|
* Resets the {@code launchPermission}s on an AMI.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* ID of the AMI on which the attribute will be reset.
|
* ID of the AMI on which the attribute will be reset.
|
||||||
*
|
*
|
||||||
|
@ -234,11 +256,13 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void resetLaunchPermissionsOnImage(String imageId);
|
void resetLaunchPermissionsOnImageInRegion(Region region, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@code launchPermission}s from an AMI.
|
* Removes {@code launchPermission}s from an AMI.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param userIds
|
* @param userIds
|
||||||
* AWS Access Key ID.
|
* AWS Access Key ID.
|
||||||
* @param userGroups
|
* @param userGroups
|
||||||
|
@ -252,12 +276,14 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void removeLaunchPermissionsFromImage(Iterable<String> userIds, Iterable<String> userGroups,
|
void removeLaunchPermissionsFromImageInRegion(Region region, Iterable<String> userIds,
|
||||||
String imageId);
|
Iterable<String> userGroups, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@code productCode}s to an AMI.
|
* Adds {@code productCode}s to an AMI.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param productCodes
|
* @param productCodes
|
||||||
* Product Codes
|
* Product Codes
|
||||||
* @param imageId
|
* @param imageId
|
||||||
|
@ -269,11 +295,13 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void addProductCodesToImage(Iterable<String> productCodes, String imageId);
|
void addProductCodesToImageInRegion(Region region, Iterable<String> productCodes, String imageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@code productCode}s from an AMI.
|
* Removes {@code productCode}s from an AMI.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* AMIs are tied to the Region where its files are located within Amazon S3.
|
||||||
* @param productCodes
|
* @param productCodes
|
||||||
* Product Codes
|
* Product Codes
|
||||||
* @param imageId
|
* @param imageId
|
||||||
|
@ -285,5 +313,6 @@ public interface AMIClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void removeProductCodesFromImage(Iterable<String> productCodes, String imageId);
|
void removeProductCodesFromImageInRegion(Region region, Iterable<String> productCodes,
|
||||||
|
String imageId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
|
@ -37,11 +37,14 @@ import javax.ws.rs.Path;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.binders.BindInetAddressesToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindInetAddressesToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.ParamParser;
|
import org.jclouds.rest.annotations.ParamParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
@ -62,50 +65,55 @@ import org.jclouds.rest.functions.InetAddressToHostAddress;
|
||||||
public interface ElasticIPAddressAsyncClient {
|
public interface ElasticIPAddressAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#allocateAddress
|
* @see BaseEC2Client#allocateAddressInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@XMLResponseParser(AllocateAddressResponseHandler.class)
|
@XMLResponseParser(AllocateAddressResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "AllocateAddress")
|
@FormParams(keys = ACTION, values = "AllocateAddress")
|
||||||
Future<InetAddress> allocateAddress();
|
Future<InetAddress> allocateAddressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#associateAddress
|
* @see BaseEC2Client#associateAddressInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AssociateAddress")
|
@FormParams(keys = ACTION, values = "AssociateAddress")
|
||||||
Future<Void> associateAddress(
|
Future<Void> associateAddressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp,
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp,
|
||||||
@FormParam("InstanceId") String instanceId);
|
@FormParam("InstanceId") String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#disassociateAddress
|
* @see BaseEC2Client#disassociateAddressInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DisassociateAddress")
|
@FormParams(keys = ACTION, values = "DisassociateAddress")
|
||||||
Future<Void> disassociateAddress(
|
Future<Void> disassociateAddressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#releaseAddress
|
* @see BaseEC2Client#releaseAddressInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "ReleaseAddress")
|
@FormParams(keys = ACTION, values = "ReleaseAddress")
|
||||||
Future<Void> releaseAddress(
|
Future<Void> releaseAddressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
@FormParam("PublicIp") @ParamParser(InetAddressToHostAddress.class) InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#describeAddresses
|
* @see BaseEC2Client#describeAddressesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DescribeAddresses")
|
@FormParams(keys = ACTION, values = "DescribeAddresses")
|
||||||
@XMLResponseParser(DescribeAddressesResponseHandler.class)
|
@XMLResponseParser(DescribeAddressesResponseHandler.class)
|
||||||
Future<? extends SortedSet<PublicIpInstanceIdPair>> describeAddresses(
|
Future<? extends Set<PublicIpInstanceIdPair>> describeAddressesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindInetAddressesToIndexedFormParams.class) InetAddress... publicIps);
|
@BinderParam(BindInetAddressesToIndexedFormParams.class) InetAddress... publicIps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,19 +44,23 @@ public interface ElasticIPAddressClient {
|
||||||
/**
|
/**
|
||||||
* Acquires an elastic IP address for use with your account.
|
* Acquires an elastic IP address for use with your account.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
* @see #describeAddresses
|
* @see #describeAddresses
|
||||||
* @see #releaseAddress
|
* @see #releaseAddress
|
||||||
* @see #associateAddress
|
* @see #associateAddress
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html"
|
||||||
*/
|
*/
|
||||||
InetAddress allocateAddress();
|
InetAddress allocateAddressInRegion(Region region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates an elastic IP address with an instance. If the IP address is currently assigned to
|
* Associates an elastic IP address with an instance. If the IP address is currently assigned to
|
||||||
* another instance, the IP address is assigned to the new instance. This is an idempotent
|
* another instance, the IP address is assigned to the new instance. This is an idempotent
|
||||||
* operation. If you enter it more than once, Amazon EC2 does not return an error.
|
* operation. If you enter it more than once, Amazon EC2 does not return an error.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
* @param publicIp
|
* @param publicIp
|
||||||
* IP address that you are assigning to the instance.
|
* IP address that you are assigning to the instance.
|
||||||
* @param instanceId
|
* @param instanceId
|
||||||
|
@ -67,13 +72,15 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-AssociateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-AssociateAddress.html"
|
||||||
*/
|
*/
|
||||||
void associateAddress(InetAddress publicIp, String instanceId);
|
void associateAddressInRegion(Region region, InetAddress publicIp, String instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disassociates the specified elastic IP address from the instance to which it is assigned. This
|
* Disassociates the specified elastic IP address from the instance to which it is assigned. This
|
||||||
* is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an
|
* is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an
|
||||||
* error.
|
* error.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
* @param publicIp
|
* @param publicIp
|
||||||
* IP address that you are assigning to the instance.
|
* IP address that you are assigning to the instance.
|
||||||
*
|
*
|
||||||
|
@ -83,27 +90,33 @@ public interface ElasticIPAddressClient {
|
||||||
* @see #associateAddress
|
* @see #associateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DisdisassociateAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DisdisassociateAddress.html"
|
||||||
*/
|
*/
|
||||||
void disassociateAddress(InetAddress publicIp);
|
void disassociateAddressInRegion(Region region, InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases an elastic IP address associated with your account.
|
* Releases an elastic IP address associated with your account.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
* @param publicIp
|
* @param publicIp
|
||||||
* The IP address that you are releasing from your account.
|
* The IP address that you are releasing from your account.
|
||||||
|
*
|
||||||
* @see #allocateAddress
|
* @see #allocateAddress
|
||||||
* @see #describeAddresses
|
* @see #describeAddresses
|
||||||
* @see #associateAddress
|
* @see #associateAddress
|
||||||
* @see #disassociateAddress
|
* @see #disassociateAddress
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-ReleaseAddress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-ReleaseAddress.html"
|
||||||
*/
|
*/
|
||||||
void releaseAddress(InetAddress publicIp);
|
void releaseAddressInRegion(Region region, InetAddress publicIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists elastic IP addresses assigned to your account or provides information about a specific
|
* Lists elastic IP addresses assigned to your account or provides information about a specific
|
||||||
* address.
|
* address.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
* @param publicIps
|
* @param publicIps
|
||||||
* Elastic IP address to describe.
|
* Elastic IP address to describe.
|
||||||
|
*
|
||||||
* @throws AWSResponseException
|
* @throws AWSResponseException
|
||||||
* if the requested publicIp is not found
|
* if the requested publicIp is not found
|
||||||
* @see #allocateAddress
|
* @see #allocateAddress
|
||||||
|
@ -111,6 +124,7 @@ public interface ElasticIPAddressClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAddresses.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAddresses.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<PublicIpInstanceIdPair> describeAddresses(InetAddress... publicIps);
|
Set<PublicIpInstanceIdPair> describeAddressesInRegion(Region region,
|
||||||
|
InetAddress... publicIps);
|
||||||
|
|
||||||
}
|
}
|
|
@ -29,21 +29,27 @@ import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
||||||
|
import org.jclouds.aws.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam;
|
||||||
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.aws.ec2.domain.TerminatedInstance;
|
import org.jclouds.aws.ec2.domain.TerminatedInstance;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeInstancesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.TerminateInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.TerminateInstancesResponseHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
|
@ -62,34 +68,38 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
public interface InstanceAsyncClient {
|
public interface InstanceAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#describeInstances
|
* @see BaseEC2Client#describeInstancesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DescribeInstances")
|
@FormParams(keys = ACTION, values = "DescribeInstances")
|
||||||
@XMLResponseParser(DescribeInstancesResponseHandler.class)
|
@XMLResponseParser(DescribeInstancesResponseHandler.class)
|
||||||
Future<? extends SortedSet<Reservation>> describeInstances(
|
Future<? extends SortedSet<Reservation>> describeInstancesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#runInstances
|
* @see BaseEC2Client#runInstancesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RunInstances")
|
@FormParams(keys = ACTION, values = "RunInstances")
|
||||||
@XMLResponseParser(RunInstancesResponseHandler.class)
|
@XMLResponseParser(RunInstancesResponseHandler.class)
|
||||||
Future<Reservation> runInstances(@FormParam("ImageId") String imageId,
|
Future<Reservation> runInstancesInRegion(
|
||||||
@FormParam("MinCount") int minCount, @FormParam("MaxCount") int maxCount,
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
RunInstancesOptions... options);
|
@Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) AvailabilityZone nullableAvailabilityZone,
|
||||||
|
@FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount,
|
||||||
|
@FormParam("MaxCount") int maxCount, RunInstancesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#terminateInstances
|
* @see BaseEC2Client#terminateInstancesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "TerminateInstances")
|
@FormParams(keys = ACTION, values = "TerminateInstances")
|
||||||
@XMLResponseParser(TerminateInstancesResponseHandler.class)
|
@XMLResponseParser(TerminateInstancesResponseHandler.class)
|
||||||
Future<? extends SortedSet<TerminatedInstance>> terminateInstances(
|
Future<? extends SortedSet<TerminatedInstance>> terminateInstancesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("InstanceId.0") String instanceId,
|
@FormParam("InstanceId.0") String instanceId,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ package org.jclouds.aws.ec2.services;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.aws.ec2.domain.TerminatedInstance;
|
import org.jclouds.aws.ec2.domain.TerminatedInstance;
|
||||||
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
||||||
|
@ -52,12 +56,16 @@ public interface InstanceClient {
|
||||||
* Recently terminated instances might appear in the returned results.This interval is usually
|
* Recently terminated instances might appear in the returned results.This interval is usually
|
||||||
* less than one hour.
|
* less than one hour.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||||
|
* Region.
|
||||||
|
*
|
||||||
* @see #runInstances
|
* @see #runInstances
|
||||||
* @see #terminateInstances
|
* @see #terminateInstances
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<Reservation> describeInstances(String... instanceIds);
|
SortedSet<Reservation> describeInstancesInRegion(Region region, String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches a specified number of instances of an AMI for which you have permissions.
|
* Launches a specified number of instances of an AMI for which you have permissions.
|
||||||
|
@ -100,6 +108,13 @@ public interface InstanceClient {
|
||||||
* provide greater stability and performance for these instance types. For more information about
|
* provide greater stability and performance for these instance types. For more information about
|
||||||
* kernels, go the Amazon Elastic Compute Cloud Developer Guide.
|
* kernels, go the Amazon Elastic Compute Cloud Developer Guide.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||||
|
* Region.
|
||||||
|
* @param nullableAvailabilityZone
|
||||||
|
* Specifies the placement constraints (Availability Zones) for launching the
|
||||||
|
* instances. If null, Amazon will determine the best availability zone to place the
|
||||||
|
* instance.
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* Unique ID of a machine image, returned by a call to
|
* Unique ID of a machine image, returned by a call to
|
||||||
* @param minCount
|
* @param minCount
|
||||||
|
@ -123,8 +138,9 @@ public interface InstanceClient {
|
||||||
* />
|
* />
|
||||||
* @see RunInstancesOptions
|
* @see RunInstancesOptions
|
||||||
*/
|
*/
|
||||||
Reservation runInstances(String imageId, int minCount, int maxCount,
|
Reservation runInstancesInRegion(Region region,
|
||||||
RunInstancesOptions... options);
|
@Nullable AvailabilityZone nullableAvailabilityZone, String imageId, int minCount,
|
||||||
|
int maxCount, RunInstancesOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down one or more instances. This operation is idempotent; if you terminate an instance
|
* Shuts down one or more instances. This operation is idempotent; if you terminate an instance
|
||||||
|
@ -132,12 +148,17 @@ public interface InstanceClient {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Terminated instances will remain visible after termination (approximately one hour).
|
* Terminated instances will remain visible after termination (approximately one hour).
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||||
|
* Region.
|
||||||
|
*
|
||||||
* @param instanceIds
|
* @param instanceIds
|
||||||
* Instance ID to terminate.
|
* Instance ID to terminate.
|
||||||
* @see #describeInstances
|
* @see #describeInstances
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-TerminateInstances.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-TerminateInstances.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<TerminatedInstance> terminateInstances(String instanceId, String... instanceIds);
|
SortedSet<TerminatedInstance> terminateInstancesInRegion(Region region, String instanceId,
|
||||||
|
String... instanceIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.aws.ec2.services;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
|
@ -36,11 +36,14 @@ import javax.ws.rs.Path;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.binders.BindKeyNameToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindKeyNameToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.KeyPairResponseHandler;
|
import org.jclouds.aws.ec2.xml.KeyPairResponseHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
|
@ -59,30 +62,35 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
public interface KeyPairAsyncClient {
|
public interface KeyPairAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#createKeyPair
|
* @see BaseEC2Client#createKeyPairInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "CreateKeyPair")
|
@FormParams(keys = ACTION, values = "CreateKeyPair")
|
||||||
@XMLResponseParser(KeyPairResponseHandler.class)
|
@XMLResponseParser(KeyPairResponseHandler.class)
|
||||||
Future<KeyPair> createKeyPair(@FormParam("KeyName") String keyName);
|
Future<KeyPair> createKeyPairInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("KeyName") String keyName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#describeKeyPairs
|
* @see BaseEC2Client#describeKeyPairsInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DescribeKeyPairs")
|
@FormParams(keys = ACTION, values = "DescribeKeyPairs")
|
||||||
@XMLResponseParser(DescribeKeyPairsResponseHandler.class)
|
@XMLResponseParser(DescribeKeyPairsResponseHandler.class)
|
||||||
Future<? extends SortedSet<KeyPair>> describeKeyPairs(
|
Future<? extends Set<KeyPair>> describeKeyPairsInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindKeyNameToIndexedFormParams.class) String... keyPairNames);
|
@BinderParam(BindKeyNameToIndexedFormParams.class) String... keyPairNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#deleteKeyPair
|
* @see BaseEC2Client#deleteKeyPairInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteKeyPair")
|
@FormParams(keys = ACTION, values = "DeleteKeyPair")
|
||||||
Future<Void> deleteKeyPair(@FormParam("KeyName") String keyName);
|
Future<Void> deleteKeyPairInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("KeyName") String keyName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +45,11 @@ public interface KeyPairClient {
|
||||||
* unencrypted PEM encoded PKCS#8 private key. If a key with the specified name already exists,
|
* unencrypted PEM encoded PKCS#8 private key. If a key with the specified name already exists,
|
||||||
* Amazon EC2 returns an error.
|
* Amazon EC2 returns an error.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Key pairs (to connect to instances) are Region-specific.
|
||||||
|
* @param keyName
|
||||||
|
* A unique name for the key pair.
|
||||||
|
*
|
||||||
* @see #runInstances
|
* @see #runInstances
|
||||||
* @see #describeKeyPairs
|
* @see #describeKeyPairs
|
||||||
* @see #deleteKeyPair
|
* @see #deleteKeyPair
|
||||||
|
@ -52,26 +58,34 @@ public interface KeyPairClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
KeyPair createKeyPair(String keyName);
|
KeyPair createKeyPairInRegion(Region region, String keyName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about key pairs available to you. If you specify key pairs, information
|
* Returns information about key pairs available to you. If you specify key pairs, information
|
||||||
* about those key pairs is returned. Otherwise, information for all registered key pairs is
|
* about those key pairs is returned. Otherwise, information for all registered key pairs is
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Key pairs (to connect to instances) are Region-specific.
|
||||||
* @param keyPairNames
|
* @param keyPairNames
|
||||||
* Key pairs to describe.
|
* Key pairs to describe.
|
||||||
|
*
|
||||||
* @see #runInstances
|
* @see #runInstances
|
||||||
* @see #describeAvailabilityZones
|
* @see #describeAvailabilityZones
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<KeyPair> describeKeyPairs(String... keyPairNames);
|
Set<KeyPair> describeKeyPairsInRegion(Region region, String... keyPairNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the
|
* Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the
|
||||||
* key pair
|
* key pair
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Key pairs (to connect to instances) are Region-specific.
|
||||||
|
* @param keyName
|
||||||
|
* Name of the key pair to delete
|
||||||
|
*
|
||||||
* @see #describeKeyPairs
|
* @see #describeKeyPairs
|
||||||
* @see #createKeyPair
|
* @see #createKeyPair
|
||||||
*
|
*
|
||||||
|
@ -79,7 +93,6 @@ public interface KeyPairClient {
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteKeyPair.html"
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteKeyPair.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
|
void deleteKeyPairInRegion(Region region, String keyName);
|
||||||
void deleteKeyPair(String keyName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,13 @@ import javax.ws.rs.Path;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
|
@ -58,24 +61,26 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
public interface MonitoringAsyncClient {
|
public interface MonitoringAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Monitoring#monitorInstances
|
* @see Monitoring#monitorInstancesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "MonitorInstances")
|
@FormParams(keys = ACTION, values = "MonitorInstances")
|
||||||
@XMLResponseParser(MonitoringStateHandler.class)
|
@XMLResponseParser(MonitoringStateHandler.class)
|
||||||
Future<? extends Map<String, MonitoringState>> monitorInstances(
|
Future<? extends Map<String, MonitoringState>> monitorInstancesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("InstanceId.0") String instanceId,
|
@FormParam("InstanceId.0") String instanceId,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Monitoring#monitorInstances
|
* @see Monitoring#monitorInstancesInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "UnmonitorInstances")
|
@FormParams(keys = ACTION, values = "UnmonitorInstances")
|
||||||
@XMLResponseParser(MonitoringStateHandler.class)
|
@XMLResponseParser(MonitoringStateHandler.class)
|
||||||
Future<? extends Map<String, MonitoringState>> unmonitorInstances(
|
Future<? extends Map<String, MonitoringState>> unmonitorInstancesInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("InstanceId.0") String instanceId,
|
@FormParam("InstanceId.0") String instanceId,
|
||||||
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,12 @@ import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides monitoring services for EC2. For more information, refer to the Amazon CloudWatch Developer Guide.
|
* Provides monitoring services for EC2. For more information, refer to the Amazon CloudWatch
|
||||||
|
* Developer Guide.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -39,26 +41,35 @@ import org.jclouds.concurrent.Timeout;
|
||||||
public interface MonitoringClient {
|
public interface MonitoringClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables monitoring for a running instance. For more information, refer to the Amazon CloudWatch Developer Guide.
|
* Enables monitoring for a running instance. For more information, refer to the Amazon
|
||||||
|
* CloudWatch Developer Guide.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||||
|
* Region.
|
||||||
* @see InstanceClient#runInstances
|
* @see InstanceClient#runInstances
|
||||||
* @see #unmonitorInstances
|
* @see #unmonitorInstances
|
||||||
*
|
*
|
||||||
* @see <a href=
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html"
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html"
|
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Map<String, MonitoringState> monitorInstances(String instanceId, String... instanceIds);
|
Map<String, MonitoringState> monitorInstancesInRegion(Region region, String instanceId,
|
||||||
|
String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables monitoring for a running instance. For more information, refer to the Amazon CloudWatch Developer Guide.
|
* Disables monitoring for a running instance. For more information, refer to the Amazon
|
||||||
|
* CloudWatch Developer Guide.
|
||||||
|
*
|
||||||
|
* @param region
|
||||||
|
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||||
|
* Region.
|
||||||
*
|
*
|
||||||
* @see InstanceClient#runInstances
|
* @see InstanceClient#runInstances
|
||||||
* @see #monitorInstances
|
* @see #monitorInstances
|
||||||
*
|
*
|
||||||
* @see <a href=
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html"
|
||||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html"
|
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
Map<String, MonitoringState> unmonitorInstances(String instanceId, String... instanceIds);
|
Map<String, MonitoringState> unmonitorInstancesInRegion(Region region, String instanceId,
|
||||||
|
String... instanceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,16 @@ import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.binders.BindGroupNameToIndexedFormParams;
|
import org.jclouds.aws.ec2.binders.BindGroupNameToIndexedFormParams;
|
||||||
import org.jclouds.aws.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams;
|
import org.jclouds.aws.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
|
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
@ -63,70 +66,82 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
public interface SecurityGroupAsyncClient {
|
public interface SecurityGroupAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#createSecurityGroup
|
* @see BaseEC2Client#createSecurityGroupInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "CreateSecurityGroup")
|
@FormParams(keys = ACTION, values = "CreateSecurityGroup")
|
||||||
Future<Void> createSecurityGroup(@FormParam("GroupName") String name,
|
Future<Void> createSecurityGroupInRegion(
|
||||||
@FormParam("GroupDescription") String description);
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("GroupName") String name, @FormParam("GroupDescription") String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#deleteSecurityGroup
|
* @see BaseEC2Client#deleteSecurityGroupInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteSecurityGroup")
|
@FormParams(keys = ACTION, values = "DeleteSecurityGroup")
|
||||||
@ExceptionParser(ReturnVoidOnGroupNotFound.class)
|
@ExceptionParser(ReturnVoidOnGroupNotFound.class)
|
||||||
Future<Void> deleteSecurityGroup(@FormParam("GroupName") String name);
|
Future<Void> deleteSecurityGroupInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("GroupName") String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#describeSecurityGroups
|
* @see BaseEC2Client#describeSecurityGroupsInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DescribeSecurityGroups")
|
@FormParams(keys = ACTION, values = "DescribeSecurityGroups")
|
||||||
@XMLResponseParser(DescribeSecurityGroupsResponseHandler.class)
|
@XMLResponseParser(DescribeSecurityGroupsResponseHandler.class)
|
||||||
Future<? extends SortedSet<SecurityGroup>> describeSecurityGroups(
|
Future<? extends SortedSet<SecurityGroup>> describeSecurityGroupsInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@BinderParam(BindGroupNameToIndexedFormParams.class) String... securityGroupNames);
|
@BinderParam(BindGroupNameToIndexedFormParams.class) String... securityGroupNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#authorizeSecurityGroupIngress(String,UserIdGroupPair)
|
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(Region, String,UserIdGroupPair)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||||
Future<Void> authorizeSecurityGroupIngress(
|
Future<Void> authorizeSecurityGroupIngressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#authorizeSecurityGroupIngress(String,IpProtocol,int,int,String)
|
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(Region,
|
||||||
|
* String,IpProtocol,int,int,String)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||||
Future<Void> authorizeSecurityGroupIngress(@FormParam("GroupName") String groupName,
|
Future<Void> authorizeSecurityGroupIngressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("GroupName") String groupName,
|
||||||
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
||||||
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#revokeSecurityGroupIngress(String,UserIdGroupPair)
|
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(Region, String,UserIdGroupPair)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||||
Future<Void> revokeSecurityGroupIngress(
|
Future<Void> revokeSecurityGroupIngressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
@FormParam("GroupName") String groupName,
|
@FormParam("GroupName") String groupName,
|
||||||
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
@BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BaseEC2Client#revokeSecurityGroupIngress(String,IpProtocol,int,int,String)
|
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(Region,
|
||||||
|
* String,IpProtocol,int,int,String)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||||
Future<Void> revokeSecurityGroupIngress(@FormParam("GroupName") String groupName,
|
Future<Void> revokeSecurityGroupIngressInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) Region region,
|
||||||
|
@FormParam("GroupName") String groupName,
|
||||||
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
@FormParam("IpProtocol") IpProtocol ipProtocol, @FormParam("FromPort") int fromPort,
|
||||||
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -43,6 +44,10 @@ public interface SecurityGroupClient {
|
||||||
/**
|
/**
|
||||||
* Creates a new security group. Group names must be unique per account.
|
* Creates a new security group. Group names must be unique per account.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param name
|
* @param name
|
||||||
* Name of the security group. Accepts alphanumeric characters, spaces, dashes, and
|
* Name of the security group. Accepts alphanumeric characters, spaces, dashes, and
|
||||||
* underscores.
|
* underscores.
|
||||||
|
@ -59,11 +64,15 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void createSecurityGroup(String name, String description);
|
void createSecurityGroupInRegion(Region region, String name, String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a security group that you own.
|
* Deletes a security group that you own.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param name
|
* @param name
|
||||||
* Name of the security group to delete.
|
* Name of the security group to delete.
|
||||||
*
|
*
|
||||||
|
@ -75,11 +84,15 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSecurityGroup.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteSecurityGroup.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteSecurityGroup(String name);
|
void deleteSecurityGroupInRegion(Region region, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about security groups that you own.
|
* Returns information about security groups that you own.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param securityGroupNames
|
* @param securityGroupNames
|
||||||
* Name of the security groups
|
* Name of the security groups
|
||||||
*
|
*
|
||||||
|
@ -91,12 +104,17 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html"
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
SortedSet<SecurityGroup> describeSecurityGroups(String... securityGroupNames);
|
SortedSet<SecurityGroup> describeSecurityGroupsInRegion(Region region,
|
||||||
|
String... securityGroupNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Adds permissions to a security group based on another group.
|
* Adds permissions to a security group based on another group.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* Name of the group to modify. The name must be valid and belong to the account
|
* Name of the group to modify. The name must be valid and belong to the account
|
||||||
* @param sourceSecurityGroup
|
* @param sourceSecurityGroup
|
||||||
|
@ -110,7 +128,8 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void authorizeSecurityGroupIngress(String groupName, UserIdGroupPair sourceSecurityGroup);
|
void authorizeSecurityGroupIngressInRegion(Region region, String groupName,
|
||||||
|
UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -123,6 +142,10 @@ public interface SecurityGroupClient {
|
||||||
* the security group as quickly as possible. However, depending on the number of instances, a
|
* the security group as quickly as possible. However, depending on the number of instances, a
|
||||||
* small delay might occur.
|
* small delay might occur.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* Name of the group to modify. The name must be valid and belong to the account
|
* Name of the group to modify. The name must be valid and belong to the account
|
||||||
* @param ipProtocol
|
* @param ipProtocol
|
||||||
|
@ -144,14 +167,18 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void authorizeSecurityGroupIngress(String groupName, IpProtocol ipProtocol, int fromPort,
|
void authorizeSecurityGroupIngressInRegion(Region region, String groupName,
|
||||||
int toPort, String cidrIp);
|
IpProtocol ipProtocol, int fromPort, int toPort, String cidrIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Revokes permissions from a security group. The permissions used to revoke must be specified
|
* Revokes permissions from a security group. The permissions used to revoke must be specified
|
||||||
* using the same values used to grant the permissions.
|
* using the same values used to grant the permissions.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* Name of the group to modify. The name must be valid and belong to the account
|
* Name of the group to modify. The name must be valid and belong to the account
|
||||||
* @param sourceSecurityGroup
|
* @param sourceSecurityGroup
|
||||||
|
@ -165,7 +192,8 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void revokeSecurityGroupIngress(String groupName, UserIdGroupPair sourceSecurityGroup);
|
void revokeSecurityGroupIngressInRegion(Region region, String groupName,
|
||||||
|
UserIdGroupPair sourceSecurityGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -179,6 +207,10 @@ public interface SecurityGroupClient {
|
||||||
* Permission changes are quickly propagated to instances within the security group. However,
|
* Permission changes are quickly propagated to instances within the security group. However,
|
||||||
* depending on the number of instances in the group, a small delay is might occur.
|
* depending on the number of instances in the group, a small delay is might occur.
|
||||||
*
|
*
|
||||||
|
* @param region
|
||||||
|
* Security groups are not copied across Regions. Instances within the Region cannot
|
||||||
|
* communicate with instances outside the Region using group-based firewall rules.
|
||||||
|
* Traffic from instances in another Region is seen as WAN bandwidth.
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* Name of the group to modify. The name must be valid and belong to the account
|
* Name of the group to modify. The name must be valid and belong to the account
|
||||||
* @param ipProtocol
|
* @param ipProtocol
|
||||||
|
@ -200,6 +232,6 @@ public interface SecurityGroupClient {
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void revokeSecurityGroupIngress(String groupName, IpProtocol ipProtocol, int fromPort,
|
void revokeSecurityGroupIngressInRegion(Region region, String groupName, IpProtocol ipProtocol,
|
||||||
int toPort, String cidrIp);
|
int fromPort, int toPort, String cidrIp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DescribeAddressesResponseHandler extends
|
public class DescribeAddressesResponseHandler extends
|
||||||
HandlerWithResult<SortedSet<PublicIpInstanceIdPair>> {
|
HandlerWithResult<Set<PublicIpInstanceIdPair>> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
private SortedSet<PublicIpInstanceIdPair> pairs = Sets.newTreeSet();
|
private Set<PublicIpInstanceIdPair> pairs = Sets.newLinkedHashSet();
|
||||||
private InetAddress ipAddress;
|
private InetAddress ipAddress;
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class DescribeAddressesResponseHandler extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<PublicIpInstanceIdPair> getResult() {
|
public Set<PublicIpInstanceIdPair> getResult() {
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.xml;
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
@ -37,14 +37,14 @@ import com.google.common.collect.Sets;
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<SortedSet<KeyPair>> {
|
public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<Set<KeyPair>> {
|
||||||
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private SortedSet<KeyPair> keyPairs = Sets.newTreeSet();
|
private Set<KeyPair> keyPairs = Sets.newLinkedHashSet();
|
||||||
private String keyFingerprint;
|
private String keyFingerprint;
|
||||||
private String keyName;
|
private String keyName;
|
||||||
|
|
||||||
public SortedSet<KeyPair> getResult() {
|
public Set<KeyPair> getResult() {
|
||||||
return keyPairs;
|
return keyPairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,347 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
package org.jclouds.aws.ec2;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.IpPermission;
|
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
|
||||||
import org.jclouds.aws.ec2.domain.Reservation;
|
|
||||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests behavior of {@code EC2Client}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "live", sequential = true, testName = "ec2.EC2ClientLiveTest")
|
|
||||||
public class EC2ClientLiveTest {
|
|
||||||
|
|
||||||
private EC2Client client;
|
|
||||||
private String user;
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
public void setupClient() {
|
|
||||||
user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
|
||||||
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
|
||||||
|
|
||||||
client = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule()).getApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDescribeAddresses() {
|
|
||||||
SortedSet<PublicIpInstanceIdPair> allResults = client.getElasticIPAddressServices()
|
|
||||||
.describeAddresses();
|
|
||||||
assertNotNull(allResults);
|
|
||||||
if (allResults.size() >= 1) {
|
|
||||||
PublicIpInstanceIdPair pair = allResults.last();
|
|
||||||
SortedSet<PublicIpInstanceIdPair> result = client.getElasticIPAddressServices()
|
|
||||||
.describeAddresses(pair.getPublicIp());
|
|
||||||
assertNotNull(result);
|
|
||||||
PublicIpInstanceIdPair compare = result.last();
|
|
||||||
assertEquals(compare, pair);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDescribeInstances() {
|
|
||||||
SortedSet<Reservation> allResults = client.getInstanceServices().describeInstances();
|
|
||||||
assertNotNull(allResults);
|
|
||||||
assert allResults.size() >= 0 : allResults.size();
|
|
||||||
if (allResults.size() >= 2) {
|
|
||||||
Iterator<Reservation> iterator = allResults.iterator();
|
|
||||||
String id1 = iterator.next().getRunningInstances().first().getInstanceId();
|
|
||||||
String id2 = iterator.next().getRunningInstances().first().getInstanceId();
|
|
||||||
SortedSet<Reservation> twoResults = client.getInstanceServices().describeInstances(id1,
|
|
||||||
id2);
|
|
||||||
assertNotNull(twoResults);
|
|
||||||
assertEquals(twoResults.size(), 2);
|
|
||||||
iterator = allResults.iterator();
|
|
||||||
assertEquals(iterator.next().getRunningInstances().first().getInstanceId(), id1);
|
|
||||||
assertEquals(iterator.next().getRunningInstances().first().getInstanceId(), id2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDescribeKeyPairs() {
|
|
||||||
SortedSet<KeyPair> allResults = client.getKeyPairServices().describeKeyPairs();
|
|
||||||
assertNotNull(allResults);
|
|
||||||
assert allResults.size() >= 0 : allResults.size();
|
|
||||||
if (allResults.size() >= 2) {
|
|
||||||
Iterator<KeyPair> iterator = allResults.iterator();
|
|
||||||
String id1 = iterator.next().getKeyName();
|
|
||||||
String id2 = iterator.next().getKeyName();
|
|
||||||
SortedSet<KeyPair> twoResults = client.getKeyPairServices().describeKeyPairs(id1, id2);
|
|
||||||
assertNotNull(twoResults);
|
|
||||||
assertEquals(twoResults.size(), 2);
|
|
||||||
iterator = twoResults.iterator();
|
|
||||||
assertEquals(iterator.next().getKeyName(), id1);
|
|
||||||
assertEquals(iterator.next().getKeyName(), id2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDescribeSecurityGroups() throws InterruptedException, ExecutionException,
|
|
||||||
TimeoutException {
|
|
||||||
SortedSet<SecurityGroup> allResults = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups();
|
|
||||||
assertNotNull(allResults);
|
|
||||||
assert allResults.size() >= 0 : allResults.size();
|
|
||||||
if (allResults.size() >= 2) {
|
|
||||||
Iterator<SecurityGroup> iterator = allResults.iterator();
|
|
||||||
String id1 = iterator.next().getName();
|
|
||||||
String id2 = iterator.next().getName();
|
|
||||||
SortedSet<SecurityGroup> twoResults = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(id1, id2);
|
|
||||||
assertNotNull(twoResults);
|
|
||||||
assertEquals(twoResults.size(), 2);
|
|
||||||
iterator = twoResults.iterator();
|
|
||||||
assertEquals(iterator.next().getName(), id1);
|
|
||||||
assertEquals(iterator.next().getName(), id2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCreateKeyPair() {
|
|
||||||
String keyName = PREFIX + "1";
|
|
||||||
try {
|
|
||||||
client.getKeyPairServices().deleteKeyPair(keyName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
client.getKeyPairServices().deleteKeyPair(keyName);
|
|
||||||
|
|
||||||
KeyPair result = client.getKeyPairServices().createKeyPair(keyName);
|
|
||||||
assertNotNull(result);
|
|
||||||
assertNotNull(result.getKeyMaterial());
|
|
||||||
assertNotNull(result.getKeyFingerprint());
|
|
||||||
assertEquals(result.getKeyName(), keyName);
|
|
||||||
|
|
||||||
SortedSet<KeyPair> twoResults = client.getKeyPairServices().describeKeyPairs(keyName);
|
|
||||||
assertNotNull(twoResults);
|
|
||||||
assertEquals(twoResults.size(), 1);
|
|
||||||
KeyPair listPair = twoResults.iterator().next();
|
|
||||||
assertEquals(listPair.getKeyName(), result.getKeyName());
|
|
||||||
assertEquals(listPair.getKeyFingerprint(), result.getKeyFingerprint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCreateSecurityGroup() {
|
|
||||||
String groupName = PREFIX + "1";
|
|
||||||
String groupDescription = PREFIX + "1 description";
|
|
||||||
try {
|
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(groupName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(groupName);
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroup(groupName, groupDescription);
|
|
||||||
|
|
||||||
verifySecurityGroup(groupName, groupDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testAuthorizeSecurityGroupIngressCidr() throws InterruptedException, ExecutionException,
|
|
||||||
TimeoutException {
|
|
||||||
String groupName = PREFIX + "ingress";
|
|
||||||
|
|
||||||
try {
|
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(groupName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroup(groupName, groupName);
|
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(groupName, IpProtocol.TCP,
|
|
||||||
80, 80, "0.0.0.0/0");
|
|
||||||
assertEventually(new GroupHasPermission(client, groupName, new IpPermission(80, 80, Sets
|
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().revokeSecurityGroupIngress(groupName, IpProtocol.TCP, 80,
|
|
||||||
80, "0.0.0.0/0");
|
|
||||||
assertEventually(new GroupHasNoPermissions(client, groupName));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifySecurityGroup(String groupName, String description) {
|
|
||||||
SortedSet<SecurityGroup> oneResult = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(groupName);
|
|
||||||
assertNotNull(oneResult);
|
|
||||||
assertEquals(oneResult.size(), 1);
|
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
|
||||||
assertEquals(listPair.getName(), groupName);
|
|
||||||
assertEquals(listPair.getDescription(), description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = false)
|
|
||||||
// TODO
|
|
||||||
void testAuthorizeSecurityGroupIngressSourceGroup() throws InterruptedException {
|
|
||||||
String group1Name = PREFIX + "ingress1";
|
|
||||||
String group2Name = PREFIX + "ingress2";
|
|
||||||
|
|
||||||
try {
|
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(group1Name);
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(group2Name);
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroup(group1Name, group1Name);
|
|
||||||
client.getSecurityGroupServices().createSecurityGroup(group2Name, group2Name);
|
|
||||||
ensureGroupsExist(group1Name, group2Name);
|
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(group1Name, IpProtocol.TCP,
|
|
||||||
80, 80, "0.0.0.0/0");
|
|
||||||
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
|
||||||
|
|
||||||
SortedSet<SecurityGroup> oneResult = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(group1Name);
|
|
||||||
assertNotNull(oneResult);
|
|
||||||
assertEquals(oneResult.size(), 1);
|
|
||||||
SecurityGroup group = oneResult.iterator().next();
|
|
||||||
assertEquals(group.getName(), group1Name);
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(group2Name,
|
|
||||||
new UserIdGroupPair(group.getOwnerId(), group1Name));
|
|
||||||
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
|
||||||
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
|
||||||
|
|
||||||
client.getSecurityGroupServices().revokeSecurityGroupIngress(group2Name,
|
|
||||||
new UserIdGroupPair(group.getOwnerId(), group1Name));
|
|
||||||
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class GroupHasPermission implements Runnable {
|
|
||||||
private final EC2Client client;
|
|
||||||
private final String group;
|
|
||||||
private final IpPermission permission;
|
|
||||||
|
|
||||||
private GroupHasPermission(EC2Client client, String group, IpPermission permission) {
|
|
||||||
this.client = client;
|
|
||||||
this.group = group;
|
|
||||||
this.permission = permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
SortedSet<SecurityGroup> oneResult = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(group);
|
|
||||||
assertNotNull(oneResult);
|
|
||||||
assertEquals(oneResult.size(), 1);
|
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
|
||||||
assert listPair.getIpPermissions().contains(permission);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class GroupHasNoPermissions implements Runnable {
|
|
||||||
private final EC2Client client;
|
|
||||||
private final String group;
|
|
||||||
|
|
||||||
private GroupHasNoPermissions(EC2Client client, String group) {
|
|
||||||
this.client = client;
|
|
||||||
this.group = group;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
SortedSet<SecurityGroup> oneResult = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(group);
|
|
||||||
assertNotNull(oneResult);
|
|
||||||
assertEquals(oneResult.size(), 1);
|
|
||||||
SecurityGroup listPair = oneResult.iterator().next();
|
|
||||||
assertEquals(listPair.getIpPermissions().size(), 0);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureGroupsExist(String group1Name, String group2Name) {
|
|
||||||
SortedSet<SecurityGroup> twoResults = client.getSecurityGroupServices()
|
|
||||||
.describeSecurityGroups(group1Name, group2Name);
|
|
||||||
assertNotNull(twoResults);
|
|
||||||
assertEquals(twoResults.size(), 2);
|
|
||||||
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
|
||||||
SecurityGroup listPair1 = iterator.next();
|
|
||||||
assertEquals(listPair1.getName(), group1Name);
|
|
||||||
assertEquals(listPair1.getDescription(), group1Name);
|
|
||||||
|
|
||||||
SecurityGroup listPair2 = iterator.next();
|
|
||||||
assertEquals(listPair2.getName(), group2Name);
|
|
||||||
assertEquals(listPair2.getDescription(), group2Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int INCONSISTENCY_WINDOW = 5000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Due to eventual consistency, container commands may not return correctly immediately. Hence,
|
|
||||||
* we will try up to the inconsistency window to see if the assertion completes.
|
|
||||||
*/
|
|
||||||
protected static void assertEventually(Runnable assertion) throws InterruptedException {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
AssertionError error = null;
|
|
||||||
for (int i = 0; i < 30; i++) {
|
|
||||||
try {
|
|
||||||
assertion.run();
|
|
||||||
if (i > 0)
|
|
||||||
System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System
|
|
||||||
.currentTimeMillis()
|
|
||||||
- start, assertion.getClass().getSimpleName());
|
|
||||||
return;
|
|
||||||
} catch (AssertionError e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
Thread.sleep(INCONSISTENCY_WINDOW / 30);
|
|
||||||
}
|
|
||||||
if (error != null)
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -42,6 +42,7 @@ import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Reservation;
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
@ -56,6 +57,7 @@ import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,30 +99,32 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
securityGroupName = serverPrefix + "ingress";
|
securityGroupName = serverPrefix + "ingress";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(securityGroupName);
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
||||||
|
securityGroupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.getSecurityGroupServices().createSecurityGroup(securityGroupName, securityGroupName);
|
client.getSecurityGroupServices().createSecurityGroupInRegion(Region.DEFAULT,
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(securityGroupName,
|
securityGroupName, securityGroupName);
|
||||||
IpProtocol.TCP, 80, 80, "0.0.0.0/0");
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(securityGroupName,
|
securityGroupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0");
|
||||||
IpProtocol.TCP, 443, 443, "0.0.0.0/0");
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
||||||
client.getSecurityGroupServices().authorizeSecurityGroupIngress(securityGroupName,
|
securityGroupName, IpProtocol.TCP, 443, 443, "0.0.0.0/0");
|
||||||
IpProtocol.TCP, 22, 22, "0.0.0.0/0");
|
client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(Region.DEFAULT,
|
||||||
|
securityGroupName, IpProtocol.TCP, 22, 22, "0.0.0.0/0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String keyName = serverPrefix + "1";
|
String keyName = serverPrefix + "1";
|
||||||
try {
|
try {
|
||||||
client.getKeyPairServices().deleteKeyPair(keyName);
|
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
client.getKeyPairServices().deleteKeyPair(keyName);
|
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
|
|
||||||
keyPair = client.getKeyPairServices().createKeyPair(keyName);
|
keyPair = client.getKeyPairServices().createKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
assertNotNull(keyPair);
|
assertNotNull(keyPair);
|
||||||
assertNotNull(keyPair.getKeyMaterial());
|
assertNotNull(keyPair.getKeyMaterial());
|
||||||
assertNotNull(keyPair.getKeyFingerprint());
|
assertNotNull(keyPair.getKeyFingerprint());
|
||||||
|
@ -135,7 +139,9 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
while (server == null) {
|
while (server == null) {
|
||||||
try {
|
try {
|
||||||
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
System.out.printf("%d: running instance%n", System.currentTimeMillis());
|
||||||
server = client.getInstanceServices().runInstances(
|
server = client.getInstanceServices().runInstancesInRegion(
|
||||||
|
Region.DEFAULT,
|
||||||
|
null,
|
||||||
imageId,
|
imageId,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
@ -161,37 +167,42 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
@Test(enabled = true, dependsOnMethods = "testCreateRunningInstance")
|
@Test(enabled = true, dependsOnMethods = "testCreateRunningInstance")
|
||||||
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
address = client.getElasticIPAddressServices().allocateAddress();
|
address = client.getElasticIPAddressServices().allocateAddressInRegion(Region.DEFAULT);
|
||||||
assertNotNull(address);
|
assertNotNull(address);
|
||||||
|
|
||||||
PublicIpInstanceIdPair compare = client.getElasticIPAddressServices().describeAddresses(
|
PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressServices()
|
||||||
address).last();
|
.describeAddressesInRegion(Region.DEFAULT, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assert compare.getInstanceId() == null;
|
assert compare.getInstanceId() == null;
|
||||||
|
|
||||||
client.getElasticIPAddressServices().associateAddress(address, serverId);
|
client.getElasticIPAddressServices().associateAddressInRegion(Region.DEFAULT, address,
|
||||||
|
serverId);
|
||||||
|
|
||||||
compare = client.getElasticIPAddressServices().describeAddresses(address).last();
|
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
||||||
|
Region.DEFAULT, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assertEquals(compare.getInstanceId(), serverId);
|
assertEquals(compare.getInstanceId(), serverId);
|
||||||
|
|
||||||
Reservation reservation = client.getInstanceServices().describeInstances(serverId).last();
|
Reservation reservation = client.getInstanceServices().describeInstancesInRegion(
|
||||||
|
Region.DEFAULT, serverId).last();
|
||||||
|
|
||||||
assertNotNull(reservation.getRunningInstances().last().getIpAddress());
|
assertNotNull(reservation.getRunningInstances().last().getIpAddress());
|
||||||
assertFalse(reservation.getRunningInstances().last().getIpAddress().equals(address));
|
assertFalse(reservation.getRunningInstances().last().getIpAddress().equals(address));
|
||||||
|
|
||||||
doCheckKey(address);
|
doCheckKey(address);
|
||||||
|
|
||||||
client.getElasticIPAddressServices().disassociateAddress(address);
|
client.getElasticIPAddressServices().disassociateAddressInRegion(Region.DEFAULT, address);
|
||||||
|
|
||||||
compare = client.getElasticIPAddressServices().describeAddresses(address).last();
|
compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(
|
||||||
|
Region.DEFAULT, address));
|
||||||
|
|
||||||
assertEquals(compare.getPublicIp(), address);
|
assertEquals(compare.getPublicIp(), address);
|
||||||
assert compare.getInstanceId() == null;
|
assert compare.getInstanceId() == null;
|
||||||
|
|
||||||
reservation = client.getInstanceServices().describeInstances(serverId).last();
|
reservation = client.getInstanceServices()
|
||||||
|
.describeInstancesInRegion(Region.DEFAULT, serverId).last();
|
||||||
// assert reservation.getRunningInstances().last().getIpAddress() == null; TODO
|
// assert reservation.getRunningInstances().last().getIpAddress() == null; TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,19 +258,20 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
@AfterTest
|
@AfterTest
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
if (address != null)
|
if (address != null)
|
||||||
client.getElasticIPAddressServices().releaseAddress(address);
|
client.getElasticIPAddressServices().releaseAddressInRegion(Region.DEFAULT, address);
|
||||||
if (serverId != null)
|
if (serverId != null)
|
||||||
client.getInstanceServices().terminateInstances(serverId);
|
client.getInstanceServices().terminateInstancesInRegion(Region.DEFAULT, serverId);
|
||||||
if (keyPair != null)
|
if (keyPair != null)
|
||||||
client.getKeyPairServices().deleteKeyPair(keyPair.getKeyName());
|
client.getKeyPairServices().deleteKeyPairInRegion(Region.DEFAULT, keyPair.getKeyName());
|
||||||
if (securityGroupName != null)
|
if (securityGroupName != null)
|
||||||
client.getSecurityGroupServices().deleteSecurityGroup(securityGroupName);
|
client.getSecurityGroupServices().deleteSecurityGroupInRegion(Region.DEFAULT,
|
||||||
|
securityGroupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningInstance getRunningInstance(String serverId) throws InterruptedException,
|
private RunningInstance getRunningInstance(String serverId) throws InterruptedException,
|
||||||
ExecutionException, TimeoutException {
|
ExecutionException, TimeoutException {
|
||||||
return client.getInstanceServices().describeInstances(serverId).first().getRunningInstances()
|
return client.getInstanceServices().describeInstancesInRegion(Region.DEFAULT, serverId)
|
||||||
.first();
|
.first().getRunningInstances().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ package org.jclouds.aws.ec2.options;
|
||||||
|
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.asType;
|
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.asType;
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.enableMonitoring;
|
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.enableMonitoring;
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.inAvailabilityZone;
|
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withAdditionalInfo;
|
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withAdditionalInfo;
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withDeviceName;
|
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withDeviceName;
|
||||||
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withKernelId;
|
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withKernelId;
|
||||||
|
@ -136,8 +135,7 @@ public class RunInstancesOptionsTest {
|
||||||
public void testWithUserData() {
|
public void testWithUserData() {
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
RunInstancesOptions options = new RunInstancesOptions();
|
||||||
options.withUserData("test");
|
options.withUserData("test");
|
||||||
assertEquals(options.buildFormParameters().get("UserData"), Collections
|
assertEquals(options.buildFormParameters().get("UserData"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -149,8 +147,7 @@ public class RunInstancesOptionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testWithUserDataStatic() {
|
public void testWithUserDataStatic() {
|
||||||
RunInstancesOptions options = withUserData("test");
|
RunInstancesOptions options = withUserData("test");
|
||||||
assertEquals(options.buildFormParameters().get("UserData"), Collections
|
assertEquals(options.buildFormParameters().get("UserData"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
@ -184,39 +181,11 @@ public class RunInstancesOptionsTest {
|
||||||
asType(null);
|
asType(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInAvailabilityZone() {
|
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
|
||||||
options.inAvailabilityZone("test");
|
|
||||||
assertEquals(options.buildFormParameters().get("Placement.AvailabilityZone"), Collections
|
|
||||||
.singletonList("test"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNullAvailabilityZone() {
|
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
|
||||||
assertEquals(options.buildFormParameters().get("Placement.AvailabilityZone"),
|
|
||||||
Collections.EMPTY_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInAvailabilityZoneStatic() {
|
|
||||||
RunInstancesOptions options = inAvailabilityZone("test");
|
|
||||||
assertEquals(options.buildFormParameters().get("Placement.AvailabilityZone"), Collections
|
|
||||||
.singletonList("test"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
|
||||||
public void testInAvailabilityZoneNPE() {
|
|
||||||
inAvailabilityZone(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithKernelId() {
|
public void testWithKernelId() {
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
RunInstancesOptions options = new RunInstancesOptions();
|
||||||
options.withKernelId("test");
|
options.withKernelId("test");
|
||||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections
|
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -228,8 +197,7 @@ public class RunInstancesOptionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testWithKernelIdStatic() {
|
public void testWithKernelIdStatic() {
|
||||||
RunInstancesOptions options = withKernelId("test");
|
RunInstancesOptions options = withKernelId("test");
|
||||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections
|
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
@ -289,8 +257,7 @@ public class RunInstancesOptionsTest {
|
||||||
public void testWithSubnetId() {
|
public void testWithSubnetId() {
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
RunInstancesOptions options = new RunInstancesOptions();
|
||||||
options.withSubnetId("test");
|
options.withSubnetId("test");
|
||||||
assertEquals(options.buildFormParameters().get("SubnetId"), Collections
|
assertEquals(options.buildFormParameters().get("SubnetId"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -302,8 +269,7 @@ public class RunInstancesOptionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testWithSubnetIdStatic() {
|
public void testWithSubnetIdStatic() {
|
||||||
RunInstancesOptions options = withSubnetId("test");
|
RunInstancesOptions options = withSubnetId("test");
|
||||||
assertEquals(options.buildFormParameters().get("SubnetId"), Collections
|
assertEquals(options.buildFormParameters().get("SubnetId"), Collections.singletonList("test"));
|
||||||
.singletonList("test"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
@ -341,8 +307,8 @@ public class RunInstancesOptionsTest {
|
||||||
public void testWithVirtualName() {
|
public void testWithVirtualName() {
|
||||||
RunInstancesOptions options = new RunInstancesOptions();
|
RunInstancesOptions options = new RunInstancesOptions();
|
||||||
options.withVirtualName("test");
|
options.withVirtualName("test");
|
||||||
assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"),
|
assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), Collections
|
||||||
Collections.singletonList("test"));
|
.singletonList("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -355,8 +321,8 @@ public class RunInstancesOptionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testWithVirtualNameStatic() {
|
public void testWithVirtualNameStatic() {
|
||||||
RunInstancesOptions options = withVirtualName("test");
|
RunInstancesOptions options = withVirtualName("test");
|
||||||
assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"),
|
assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), Collections
|
||||||
Collections.singletonList("test"));
|
.singletonList("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
|
|
@ -30,8 +30,12 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
|
@ -56,6 +60,7 @@ import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -70,16 +75,17 @@ import com.google.inject.TypeLiteral;
|
||||||
public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("createImage", String.class, String.class,
|
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
||||||
Array.newInstance(CreateImageOptions.class, 0).getClass());
|
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
.getClass());
|
||||||
"instanceId");
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "name", "instanceId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 69\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 69\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateImage&Name=name&InstanceId=instanceId");
|
"Version=2009-11-30&Action=CreateImage&InstanceId=instanceId&Name=name");
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
@ -89,17 +95,19 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testCreateImageOptions() throws SecurityException, NoSuchMethodException,
|
public void testCreateImageOptions() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("createImage", String.class, String.class,
|
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", Region.class,
|
||||||
Array.newInstance(CreateImageOptions.class, 0).getClass());
|
String.class, String.class, Array.newInstance(CreateImageOptions.class, 0)
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
.getClass());
|
||||||
"instanceId", new CreateImageOptions().withDescription("description").noReboot());
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "name", "instanceId", new CreateImageOptions().withDescription(
|
||||||
|
"description").noReboot());
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 107\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 107\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateImage&Name=name&InstanceId=instanceId&Description=description&NoReboot=true");
|
"Version=2009-11-30&Action=CreateImage&InstanceId=instanceId&Name=name&Description=description&NoReboot=true");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
|
@ -109,8 +117,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("describeImages", Array.newInstance(
|
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
||||||
DescribeImagesOptions.class, 0).getClass());
|
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
|
@ -131,10 +139,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException,
|
public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("describeImages", Array.newInstance(
|
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", Region.class, Array
|
||||||
DescribeImagesOptions.class, 0).getClass());
|
.newInstance(DescribeImagesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
executableBy("me").ownedBy("fred", "nancy").imageIds("1", "2"));
|
Region.DEFAULT, executableBy("me").ownedBy("fred", "nancy").imageIds("1", "2"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -151,8 +159,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("deregisterImage", String.class);
|
Method method = AMIAsyncClient.class.getMethod("deregisterImageInRegion", Region.class,
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
String.class);
|
||||||
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -168,16 +178,17 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException,
|
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifest", String.class,
|
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
||||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
RegisterImageOptions.class, 0).getClass());
|
||||||
"pathToManifest");
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "name", "pathToManifest");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 78\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 78\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=RegisterImage&Name=name&ImageLocation=pathToManifest");
|
"Version=2009-11-30&Action=RegisterImage&ImageLocation=pathToManifest&Name=name");
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
@ -187,17 +198,19 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRegisterImageFromManifestOptions() throws SecurityException,
|
public void testRegisterImageFromManifestOptions() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifest", String.class,
|
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion",
|
||||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
RegisterImageOptions.class, 0).getClass());
|
||||||
"pathToManifest", new RegisterImageOptions().withDescription("description"));
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "name", "pathToManifest", new RegisterImageOptions()
|
||||||
|
.withDescription("description"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 102\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 102\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=RegisterImage&Name=name&ImageLocation=pathToManifest&Description=description");
|
"Version=2009-11-30&Action=RegisterImage&ImageLocation=pathToManifest&Name=name&Description=description");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
|
@ -208,18 +221,18 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException,
|
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class
|
Method method = AMIAsyncClient.class.getMethod("registerImageBackedByEbsInRegion",
|
||||||
.getMethod("registerImageBackedByEbs", String.class, String.class, Array
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"imageName", "snapshotId");
|
Region.DEFAULT, "imageName", "snapshotId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 176\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 176\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&Name=imageName&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId");
|
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName");
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
@ -229,20 +242,21 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRegisterImageBackedByEBSOptions() throws SecurityException,
|
public void testRegisterImageBackedByEBSOptions() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class
|
Method method = AMIAsyncClient.class.getMethod("registerImageBackedByEbsInRegion",
|
||||||
.getMethod("registerImageBackedByEbs", String.class, String.class, Array
|
Region.class, String.class, String.class, Array.newInstance(
|
||||||
.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription(
|
Region.DEFAULT, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions()
|
||||||
"description").addBlockDeviceFromSnapshot("/dev/device", null, "snapshot")
|
.withDescription("description").addBlockDeviceFromSnapshot("/dev/device",
|
||||||
.addNewBlockDevice("/dev/newdevice", "newblock", 100));
|
null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock",
|
||||||
|
100));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 528\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 528\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&Name=imageName&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100");
|
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||||
|
@ -253,8 +267,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException,
|
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImage", String.class);
|
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion",
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
Region.class, String.class);
|
||||||
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -271,8 +287,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testGetProductCodesForImage() throws SecurityException, NoSuchMethodException,
|
public void testGetProductCodesForImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("getProductCodesForImage", String.class);
|
Method method = AMIAsyncClient.class.getMethod("getProductCodesForImageInRegion",
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
Region.class, String.class);
|
||||||
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -289,9 +307,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testGetBlockDeviceMappingsForImage() throws SecurityException,
|
public void testGetBlockDeviceMappingsForImage() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class
|
Method method = AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion",
|
||||||
.getMethod("getBlockDeviceMappingsForImage", String.class);
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -308,17 +327,17 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException,
|
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImage", Iterable.class,
|
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion",
|
||||||
Iterable.class, String.class);
|
Region.class, Iterable.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 107\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 107\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserId.1=bob&UserId.2=sue&UserGroup.1=all");
|
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue");
|
||||||
filter.filter(httpMethod);
|
filter.filter(httpMethod);
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
|
@ -333,22 +352,17 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRemoveLaunchPermissionsFromImage() throws SecurityException,
|
public void testRemoveLaunchPermissionsFromImage() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImage",
|
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion",
|
||||||
Iterable.class, Iterable.class, String.class);
|
Region.class, Iterable.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
Region.DEFAULT, ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 110\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 110\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserId.1=bob&UserId.2=sue&UserGroup.1=all");
|
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue");
|
||||||
filter.filter(httpMethod);
|
|
||||||
assertPayloadEquals(
|
|
||||||
httpMethod,
|
|
||||||
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=remove&Signature=hgjXXq6PXEuHCIsp5izCTJqS%2Biv2ZdnIv0VSV1kYy%2BE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2009-11-30&AWSAccessKeyId=user");
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
@ -358,8 +372,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException,
|
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImage", String.class);
|
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion",
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
Region.class, String.class);
|
||||||
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -375,10 +391,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testAddProductCodesToImage() throws SecurityException, NoSuchMethodException,
|
public void testAddProductCodesToImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("addProductCodesToImage", Iterable.class,
|
Method method = AMIAsyncClient.class.getMethod("addProductCodesToImageInRegion",
|
||||||
String.class);
|
Region.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
ImmutableList.of("code1", "code2"), "imageId");
|
Region.DEFAULT, ImmutableList.of("code1", "code2"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -396,10 +412,10 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
public void testRemoveProductCodesFromImage() throws SecurityException, NoSuchMethodException,
|
public void testRemoveProductCodesFromImage() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = AMIAsyncClient.class.getMethod("removeProductCodesFromImage", Iterable.class,
|
Method method = AMIAsyncClient.class.getMethod("removeProductCodesFromImageInRegion",
|
||||||
String.class);
|
Region.class, Iterable.class, String.class);
|
||||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
ImmutableList.of("code1", "code2"), "imageId");
|
Region.DEFAULT, ImmutableList.of("code1", "code2"), "imageId");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -460,6 +476,16 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,8 @@ 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.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||||
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withDescription;
|
|
||||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
||||||
|
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withDescription;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@ -39,6 +38,7 @@ import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.EC2ContextFactory;
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||||
import org.jclouds.aws.ec2.domain.Image.RootDeviceType;
|
import org.jclouds.aws.ec2.domain.Image.RootDeviceType;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
@ -47,6 +47,7 @@ import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
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.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.internal.ImmutableMap;
|
import com.google.inject.internal.ImmutableMap;
|
||||||
|
@ -78,25 +79,30 @@ public class AMIClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() {
|
public void testDescribeImages() {
|
||||||
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImages());
|
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
|
Region.US_WEST_1)) {
|
||||||
|
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImagesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 2 : allResults.size();
|
||||||
Iterator<Image> iterator = allResults.iterator();
|
Iterator<Image> iterator = allResults.iterator();
|
||||||
String id1 = iterator.next().getImageId();
|
String id1 = iterator.next().getImageId();
|
||||||
String id2 = iterator.next().getImageId();
|
String id2 = iterator.next().getImageId();
|
||||||
SortedSet<Image> twoResults = Sets.newTreeSet(client.describeImages(imageIds(id1, id2)));
|
SortedSet<Image> twoResults = Sets.newTreeSet(client.describeImagesInRegion(region,
|
||||||
|
imageIds(id1, id2)));
|
||||||
assertNotNull(twoResults);
|
assertNotNull(twoResults);
|
||||||
assertEquals(twoResults.size(), 2);
|
assertEquals(twoResults.size(), 2);
|
||||||
iterator = twoResults.iterator();
|
iterator = twoResults.iterator();
|
||||||
assertEquals(iterator.next().getImageId(), id1);
|
assertEquals(iterator.next().getImageId(), id1);
|
||||||
assertEquals(iterator.next().getImageId(), id2);
|
assertEquals(iterator.next().getImageId(), id2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testRegisterImageFromManifest() {
|
public void testRegisterImageFromManifest() {
|
||||||
String imageRegisteredId = client.registerImageFromManifest("jcloudstest1", DEFAULT_MANIFEST);
|
String imageRegisteredId = client.registerImageFromManifestInRegion(Region.DEFAULT,
|
||||||
|
"jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client
|
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
.describeImages(imageIds(imageRegisteredId)));
|
Region.DEFAULT, 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);
|
||||||
|
@ -105,11 +111,11 @@ public class AMIClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRegisterImageFromManifestOptions() {
|
public void testRegisterImageFromManifestOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerImageFromManifest("jcloudstest2",
|
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(
|
||||||
DEFAULT_MANIFEST, withDescription("adrian"));
|
Region.DEFAULT, "jcloudstest2", DEFAULT_MANIFEST, withDescription("adrian"));
|
||||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client
|
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client
|
||||||
.describeImages(imageIds(imageRegisteredWithOptionsId)));
|
.describeImagesInRegion(Region.DEFAULT, 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);
|
||||||
|
@ -122,10 +128,11 @@ public class AMIClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// awaiting EBS functionality to be added to jclouds
|
// awaiting EBS functionality to be added to jclouds
|
||||||
public void testRegisterImageBackedByEBS() {
|
public void testRegisterImageBackedByEBS() {
|
||||||
String imageRegisteredId = client.registerImageBackedByEbs("jcloudstest1", DEFAULT_MANIFEST);
|
String imageRegisteredId = client.registerImageBackedByEbsInRegion(Region.DEFAULT,
|
||||||
|
"jcloudstest1", DEFAULT_MANIFEST);
|
||||||
imagesToDeregister.add(imageRegisteredId);
|
imagesToDeregister.add(imageRegisteredId);
|
||||||
Image imageRegistered = Iterables.getOnlyElement(client
|
Image imageRegistered = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
.describeImages(imageIds(imageRegisteredId)));
|
Region.DEFAULT, 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);
|
||||||
|
@ -135,12 +142,12 @@ public class AMIClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// awaiting EBS functionality to be added to jclouds
|
// awaiting EBS functionality to be added to jclouds
|
||||||
public void testRegisterImageBackedByEBSOptions() {
|
public void testRegisterImageBackedByEBSOptions() {
|
||||||
String imageRegisteredWithOptionsId = client.registerImageBackedByEbs("jcloudstest2",
|
String imageRegisteredWithOptionsId = client.registerImageBackedByEbsInRegion(Region.DEFAULT,
|
||||||
DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription(
|
"jcloudstest2", DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1)
|
||||||
"adrian"));
|
.withDescription("adrian"));
|
||||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||||
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client
|
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(
|
||||||
.describeImages(imageIds(imageRegisteredWithOptionsId)));
|
Region.DEFAULT, 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);
|
||||||
|
@ -153,46 +160,48 @@ public class AMIClientLiveTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testCreateImage() {
|
public void testCreateImage() {
|
||||||
// TODO client.createImage(name, instanceId, options);
|
// TODO client.createImageInRegion(Region.DEFAULT, name, instanceId, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddLaunchPermissionsToImage() {
|
public void testAddLaunchPermissionsToImage() {
|
||||||
// TODO client.addLaunchPermissionsToImage(userIds, userGroups, imageId);
|
// TODO client.addLaunchPermissionsToImageInRegion(Region.DEFAULT, userIds, userGroups,
|
||||||
|
// imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddProductCodesToImage() {
|
public void testAddProductCodesToImage() {
|
||||||
// TODO client.addProductCodesToImage(productCodes, imageId);
|
// TODO client.addProductCodesToImageInRegion(Region.DEFAULT, productCodes, imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRemoveLaunchPermissionsFromImage() {
|
public void testRemoveLaunchPermissionsFromImage() {
|
||||||
// TODO client.removeLaunchPermissionsFromImage(userIds, userGroups, imageId);
|
// TODO client.removeLaunchPermissionsFromImageInRegion(Region.DEFAULT, userIds, userGroups,
|
||||||
|
// imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testResetLaunchPermissionsOnImage() {
|
public void testResetLaunchPermissionsOnImage() {
|
||||||
// TODO client.resetLaunchPermissionsOnImage(imageId);
|
// TODO client.resetLaunchPermissionsOnImageInRegion(Region.DEFAULT, imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLaunchPermissionForImage() {
|
public void testGetLaunchPermissionForImage() {
|
||||||
System.out.println(client.getLaunchPermissionForImage(imageId));
|
System.out.println(client.getLaunchPermissionForImageInRegion(Region.DEFAULT, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetProductCodesForImage() {
|
public void testGetProductCodesForImage() {
|
||||||
System.out.println(client.getProductCodesForImage(imageId));
|
System.out.println(client.getProductCodesForImageInRegion(Region.DEFAULT, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// awaiting ebs support
|
// awaiting ebs support
|
||||||
public void testGetBlockDeviceMappingsForImage() {
|
public void testGetBlockDeviceMappingsForImage() {
|
||||||
System.out.println(client.getBlockDeviceMappingsForImage(imageId));
|
System.out.println(client.getBlockDeviceMappingsForImageInRegion(Region.DEFAULT, imageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
public void deregisterImages() {
|
public void deregisterImages() {
|
||||||
for (String imageId : imagesToDeregister)
|
for (String imageId : imagesToDeregister)
|
||||||
client.deregisterImage(imageId);
|
client.deregisterImageInRegion(Region.DEFAULT, imageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,12 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
||||||
|
@ -47,6 +51,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -62,10 +67,10 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
|
|
||||||
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException,
|
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("disassociateAddress",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion",
|
||||||
InetAddress.class);
|
Region.class, InetAddress.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -81,16 +86,16 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAssociateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAssociateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("associateAddress",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion",
|
||||||
InetAddress.class, String.class);
|
Region.class, InetAddress.class, String.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), "me");
|
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), "me");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 75\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 75\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=AssociateAddress&PublicIp=127.0.0.1&InstanceId=me");
|
"Version=2009-11-30&Action=AssociateAddress&InstanceId=me&PublicIp=127.0.0.1");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
@ -100,10 +105,10 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReleaseAddress() throws SecurityException, NoSuchMethodException, IOException {
|
public void testReleaseAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("releaseAddress",
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion",
|
||||||
InetAddress.class);
|
Region.class, InetAddress.class);
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -118,10 +123,10 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeAddresses() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeAddresses() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("describeAddresses", Array
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion",
|
||||||
.newInstance(InetAddress.class, 0).getClass());
|
Region.class, Array.newInstance(InetAddress.class, 0).getClass());
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
method, Region.DEFAULT, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -137,9 +142,10 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAllocateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("allocateAddress");
|
Method method = ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion",
|
||||||
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor
|
Region.class);
|
||||||
.createRequest(method);
|
GeneratedHttpRequest<ElasticIPAddressAsyncClient> httpMethod = processor.createRequest(
|
||||||
|
method, Region.DEFAULT);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -189,6 +195,16 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ElasticIPAddressClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "ec2.ElasticIPAddressClientLiveTest")
|
||||||
|
public class ElasticIPAddressClientLiveTest {
|
||||||
|
|
||||||
|
private ElasticIPAddressClient client;
|
||||||
|
private RestContext<EC2AsyncClient, EC2Client> context;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||||
|
|
||||||
|
context = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule());
|
||||||
|
client = context.getApi().getElasticIPAddressServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDescribeAddresses() {
|
||||||
|
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
|
Region.US_WEST_1)) {
|
||||||
|
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client
|
||||||
|
.describeAddressesInRegion(region));
|
||||||
|
assertNotNull(allResults);
|
||||||
|
if (allResults.size() >= 1) {
|
||||||
|
PublicIpInstanceIdPair pair = allResults.last();
|
||||||
|
SortedSet<PublicIpInstanceIdPair> result = Sets.newTreeSet(client
|
||||||
|
.describeAddressesInRegion(region, pair.getPublicIp()));
|
||||||
|
assertNotNull(result);
|
||||||
|
PublicIpInstanceIdPair compare = result.last();
|
||||||
|
assertEquals(compare, pair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
public void shutdown() {
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,13 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeInstancesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeInstancesResponseHandler;
|
||||||
|
@ -47,6 +52,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -61,9 +67,10 @@ import com.google.inject.TypeLiteral;
|
||||||
public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient> {
|
public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient> {
|
||||||
|
|
||||||
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("describeInstances", Array.newInstance(
|
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
||||||
String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -79,10 +86,10 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
|
|
||||||
public void testDescribeInstancesArgs() throws SecurityException, NoSuchMethodException,
|
public void testDescribeInstancesArgs() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("describeInstances", Array.newInstance(
|
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion",
|
||||||
String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, "1",
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"2");
|
Region.DEFAULT, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -99,10 +106,10 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
|
|
||||||
public void testTerminateInstances() throws SecurityException, NoSuchMethodException,
|
public void testTerminateInstances() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("terminateInstances", String.class, Array
|
Method method = InstanceAsyncClient.class.getMethod("terminateInstancesInRegion",
|
||||||
.newInstance(String.class, 0).getClass());
|
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method, "1",
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"2");
|
Region.DEFAULT, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -118,16 +125,17 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("runInstances", String.class, int.class,
|
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", Region.class,
|
||||||
int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
AvailabilityZone.class, String.class, int.class, int.class, Array.newInstance(
|
||||||
|
RunInstancesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"ami-voo", 1, 1);
|
Region.DEFAULT, null, "ami-voo", 1, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 76\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 76\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MaxCount=1&MinCount=1");
|
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, RunInstancesResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, RunInstancesResponseHandler.class);
|
||||||
|
@ -138,18 +146,20 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
|
|
||||||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException,
|
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = InstanceAsyncClient.class.getMethod("runInstances", String.class, int.class,
|
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", Region.class,
|
||||||
int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
AvailabilityZone.class, String.class, int.class, int.class, Array.newInstance(
|
||||||
|
RunInstancesOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<InstanceAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"ami-voo", 1, 5, new RunInstancesOptions().withKernelId("kernelId")
|
Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", 1, 5,
|
||||||
.enableMonitoring());
|
new RunInstancesOptions().withKernelId("kernelId").enableMonitoring());
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(
|
||||||
"Content-Length: 118\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
httpMethod,
|
||||||
|
"Content-Length: 118\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.eu-west-1.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true");
|
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&Placement.AvailabilityZone=eu-west-1a");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, RunInstancesResponseHandler.class);
|
assertSaxResponseParserClassEquals(method, RunInstancesResponseHandler.class);
|
||||||
|
@ -194,6 +204,16 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.domain.Reservation;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code EC2Client}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "ec2.InstanceClientLiveTest")
|
||||||
|
public class InstanceClientLiveTest {
|
||||||
|
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
||||||
|
|
||||||
|
private InstanceClient client;
|
||||||
|
private String user;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||||
|
|
||||||
|
client = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule()).getApi()
|
||||||
|
.getInstanceServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDescribeInstances() {
|
||||||
|
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
|
Region.US_WEST_1)) {
|
||||||
|
SortedSet<Reservation> allResults = client.describeInstancesInRegion(region);
|
||||||
|
assertNotNull(allResults);
|
||||||
|
assert allResults.size() >= 0 : allResults.size();
|
||||||
|
if (allResults.size() >= 2) {
|
||||||
|
Iterator<Reservation> iterator = allResults.iterator();
|
||||||
|
String id1 = iterator.next().getRunningInstances().first().getInstanceId();
|
||||||
|
String id2 = iterator.next().getRunningInstances().first().getInstanceId();
|
||||||
|
SortedSet<Reservation> twoResults = client.describeInstancesInRegion(region, id1, id2);
|
||||||
|
assertNotNull(twoResults);
|
||||||
|
assertEquals(twoResults.size(), 2);
|
||||||
|
iterator = allResults.iterator();
|
||||||
|
assertEquals(iterator.next().getRunningInstances().first().getInstanceId(), id1);
|
||||||
|
assertEquals(iterator.next().getRunningInstances().first().getInstanceId(), id2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -29,8 +29,12 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
|
@ -45,6 +49,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -59,9 +64,10 @@ import com.google.inject.TypeLiteral;
|
||||||
public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
|
|
||||||
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("deleteKeyPair", String.class);
|
Method method = KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", Region.class,
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor
|
String.class);
|
||||||
.createRequest(method, "mykey");
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT, "mykey");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -76,9 +82,10 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDescribeKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairs", Array.newInstance(
|
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
||||||
String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -94,10 +101,10 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
|
|
||||||
public void testDescribeKeyPairsArgs() throws SecurityException, NoSuchMethodException,
|
public void testDescribeKeyPairsArgs() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairs", Array.newInstance(
|
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", Region.class,
|
||||||
String.class, 0).getClass());
|
Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method, "1",
|
GeneratedHttpRequest<KeyPairAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"2");
|
Region.DEFAULT, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -148,6 +155,16 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code KeyPairClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "ec2.KeyPairClientLiveTest")
|
||||||
|
public class KeyPairClientLiveTest {
|
||||||
|
|
||||||
|
private KeyPairClient client;
|
||||||
|
private RestContext<EC2AsyncClient, EC2Client> context;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||||
|
|
||||||
|
context = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule());
|
||||||
|
client = context.getApi().getKeyPairServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDescribeAddresses() {
|
||||||
|
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
|
Region.US_WEST_1)) {
|
||||||
|
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
||||||
|
assertNotNull(allResults);
|
||||||
|
if (allResults.size() >= 1) {
|
||||||
|
KeyPair pair = allResults.last();
|
||||||
|
SortedSet<KeyPair> result = Sets.newTreeSet(client.describeKeyPairsInRegion(region,
|
||||||
|
pair.getKeyName()));
|
||||||
|
assertNotNull(result);
|
||||||
|
KeyPair compare = result.last();
|
||||||
|
assertEquals(compare, pair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCreateKeyPair() {
|
||||||
|
String keyName = PREFIX + "1";
|
||||||
|
try {
|
||||||
|
client.deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
client.deleteKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
|
|
||||||
|
KeyPair result = client.createKeyPairInRegion(Region.DEFAULT, keyName);
|
||||||
|
assertNotNull(result);
|
||||||
|
assertNotNull(result.getKeyMaterial());
|
||||||
|
assertNotNull(result.getKeyFingerprint());
|
||||||
|
assertEquals(result.getKeyName(), keyName);
|
||||||
|
|
||||||
|
SortedSet<KeyPair> twoResults = Sets.newTreeSet(client.describeKeyPairsInRegion(
|
||||||
|
Region.DEFAULT, keyName));
|
||||||
|
assertNotNull(twoResults);
|
||||||
|
assertEquals(twoResults.size(), 1);
|
||||||
|
KeyPair listPair = twoResults.iterator().next();
|
||||||
|
assertEquals(listPair.getKeyName(), result.getKeyName());
|
||||||
|
assertEquals(listPair.getKeyFingerprint(), result.getKeyFingerprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
public void shutdown() {
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,12 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
|
@ -44,6 +48,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -59,10 +64,10 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
|
|
||||||
public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException,
|
public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = MonitoringAsyncClient.class.getMethod("unmonitorInstances", String.class,
|
Method method = MonitoringAsyncClient.class.getMethod("unmonitorInstancesInRegion",
|
||||||
Array.newInstance(String.class, 0).getClass());
|
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"instance1", "instance2");
|
Region.DEFAULT, "instance1", "instance2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -77,12 +82,11 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMonitorInstances() throws SecurityException, NoSuchMethodException,
|
public void testMonitorInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
IOException {
|
Method method = MonitoringAsyncClient.class.getMethod("monitorInstancesInRegion",
|
||||||
Method method = MonitoringAsyncClient.class.getMethod("monitorInstances", String.class,
|
Region.class, String.class, Array.newInstance(String.class, 0).getClass());
|
||||||
Array.newInstance(String.class, 0).getClass());
|
|
||||||
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<MonitoringAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"instance1", "instance2");
|
Region.DEFAULT, "instance1", "instance2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -96,6 +100,7 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(GeneratedHttpRequest<MonitoringAsyncClient> httpMethod) {
|
protected void checkFilters(GeneratedHttpRequest<MonitoringAsyncClient> httpMethod) {
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
assertEquals(httpMethod.getFilters().size(), 1);
|
||||||
|
@ -132,6 +137,16 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.EC2ContextFactory;
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
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.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
@ -61,14 +62,16 @@ public class MonitoringClientLiveTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// TODO get instance
|
// TODO get instance
|
||||||
public void testMonitorInstances() {
|
public void testMonitorInstances() {
|
||||||
Map<String, MonitoringState> monitoringState = client.monitorInstances(DEFAULT_INSTANCE);
|
Map<String, MonitoringState> monitoringState = client.monitorInstancesInRegion(
|
||||||
|
Region.DEFAULT, DEFAULT_INSTANCE);
|
||||||
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
// TODO get instance
|
// TODO get instance
|
||||||
public void testUnmonitorInstances() {
|
public void testUnmonitorInstances() {
|
||||||
Map<String, MonitoringState> monitoringState = client.unmonitorInstances(DEFAULT_INSTANCE);
|
Map<String, MonitoringState> monitoringState = client.unmonitorInstancesInRegion(
|
||||||
|
Region.DEFAULT, DEFAULT_INSTANCE);
|
||||||
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,13 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
||||||
|
@ -48,6 +52,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -63,9 +68,10 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException,
|
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class);
|
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion",
|
||||||
|
Region.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"name");
|
Region.DEFAULT, "name");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -82,16 +88,16 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException,
|
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class,
|
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion",
|
||||||
String.class);
|
Region.class, String.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"name", "description");
|
Region.DEFAULT, "name", "description");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 89\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 89\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(httpMethod,
|
assertPayloadEquals(httpMethod,
|
||||||
"Version=2009-11-30&Action=CreateSecurityGroup&GroupName=name&GroupDescription=description");
|
"Version=2009-11-30&Action=CreateSecurityGroup&GroupDescription=description&GroupName=name");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
@ -102,9 +108,10 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException,
|
public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroups", Array
|
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
||||||
.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
Region.DEFAULT);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -120,10 +127,10 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException,
|
public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroups", Array
|
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion",
|
||||||
.newInstance(String.class, 0).getClass());
|
Region.class, Array.newInstance(String.class, 0).getClass());
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"1", "2");
|
Region.DEFAULT, "1", "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -140,10 +147,11 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testAuthorizeSecurityGroupIngressGroup() throws SecurityException,
|
public void testAuthorizeSecurityGroupIngressGroup() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngress",
|
Method method = SecurityGroupAsyncClient.class.getMethod(
|
||||||
String.class, UserIdGroupPair.class);
|
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
|
UserIdGroupPair.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
Region.DEFAULT, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -161,17 +169,18 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testAuthorizeSecurityGroupIngressCidr() throws SecurityException,
|
public void testAuthorizeSecurityGroupIngressCidr() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngress",
|
Method method = SecurityGroupAsyncClient.class.getMethod(
|
||||||
String.class, IpProtocol.class, int.class, int.class, String.class);
|
"authorizeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
|
IpProtocol.class, int.class, int.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
Region.DEFAULT, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 131\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 131\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=AuthorizeSecurityGroupIngress&GroupName=group&FromPort=6000&IpProtocol=tcp&ToPort=7000&CidrIp=0.0.0.0%2F0");
|
"Version=2009-11-30&Action=AuthorizeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
@ -182,10 +191,11 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testRevokeSecurityGroupIngressGroup() throws SecurityException,
|
public void testRevokeSecurityGroupIngressGroup() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngress",
|
Method method = SecurityGroupAsyncClient.class.getMethod(
|
||||||
String.class, UserIdGroupPair.class);
|
"revokeSecurityGroupIngressInRegion", Region.class, String.class,
|
||||||
|
UserIdGroupPair.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
Region.DEFAULT, "group", new UserIdGroupPair("sourceUser", "sourceGroup"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
|
@ -203,17 +213,18 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
|
|
||||||
public void testRevokeSecurityGroupIngressCidr() throws SecurityException,
|
public void testRevokeSecurityGroupIngressCidr() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngress",
|
Method method = SecurityGroupAsyncClient.class.getMethod(
|
||||||
String.class, IpProtocol.class, int.class, int.class, String.class);
|
"revokeSecurityGroupIngressInRegion", Region.class, String.class, IpProtocol.class,
|
||||||
|
int.class, int.class, String.class);
|
||||||
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<SecurityGroupAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
Region.DEFAULT, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod,
|
||||||
"Content-Length: 128\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
"Content-Length: 128\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Version=2009-11-30&Action=RevokeSecurityGroupIngress&GroupName=group&FromPort=6000&IpProtocol=tcp&ToPort=7000&CidrIp=0.0.0.0%2F0");
|
"Version=2009-11-30&Action=RevokeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000");
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
@ -258,6 +269,16 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
String provide() {
|
String provide() {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
Map<Region, URI> provideMap() {
|
||||||
|
return ImmutableMap.<Region, URI> of(Region.DEFAULT, URI.create("https://booya"),
|
||||||
|
Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||||
|
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"),
|
||||||
|
Region.US_WEST_1, URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,278 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
|
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||||
|
import org.jclouds.aws.ec2.domain.IpPermission;
|
||||||
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
|
import org.jclouds.aws.ec2.domain.Region;
|
||||||
|
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||||
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code SecurityGroupClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "ec2.SecurityGroupClientLiveTest")
|
||||||
|
public class SecurityGroupClientLiveTest {
|
||||||
|
|
||||||
|
private SecurityGroupClient client;
|
||||||
|
private RestContext<EC2AsyncClient, EC2Client> context;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||||
|
|
||||||
|
context = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule());
|
||||||
|
client = context.getApi().getSecurityGroupServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDescribe() {
|
||||||
|
for (Region region : ImmutableSet.of(Region.DEFAULT, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
|
Region.US_WEST_1)) {
|
||||||
|
SortedSet<SecurityGroup> allResults = Sets.newTreeSet(client
|
||||||
|
.describeSecurityGroupsInRegion(region));
|
||||||
|
assertNotNull(allResults);
|
||||||
|
if (allResults.size() >= 1) {
|
||||||
|
SecurityGroup group = allResults.last();
|
||||||
|
SortedSet<SecurityGroup> result = Sets.newTreeSet(client
|
||||||
|
.describeSecurityGroupsInRegion(region, group.getName()));
|
||||||
|
assertNotNull(result);
|
||||||
|
SecurityGroup compare = result.last();
|
||||||
|
assertEquals(compare, group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCreateSecurityGroup() {
|
||||||
|
String groupName = PREFIX + "1";
|
||||||
|
String groupDescription = PREFIX + "1 description";
|
||||||
|
try {
|
||||||
|
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
||||||
|
|
||||||
|
client.createSecurityGroupInRegion(Region.DEFAULT, groupName, groupDescription);
|
||||||
|
|
||||||
|
verifySecurityGroup(groupName, groupDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testAuthorizeSecurityGroupIngressCidr() throws InterruptedException, ExecutionException,
|
||||||
|
TimeoutException {
|
||||||
|
String groupName = PREFIX + "ingress";
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.deleteSecurityGroupInRegion(Region.DEFAULT, groupName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
client.createSecurityGroupInRegion(Region.DEFAULT, groupName, groupName);
|
||||||
|
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, groupName, IpProtocol.TCP, 80,
|
||||||
|
80, "0.0.0.0/0");
|
||||||
|
assertEventually(new GroupHasPermission(client, groupName, new IpPermission(80, 80, Sets
|
||||||
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
|
client.revokeSecurityGroupIngressInRegion(Region.DEFAULT, groupName, IpProtocol.TCP, 80, 80,
|
||||||
|
"0.0.0.0/0");
|
||||||
|
assertEventually(new GroupHasNoPermissions(client, groupName));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifySecurityGroup(String groupName, String description) {
|
||||||
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
||||||
|
groupName);
|
||||||
|
assertNotNull(oneResult);
|
||||||
|
assertEquals(oneResult.size(), 1);
|
||||||
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
assertEquals(listPair.getName(), groupName);
|
||||||
|
assertEquals(listPair.getDescription(), description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = false)
|
||||||
|
// TODO
|
||||||
|
void testAuthorizeSecurityGroupIngressSourceGroup() throws InterruptedException {
|
||||||
|
String group1Name = PREFIX + "ingress1";
|
||||||
|
String group2Name = PREFIX + "ingress2";
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.deleteSecurityGroupInRegion(Region.DEFAULT, group1Name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
client.deleteSecurityGroupInRegion(Region.DEFAULT, group2Name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
client.createSecurityGroupInRegion(Region.DEFAULT, group1Name, group1Name);
|
||||||
|
client.createSecurityGroupInRegion(Region.DEFAULT, group2Name, group2Name);
|
||||||
|
ensureGroupsExist(group1Name, group2Name);
|
||||||
|
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, group1Name, IpProtocol.TCP, 80,
|
||||||
|
80, "0.0.0.0/0");
|
||||||
|
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
||||||
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
||||||
|
group1Name);
|
||||||
|
assertNotNull(oneResult);
|
||||||
|
assertEquals(oneResult.size(), 1);
|
||||||
|
SecurityGroup group = oneResult.iterator().next();
|
||||||
|
assertEquals(group.getName(), group1Name);
|
||||||
|
|
||||||
|
client.authorizeSecurityGroupIngressInRegion(Region.DEFAULT, group2Name, new UserIdGroupPair(
|
||||||
|
group.getOwnerId(), group1Name));
|
||||||
|
assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets
|
||||||
|
.<UserIdGroupPair> newTreeSet(), IpProtocol.TCP, ImmutableSortedSet.of("0.0.0.0/0"))));
|
||||||
|
|
||||||
|
client.revokeSecurityGroupIngressInRegion(Region.DEFAULT, group2Name, new UserIdGroupPair(
|
||||||
|
group.getOwnerId(), group1Name));
|
||||||
|
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class GroupHasPermission implements Runnable {
|
||||||
|
private final SecurityGroupClient client;
|
||||||
|
private final String group;
|
||||||
|
private final IpPermission permission;
|
||||||
|
|
||||||
|
private GroupHasPermission(SecurityGroupClient client, String group, IpPermission permission) {
|
||||||
|
this.client = client;
|
||||||
|
this.group = group;
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
SortedSet<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(
|
||||||
|
Region.DEFAULT, group);
|
||||||
|
assertNotNull(oneResult);
|
||||||
|
assertEquals(oneResult.size(), 1);
|
||||||
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
assert listPair.getIpPermissions().contains(permission);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class GroupHasNoPermissions implements Runnable {
|
||||||
|
private final SecurityGroupClient client;
|
||||||
|
private final String group;
|
||||||
|
|
||||||
|
private GroupHasNoPermissions(SecurityGroupClient client, String group) {
|
||||||
|
this.client = client;
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
||||||
|
group);
|
||||||
|
assertNotNull(oneResult);
|
||||||
|
assertEquals(oneResult.size(), 1);
|
||||||
|
SecurityGroup listPair = oneResult.iterator().next();
|
||||||
|
assertEquals(listPair.getIpPermissions().size(), 0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureGroupsExist(String group1Name, String group2Name) {
|
||||||
|
SortedSet<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(Region.DEFAULT,
|
||||||
|
group1Name, group2Name);
|
||||||
|
assertNotNull(twoResults);
|
||||||
|
assertEquals(twoResults.size(), 2);
|
||||||
|
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
||||||
|
SecurityGroup listPair1 = iterator.next();
|
||||||
|
assertEquals(listPair1.getName(), group1Name);
|
||||||
|
assertEquals(listPair1.getDescription(), group1Name);
|
||||||
|
|
||||||
|
SecurityGroup listPair2 = iterator.next();
|
||||||
|
assertEquals(listPair2.getName(), group2Name);
|
||||||
|
assertEquals(listPair2.getDescription(), group2Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int INCONSISTENCY_WINDOW = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Due to eventual consistency, container commands may not return correctly immediately. Hence,
|
||||||
|
* we will try up to the inconsistency window to see if the assertion completes.
|
||||||
|
*/
|
||||||
|
protected static void assertEventually(Runnable assertion) throws InterruptedException {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
AssertionError error = null;
|
||||||
|
for (int i = 0; i < 30; i++) {
|
||||||
|
try {
|
||||||
|
assertion.run();
|
||||||
|
if (i > 0)
|
||||||
|
System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System
|
||||||
|
.currentTimeMillis()
|
||||||
|
- start, assertion.getClass().getSimpleName());
|
||||||
|
return;
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
Thread.sleep(INCONSISTENCY_WINDOW / 30);
|
||||||
|
}
|
||||||
|
if (error != null)
|
||||||
|
throw error;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
public void shutdown() {
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,13 +28,13 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DescribeAddressesResponseHandler}
|
* Tests behavior of {@code DescribeAddressesResponseHandler}
|
||||||
|
@ -47,11 +47,11 @@ public class DescribeAddressesResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_addresses.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_addresses.xml");
|
||||||
|
|
||||||
SortedSet<PublicIpInstanceIdPair> result = factory.create(
|
Set<PublicIpInstanceIdPair> result = factory.create(
|
||||||
injector.getInstance(DescribeAddressesResponseHandler.class)).parse(is);
|
injector.getInstance(DescribeAddressesResponseHandler.class)).parse(is);
|
||||||
|
|
||||||
assertEquals(result, ImmutableSortedSet.of(new PublicIpInstanceIdPair(InetAddress
|
assertEquals(result, ImmutableList.of(new PublicIpInstanceIdPair(InetAddress
|
||||||
.getByName("67.202.55.233"), null), new PublicIpInstanceIdPair(InetAddress
|
.getByName("67.202.55.255"), "i-f15ebb98"), new PublicIpInstanceIdPair(InetAddress
|
||||||
.getByName("67.202.55.255"), "i-f15ebb98")));
|
.getByName("67.202.55.233"), null)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ package org.jclouds.aws.ec2.xml;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.SortedSet;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DescribeKeyPairsHandler}
|
* Tests behavior of {@code DescribeKeyPairsHandler}
|
||||||
|
@ -45,10 +45,10 @@ public class DescribeKeyPairsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_keypairs.xml");
|
InputStream is = getClass().getResourceAsStream("/ec2/describe_keypairs.xml");
|
||||||
|
|
||||||
SortedSet<KeyPair> expected = ImmutableSortedSet.of(new KeyPair("gsg-keypair",
|
Set<KeyPair> expected = ImmutableSet.of(new KeyPair("gsg-keypair",
|
||||||
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", null));
|
"1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", null));
|
||||||
|
|
||||||
SortedSet<KeyPair> result = factory.create(
|
Set<KeyPair> result = factory.create(
|
||||||
injector.getInstance(DescribeKeyPairsResponseHandler.class)).parse(is);
|
injector.getInstance(DescribeKeyPairsResponseHandler.class)).parse(is);
|
||||||
|
|
||||||
assertEquals(result, expected);
|
assertEquals(result, expected);
|
||||||
|
|
|
@ -756,7 +756,8 @@ public class RestAnnotationProcessor<T> {
|
||||||
boolean shouldBreak = false;
|
boolean shouldBreak = false;
|
||||||
BinderParam payloadAnnotation = (BinderParam) entry.getValue().iterator().next();
|
BinderParam payloadAnnotation = (BinderParam) entry.getValue().iterator().next();
|
||||||
Binder binder = injector.getInstance(payloadAnnotation.value());
|
Binder binder = injector.getInstance(payloadAnnotation.value());
|
||||||
if (request.getArgs().length != 0) {
|
if (request.getArgs().length >= entry.getKey() + 1
|
||||||
|
&& request.getArgs()[entry.getKey()] != null) {
|
||||||
Object input;
|
Object input;
|
||||||
Class<?> parameterType = request.getJavaMethod().getParameterTypes()[entry.getKey()];
|
Class<?> parameterType = request.getJavaMethod().getParameterTypes()[entry.getKey()];
|
||||||
Class<? extends Object> argType = request.getArgs()[entry.getKey()].getClass();
|
Class<? extends Object> argType = request.getArgs()[entry.getKey()].getClass();
|
||||||
|
|
|
@ -44,6 +44,7 @@ import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Qualifier;
|
import javax.inject.Qualifier;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
@ -339,7 +340,7 @@ public class RestAnnotationProcessorTest {
|
||||||
@Endpoint(Localhost.class)
|
@Endpoint(Localhost.class)
|
||||||
public class TestPost {
|
public class TestPost {
|
||||||
@POST
|
@POST
|
||||||
public void post(@BinderParam(BindToStringPayload.class) String content) {
|
public void post(@Nullable @BinderParam(BindToStringPayload.class) String content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
@ -361,8 +362,7 @@ public class RestAnnotationProcessorTest {
|
||||||
|
|
||||||
public void testCreatePostRequest() throws SecurityException, NoSuchMethodException {
|
public void testCreatePostRequest() throws SecurityException, NoSuchMethodException {
|
||||||
Method method = TestPost.class.getMethod("post", String.class);
|
Method method = TestPost.class.getMethod("post", String.class);
|
||||||
GeneratedHttpRequest<?> httpMethod = factory(TestPost.class).createRequest(method,
|
GeneratedHttpRequest<?> httpMethod = factory(TestPost.class).createRequest(method, "data");
|
||||||
new Object[] { "data" });
|
|
||||||
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
|
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
|
||||||
assertEquals(httpMethod.getEndpoint().getPath(), "");
|
assertEquals(httpMethod.getEndpoint().getPath(), "");
|
||||||
assertEquals(httpMethod.getMethod(), HttpMethod.POST);
|
assertEquals(httpMethod.getMethod(), HttpMethod.POST);
|
||||||
|
@ -374,6 +374,19 @@ public class RestAnnotationProcessorTest {
|
||||||
assertEquals(httpMethod.getPayload().toString(), "data");
|
assertEquals(httpMethod.getPayload().toString(), "data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreatePostRequestNullOk() throws SecurityException, NoSuchMethodException {
|
||||||
|
Method method = TestPost.class.getMethod("post", String.class);
|
||||||
|
GeneratedHttpRequest<?> httpMethod = factory(TestPost.class).createRequest(method,
|
||||||
|
new Object[] { null });
|
||||||
|
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
|
||||||
|
assertEquals(httpMethod.getEndpoint().getPath(), "");
|
||||||
|
assertEquals(httpMethod.getMethod(), HttpMethod.POST);
|
||||||
|
assertEquals(httpMethod.getHeaders().size(), 0);
|
||||||
|
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE).size(), 0);
|
||||||
|
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_LENGTH).size(), 0);
|
||||||
|
assertEquals(httpMethod.getPayload(), null);
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException {
|
public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException {
|
||||||
Method method = TestPost.class.getMethod("postAsJson", String.class);
|
Method method = TestPost.class.getMethod("postAsJson", String.class);
|
||||||
GeneratedHttpRequest<?> httpMethod = factory(TestPost.class).createRequest(method,
|
GeneratedHttpRequest<?> httpMethod = factory(TestPost.class).createRequest(method,
|
||||||
|
|
Loading…
Reference in New Issue