From 7284d7db2f80c61930bfd2910274125b37d5868d Mon Sep 17 00:00:00 2001 From: Richard Downer Date: Thu, 12 Jan 2012 15:36:14 +0200 Subject: [PATCH] Add GlobalHost[Async]Client.updateClusterPassword() --- .../cloudstack/features/GlobalHostAsyncClient.java | 13 +++++++++++++ .../cloudstack/features/GlobalHostClient.java | 9 +++++++++ .../features/GlobalHostClientExpectTest.java | 13 +++++++++++++ 3 files changed, 35 insertions(+) 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 2f7da209bf..be0c3a9a79 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 @@ -204,4 +204,17 @@ public interface GlobalHostAsyncClient { @SelectJson("cluster") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture updateCluster(@QueryParam("id") long clusterId, UpdateClusterOptions... options); + + /** + * Update password of a cluster on management server. + * + * @param clusterId the cluster ID + * @param username the username for the cluster + * @param password the password for the cluster + */ + @GET + @QueryParams(keys = "command", values = "updateHostPassword") + @SelectJson("cluster") + @Consumes(MediaType.APPLICATION_JSON) + ListenableFuture updateClusterPassword(@QueryParam("clusterid") long clusterId, @QueryParam("username") String username, @QueryParam("password") String password); } 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 24cb3e9000..f1b042ef53 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 @@ -154,4 +154,13 @@ public interface GlobalHostClient { * @return the modified cluster */ Cluster updateCluster(long clusterId, UpdateClusterOptions... options); + + /** + * Update password of a cluster on management server. + * + * @param hostId the cluster ID + * @param username the username for the cluster + * @param password the password for the cluster + */ + void updateClusterPassword(long clusterId, String username, String password); } 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 b4df927fb0..57b0a7414f 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 @@ -303,6 +303,19 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe assertEquals(actual, expected); } + @Test + public void testUpdateClusterPasswordWhenResponseIs2xx() { + HttpRequest request = HttpRequest.builder() + .method("GET") + .endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateHostPassword&clusterid=1&password=sekrit&username=fred&apiKey=identity&signature=xwc83%2BoYK0cuAiFQAlg%2F7%2F1IVHE%3D")) + .headers(ImmutableMultimap.builder().put("Accept", "application/json").build()) + .build(); + HttpResponse response = HttpResponse.builder() + .statusCode(200).build(); + + requestSendsResponse(request, response).updateClusterPassword(1, "fred", "sekrit"); + } + private Date makeDate(int year, int month, int date, int hour, int minute, int second, String timeZoneName) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneName)); cal.set(Calendar.YEAR, year);