Issue 695: Added remove virtual machine call, plus test and commented out live test

This commit is contained in:
Jason King 2011-11-24 14:58:52 +00:00
parent 4b03bb707f
commit 1cf89c6b6f
4 changed files with 45 additions and 7 deletions

View File

@ -30,10 +30,7 @@ import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineConfigurationOpt
import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines;
import org.jclouds.tmrk.enterprisecloud.functions.ReturnEmptyVirtualMachinesOnNotFoundOr404;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.*;
import java.net.URI;
/**
@ -154,4 +151,13 @@ public interface VirtualMachineAsyncClient {
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Task> unmountTools(@EndpointParam URI uri);
/**
* @see VirtualMachineClient#remove
*/
@DELETE
@Consumes("application/vnd.tmrk.cloud.task")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Task> remove(@EndpointParam URI uri);
}

View File

@ -141,4 +141,10 @@ public interface VirtualMachineClient {
*/
Task unmountTools(URI uri);
/**
* * The Action Virtual Machines Remove call removes a specified virtual machine from the compute pool.
* If successful, the call returns the task that removed the virtual machine.
* Note: To remove a virtual machine requires a Status value of Deployed and a PoweredOn value of false.
*/
Task remove(URI uri);
}

View File

@ -193,6 +193,20 @@ public class VirtualMachineAsyncClientTest extends BaseTerremarkEnterpriseCloudA
checkFilters(httpRequest);
}
public void testRemove() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
Method method = VirtualMachineAsyncClient.class.getMethod("remove", URI.class);
HttpRequest httpRequest = processor.createRequest(method,new URI("/cloudapi/ecloud/virtualmachines/5504"));
assertRequestLineEquals(httpRequest, "DELETE https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/virtualmachines/5504 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/vnd.tmrk.cloud.task\nx-tmrk-version: 2011-07-01\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(httpRequest);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>>() {

View File

@ -26,7 +26,6 @@ import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import javax.annotation.Nullable;
import java.net.URI;
import static org.testng.Assert.*;
@ -127,6 +126,19 @@ public class VirtualMachineClientActionsLiveTest extends BaseTerremarkEnterprise
assertFalse(vm.isPoweredOn());
}
/* TODO: Not ready to delete the 5504 VM until I can create one.
@Test(dependsOnMethods = "testPowerOff")
public void testRemove() throws URISyntaxException {
// Don't want to delete quite yet!
RetryablePredicate retryablePredicate = new RetryablePredicate(taskFinished(), 1000*60);
if (!retryablePredicate.apply(client.remove(vm.getHref()))) {
fail("Did not manage to finish remove task");
}
assertNull(client.getVirtualMachine(vm.getHref()));
}
*/
private boolean mountTools(URI uri) {
// Wait for task to finish AND tools to get into currentOrOutOfDate state
return new RetryablePredicate(taskFinished(), 1000*60).apply(client.mountTools(uri)) &&