mirror of https://github.com/apache/jclouds.git
added last drive commands to elastichosts
This commit is contained in:
parent
a2a84535d0
commit
0caab0226b
|
@ -80,6 +80,22 @@ public interface ElasticHostsAsyncClient {
|
||||||
@ResponseParser(SplitNewlines.class)
|
@ResponseParser(SplitNewlines.class)
|
||||||
ListenableFuture<Set<String>> listStandardDrives();
|
ListenableFuture<Set<String>> listStandardDrives();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ElasticHostsClient#listStandardCds()
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/drives/standard/cd/list")
|
||||||
|
@ResponseParser(SplitNewlines.class)
|
||||||
|
ListenableFuture<Set<String>> listStandardCds();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ElasticHostsClient#listStandardImages()
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/drives/standard/img/list")
|
||||||
|
@ResponseParser(SplitNewlines.class)
|
||||||
|
ListenableFuture<Set<String>> listStandardImages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticHostsClient#listDriveInfo()
|
* @see ElasticHostsClient#listDriveInfo()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,6 +54,20 @@ public interface ElasticHostsClient {
|
||||||
*/
|
*/
|
||||||
Set<String> listStandardDrives();
|
Set<String> listStandardDrives();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list of cd uuids that are in the library
|
||||||
|
*
|
||||||
|
* @return or empty set if no cds are found
|
||||||
|
*/
|
||||||
|
Set<String> listStandardCds();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list of image uuids that are in the library
|
||||||
|
*
|
||||||
|
* @return or empty set if no images are found
|
||||||
|
*/
|
||||||
|
Set<String> listStandardImages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all drives info
|
* Get all drives info
|
||||||
*
|
*
|
||||||
|
|
|
@ -102,6 +102,36 @@ public class ElasticHostsAsyncClientTest extends RestClientTest<ElasticHostsAsyn
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ElasticHostsAsyncClient.class.getMethod("listStandardCds");
|
||||||
|
GeneratedHttpRequest<ElasticHostsAsyncClient> httpRequest = processor.createRequest(method);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest, "GET https://api.elastichosts.com/drives/standard/cd/list HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ElasticHostsAsyncClient.class.getMethod("listStandardImages");
|
||||||
|
GeneratedHttpRequest<ElasticHostsAsyncClient> httpRequest = processor.createRequest(method);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest, "GET https://api.elastichosts.com/drives/standard/img/list HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
}
|
||||||
|
|
||||||
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = ElasticHostsAsyncClient.class.getMethod("listDriveInfo");
|
Method method = ElasticHostsAsyncClient.class.getMethod("listDriveInfo");
|
||||||
GeneratedHttpRequest<ElasticHostsAsyncClient> httpRequest = processor.createRequest(method);
|
GeneratedHttpRequest<ElasticHostsAsyncClient> httpRequest = processor.createRequest(method);
|
||||||
|
@ -279,6 +309,7 @@ public class ElasticHostsAsyncClientTest extends RestClientTest<ElasticHostsAsyn
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
assertEquals(request.getFilters().size(), 1);
|
assertEquals(request.getFilters().size(), 1);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.jclouds.rest.RestContextFactory.createContext;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -33,8 +34,10 @@ import org.jclouds.elastichosts.domain.ClaimType;
|
||||||
import org.jclouds.elastichosts.domain.CreateDriveRequest;
|
import org.jclouds.elastichosts.domain.CreateDriveRequest;
|
||||||
import org.jclouds.elastichosts.domain.DriveData;
|
import org.jclouds.elastichosts.domain.DriveData;
|
||||||
import org.jclouds.elastichosts.domain.DriveInfo;
|
import org.jclouds.elastichosts.domain.DriveInfo;
|
||||||
|
import org.jclouds.io.Payloads;
|
||||||
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.jclouds.util.Utils;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -120,6 +123,18 @@ public class ElasticHostsClientLiveTest {
|
||||||
assertNotNull(drives);
|
assertNotNull(drives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListStandardCds() throws Exception {
|
||||||
|
Set<String> drives = client.listStandardCds();
|
||||||
|
assertNotNull(drives);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListStandardImages() throws Exception {
|
||||||
|
Set<String> drives = client.listStandardImages();
|
||||||
|
assertNotNull(drives);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDrive() throws Exception {
|
public void testGetDrive() throws Exception {
|
||||||
for (String driveUUID : client.listDrives()) {
|
for (String driveUUID : client.listDrives()) {
|
||||||
|
@ -132,11 +147,12 @@ public class ElasticHostsClientLiveTest {
|
||||||
|
|
||||||
private String prefix = System.getProperty("user.name") + ".test";
|
private String prefix = System.getProperty("user.name") + ".test";
|
||||||
private DriveInfo info;
|
private DriveInfo info;
|
||||||
|
private DriveInfo info2;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
try {
|
try {
|
||||||
findAndDestroyDrive();
|
findAndDestroyDrive(prefix);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -149,12 +165,25 @@ public class ElasticHostsClientLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWeCanReadAndWriteToDrive() {
|
@Test(dependsOnMethods = "testCreate")
|
||||||
// TODO put a bunch of bytes and then read them back.
|
public void testWeCanReadAndWriteToDrive() throws IOException {
|
||||||
|
client.writeDrive(info.getUuid(), Payloads.newStringPayload("foo"));
|
||||||
|
assertEquals(Utils.toStringAndClose(client.readDrive(info.getUuid()).getInput()), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWeCopyADriveContentsViaGzip() {
|
@Test(dependsOnMethods = "testWeCanReadAndWriteToDrive")
|
||||||
// TODO gzip source to destination, then gunzip back to source and assert equiv
|
public void testWeCopyADriveContentsViaGzip() throws IOException {
|
||||||
|
try {
|
||||||
|
findAndDestroyDrive(prefix + "2");
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
info2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1024 * 1024l).build());
|
||||||
|
client.imageDrive(info.getUuid(), info2.getUuid());
|
||||||
|
|
||||||
|
// TODO block until complete
|
||||||
|
System.err.println("state " + client.getDriveInfo(info2.getUuid()));
|
||||||
|
assertEquals(Utils.toStringAndClose(client.readDrive(info2.getUuid()).getInput()), "foo");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +195,7 @@ public class ElasticHostsClientLiveTest {
|
||||||
new DriveData.Builder().claimType(ClaimType.SHARED).name("rediculous")
|
new DriveData.Builder().claimType(ClaimType.SHARED).name("rediculous")
|
||||||
.readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))
|
.readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))
|
||||||
.tags(ImmutableSet.of("tag1", "tag2")).userMetadata(ImmutableMap.of("foo", "bar")).build());
|
.tags(ImmutableSet.of("tag1", "tag2")).userMetadata(ImmutableMap.of("foo", "bar")).build());
|
||||||
|
|
||||||
assertNotNull(info2.getUuid(), info.getUuid());
|
assertNotNull(info2.getUuid(), info.getUuid());
|
||||||
assertEquals(info.getName(), "rediculous");
|
assertEquals(info.getName(), "rediculous");
|
||||||
assertEquals(info.getClaimType(), ClaimType.SHARED);
|
assertEquals(info.getClaimType(), ClaimType.SHARED);
|
||||||
|
@ -177,12 +207,12 @@ public class ElasticHostsClientLiveTest {
|
||||||
@Test(dependsOnMethods = "testSetDriveData")
|
@Test(dependsOnMethods = "testSetDriveData")
|
||||||
public void testDestroyDrive() throws Exception {
|
public void testDestroyDrive() throws Exception {
|
||||||
|
|
||||||
findAndDestroyDrive();
|
findAndDestroyDrive(prefix);
|
||||||
assertEquals(client.getDriveInfo(info.getUuid()), null);
|
assertEquals(client.getDriveInfo(info.getUuid()), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void findAndDestroyDrive() {
|
protected void findAndDestroyDrive(final String prefix) {
|
||||||
DriveInfo drive = Iterables.find(client.listDriveInfo(), new Predicate<DriveInfo>() {
|
DriveInfo drive = Iterables.find(client.listDriveInfo(), new Predicate<DriveInfo>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue