Add GlobalHost[Async]Client.updateClusterPassword()

This commit is contained in:
Richard Downer 2012-01-12 15:36:14 +02:00
parent fc50e80eb7
commit 7284d7db2f
3 changed files with 35 additions and 0 deletions

View File

@ -204,4 +204,17 @@ public interface GlobalHostAsyncClient {
@SelectJson("cluster")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Cluster> 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<Void> updateClusterPassword(@QueryParam("clusterid") long clusterId, @QueryParam("username") String username, @QueryParam("password") String password);
}

View File

@ -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);
}

View File

@ -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.<String, String>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);