Add GlobalHost[Async]Client.prepareHostForMaintenance()

This commit is contained in:
Richard Downer 2012-01-12 14:25:24 +02:00
parent 350e01c230
commit b3bb99da88
4 changed files with 36 additions and 0 deletions

View File

@ -114,6 +114,18 @@ public interface GlobalHostAsyncClient {
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Void> deleteHost(@QueryParam("id") long hostId, DeleteHostOptions... options);
/**
* Prepares a host for maintenance.
*
* @param hostId the host ID
* @return a job reference number for tracking this asynchronous job.
*/
@GET
@QueryParams(keys = "command", values = "prepareHostForMaintenance")
@SelectJson("jobid")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> prepareHostForMaintenance(@QueryParam("id") long hostId);
/**
* @see GlobalHostClient#listClusters
*/

View File

@ -90,6 +90,14 @@ public interface GlobalHostClient {
*/
void deleteHost(long hostId, DeleteHostOptions... options);
/**
* Prepares a host for maintenance.
*
* @param hostId the host ID
* @return a job reference number for tracking this asynchronous job.
*/
Long prepareHostForMaintenance(long hostId);
/**
* Lists clusters
*

View File

@ -165,6 +165,21 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
requestSendsResponse(request, response).deleteHost(1, DeleteHostOptions.Builder.forced(true).forceDestroyLocalStorage(true));
}
@Test
public void testPrepareHostForMaintenanceWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()
.method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=prepareHostForMaintenance&id=1&apiKey=identity&signature=9tDwdox%2FxAKmZr9kVrR6Ttnxf3U%3D"))
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
.build();
HttpResponse response = HttpResponse.builder()
.payload(payloadFromResource("/preparehostformaintenanceresponse.json"))
.statusCode(200).build();
Long actual = requestSendsResponse(request, response).prepareHostForMaintenance(1);
assertEquals(actual, Long.valueOf(2036L));
}
@Test
public void testListClustersWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()

View File

@ -0,0 +1 @@
{ "preparehostformaintenanceresponse" : {"warning":"this test data is fabricated","jobid":2036,"id":2017} }