Add GlobalHost[Async]Client.updateHostPassword()

This commit is contained in:
Richard Downer 2012-01-12 14:06:57 +02:00
parent 9bb9312d4a
commit 2b1c5f78f3
3 changed files with 34 additions and 0 deletions

View File

@ -90,6 +90,18 @@ public interface GlobalHostAsyncClient {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Host> updateHost(@QueryParam("id") long hostId, UpdateHostOptions... options); ListenableFuture<Host> updateHost(@QueryParam("id") long hostId, UpdateHostOptions... options);
/**
* Update password of a host on management server.
*
* @param hostId the host ID
* @param username the username for the host
* @param password the password for the host
*/
@GET
@QueryParams(keys = "command", values = "updateHostPassword")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Void> updateHostPassword(@QueryParam("hostid") long hostId, @QueryParam("username") String username, @QueryParam("password") String password);
/** /**
* @see GlobalHostClient#listClusters * @see GlobalHostClient#listClusters
*/ */

View File

@ -72,6 +72,15 @@ public interface GlobalHostClient {
*/ */
Host updateHost(long hostId, UpdateHostOptions... options); Host updateHost(long hostId, UpdateHostOptions... options);
/**
* Update password of a host on management server.
*
* @param hostId the host ID
* @param username the username for the host
* @param password the password for the host
*/
void updateHostPassword(long hostId, String username, String password);
/** /**
* Lists clusters * Lists clusters
* *

View File

@ -138,6 +138,19 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
assertEquals(actual, expected); assertEquals(actual, expected);
} }
@Test
public void testUpdateHostPasswordWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()
.method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateHostPassword&hostid=1&password=sekrit&username=fred&apiKey=identity&signature=g9nMKDWoiU72y0HhaRFekZCgfJc%3D"))
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
.build();
HttpResponse response = HttpResponse.builder()
.statusCode(200).build();
requestSendsResponse(request, response).updateHostPassword(1, "fred", "sekrit");
}
@Test @Test
public void testListClustersWhenResponseIs2xx() { public void testListClustersWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder() HttpRequest request = HttpRequest.builder()