From 3e710c1c7fd600ef9a0a781d4cd21dce2e031c62 Mon Sep 17 00:00:00 2001 From: Fang Sun Date: Tue, 3 Jul 2012 17:53:33 -0600 Subject: [PATCH] add startServer and stopServer --- .../openstack/nova/v2_0/domain/Server.java | 2 +- .../nova/v2_0/features/ServerAsyncClient.java | 20 +++++++++++++++++++ .../nova/v2_0/features/ServerClient.java | 16 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java index a80cb11286..9220db3831 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java @@ -60,7 +60,7 @@ public class Server extends Resource { */ public static enum Status { - ACTIVE, BUILD, REBUILD, SUSPENDED, PAUSED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, ERROR, UNRECOGNIZED; + ACTIVE, BUILD, REBUILD, SUSPENDED, PAUSED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, ERROR, STOPPED, UNRECOGNIZED; public String value() { return name(); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncClient.java index 226fc2ed0d..844341e535 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncClient.java @@ -107,6 +107,26 @@ public interface ServerAsyncClient { @Path("/servers/{id}") ListenableFuture deleteServer(@PathParam("id") String id); + /** + * @see ServerClient#startServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"os-start\":null}") + ListenableFuture startServer(@PathParam("id") String id); + + /** + * @see ServerClient#stopServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"os-stop\":null}") + ListenableFuture stopServer(@PathParam("id") String id); + /** * @see ServerClient#rebootServer */ diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerClient.java index 2760b0ab35..b1938923bf 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerClient.java @@ -91,7 +91,23 @@ public interface ServerClient { * @return True if successful, False otherwise */ Boolean deleteServer(String id); + + /** + * Start a server + * + * @param id + * id of the server + */ + void startServer(String id); + /** + * Stop a server + * + * @param id + * id of the server + */ + void stopServer(String id); + /** * Reboot a server. *