Add ability to use uuid to delete servers using the nova client

This commit is contained in:
Matt Stephenson 2011-11-08 12:24:56 -06:00
parent 393c99561d
commit ae287a97e8
3 changed files with 26 additions and 1 deletions

View File

@ -93,6 +93,15 @@ public interface NovaAsyncClient {
@Path("/servers/{id}") @Path("/servers/{id}")
ListenableFuture<Boolean> deleteServer(@PathParam("id") int id); ListenableFuture<Boolean> deleteServer(@PathParam("id") int id);
/**
* @see NovaClient#deleteServer
*/
@DELETE
@Consumes
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
@Path("/servers/{uuid}")
ListenableFuture<Boolean> deleteServer(@PathParam("uuid") String uuid);
/** /**
* @see NovaClient#rebootServer * @see NovaClient#rebootServer
*/ */

View File

@ -82,7 +82,8 @@ public interface NovaClient {
* @return false if the server is not found * @return false if the server is not found
* @see Server * @see Server
*/ */
boolean deleteServer(@PathParam("id") int id); boolean deleteServer(int id);
boolean deleteServer(String id);
/** /**
* The reboot function allows for either a soft or hard reboot of a server. * The reboot function allows for either a soft or hard reboot of a server.

View File

@ -426,6 +426,21 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
checkFilters(request); checkFilters(request);
} }
public void testDeleteServerByUUID() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("deleteServer", String.class);
HttpRequest request = processor.createRequest(method, "db8a1ac6-0a35-11e1-a42f-2837371c69ae");
assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/db8a1ac6-0a35-11e1-a42f-2837371c69ae HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: */*\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
checkFilters(request);
}
public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException { public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("changeAdminPass", int.class, String.class); Method method = NovaAsyncClient.class.getMethod("changeAdminPass", int.class, String.class);
HttpRequest request = processor.createRequest(method, 2, "foo"); HttpRequest request = processor.createRequest(method, 2, "foo");