mirror of https://github.com/apache/jclouds.git
Added an overloaded version of 'createVolumeFromSnapshotInAvailabilityZone' to support specific size for a volume
This commit is contained in:
parent
bb80d90755
commit
3e8381e3f3
|
@ -81,6 +81,17 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone,
|
@EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone,
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ElasticBlockStoreClient#createVolumeFromSnapshotInAvailabilityZone
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/")
|
||||||
|
@FormParams(keys = ACTION, values = "CreateVolume")
|
||||||
|
@XMLResponseParser(CreateVolumeResponseHandler.class)
|
||||||
|
ListenableFuture<Volume> createVolumeFromSnapshotInAvailabilityZone(
|
||||||
|
@EndpointParam(parser = AvailabilityZoneToEndpoint.class) @FormParam("AvailabilityZone") AvailabilityZone availabilityZone,
|
||||||
|
@FormParam("Size") int size, @FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticBlockStoreClient#createVolumeInAvailabilityZone
|
* @see ElasticBlockStoreClient#createVolumeInAvailabilityZone
|
||||||
*/
|
*/
|
||||||
|
@ -183,7 +194,7 @@ public interface ElasticBlockStoreAsyncClient {
|
||||||
@FormParam("SnapshotId") String snapshotId);
|
@FormParam("SnapshotId") String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticBlockStoreClient#removeCreateVolumePermissionsToSnapshotInRegion
|
* @see ElasticBlockStoreClient#removeCreateVolumePermissionsFromSnapshotInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
|
|
|
@ -66,6 +66,36 @@ public interface ElasticBlockStoreClient {
|
||||||
Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone,
|
Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone,
|
||||||
String snapshotId);
|
String snapshotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same
|
||||||
|
* Availability Zone. This is overloaded {@link #createVolumeFromSnapshotInAvailabilityZone},
|
||||||
|
* which creates a volume with a specific size.
|
||||||
|
* For more information about Amazon EBS, go to the Amazon Elastic Compute
|
||||||
|
* Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide.
|
||||||
|
*
|
||||||
|
* @param availabilityZone
|
||||||
|
* An Amazon EBS volume must be located within the same Availability Zone as the
|
||||||
|
* instance to which it attaches.
|
||||||
|
* @param size
|
||||||
|
* Size of volume to be created
|
||||||
|
* @param snapshotId
|
||||||
|
* The snapshot from which to create the new volume.
|
||||||
|
*
|
||||||
|
* @see #createVolumeFromSnapshotInAvailabilityZone
|
||||||
|
* @see #describeVolumesInRegion
|
||||||
|
* @see #deleteVolumeInRegion
|
||||||
|
* @see #attachVolumeInRegion
|
||||||
|
* @see #detachVolumeInRegion
|
||||||
|
* @see AvailabilityZoneAndRegionClient#describeAvailabilityZonesInRegion
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @see <a href=
|
||||||
|
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
Volume createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone availabilityZone,
|
||||||
|
int size, String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same
|
* Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same
|
||||||
* Availability Zone. For more information about Amazon EBS, go to the Amazon Elastic Compute
|
* Availability Zone. For more information about Amazon EBS, go to the Amazon Elastic Compute
|
||||||
|
|
|
@ -110,6 +110,27 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
||||||
|
"createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class,
|
||||||
|
int.class, String.class);
|
||||||
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
|
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Content-Length: 96\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(httpMethod,
|
||||||
|
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId&Size=15");
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, CreateVolumeResponseHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion",
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion",
|
||||||
Region.class, String.class);
|
Region.class, String.class);
|
||||||
|
|
|
@ -138,6 +138,27 @@ public class ElasticBlockStoreClientLiveTest {
|
||||||
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
|
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
||||||
|
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(
|
||||||
|
AvailabilityZone.US_EAST_1B, 2, snapshot.getId());
|
||||||
|
assertNotNull(volume);
|
||||||
|
|
||||||
|
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client),
|
||||||
|
600, 10, TimeUnit.SECONDS);
|
||||||
|
assert availabile.apply(volume);
|
||||||
|
|
||||||
|
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(),
|
||||||
|
volume.getId()));
|
||||||
|
assertEquals(volume.getId(), result.getId());
|
||||||
|
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||||
|
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1B);
|
||||||
|
assertEquals(volume.getSize(), 2);
|
||||||
|
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||||
|
|
||||||
|
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAttachVolumeInRegion() {
|
void testAttachVolumeInRegion() {
|
||||||
// TODO: need an instance
|
// TODO: need an instance
|
||||||
|
|
Loading…
Reference in New Issue