Add GlobalHost[Async]Client.reconnectHost()

This commit is contained in:
Richard Downer 2012-01-12 14:39:52 +02:00
parent 528fa0ae5a
commit 20f58c4a12
4 changed files with 36 additions and 0 deletions

View File

@ -138,6 +138,18 @@ public interface GlobalHostAsyncClient {
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> cancelHostMaintenance(@QueryParam("id") long hostId);
/**
* Reconnects a host.
*
* @param hostId
* @return a job reference number for tracking this asynchronous job.
*/
@GET
@QueryParams(keys = "command", values = "reconnectHost")
@SelectJson("jobid")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> reconnectHost(@QueryParam("id") long hostId);
/**
* @see GlobalHostClient#listClusters
*/

View File

@ -106,6 +106,14 @@ public interface GlobalHostClient {
*/
Long cancelHostMaintenance(long hostId);
/**
* Reconnects a host.
*
* @param hostId
* @return a job reference number for tracking this asynchronous job.
*/
Long reconnectHost(long hostId);
/**
* Lists clusters
*

View File

@ -195,6 +195,21 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
assertEquals(actual, Long.valueOf(2036L));
}
@Test
public void testReconnectHostWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()
.method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=reconnectHost&id=1&apiKey=identity&signature=wJEF02vwdyOnJOTa%2BWMMK906aRU%3D"))
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
.build();
HttpResponse response = HttpResponse.builder()
.payload(payloadFromResource("/reconnecthostresponse.json"))
.statusCode(200).build();
Long actual = requestSendsResponse(request, response).reconnectHost(1);
assertEquals(actual, Long.valueOf(2036L));
}
@Test
public void testListClustersWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()

View File

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