diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java index 70bfefcc8a..fe53dca3dc 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java @@ -138,6 +138,18 @@ public interface GlobalHostAsyncClient { @Consumes(MediaType.APPLICATION_JSON) ListenableFuture 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 reconnectHost(@QueryParam("id") long hostId); + /** * @see GlobalHostClient#listClusters */ diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java index 434470c8fc..f422af69dd 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java @@ -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 * diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java index 24dd923d82..acbba0beb9 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java @@ -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.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() diff --git a/apis/cloudstack/src/test/resources/reconnecthostresponse.json b/apis/cloudstack/src/test/resources/reconnecthostresponse.json new file mode 100644 index 0000000000..2b86f49790 --- /dev/null +++ b/apis/cloudstack/src/test/resources/reconnecthostresponse.json @@ -0,0 +1 @@ +{ "reconnecthostresponse" : {"warning":"this test data is fabricated","jobid":2036,"id":2017} } \ No newline at end of file