mirror of https://github.com/apache/jclouds.git
Moved create instance options into a binder.
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2330 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
2070456c60
commit
3d7f79f0a0
|
@ -26,6 +26,7 @@ package org.jclouds.rimuhosting.miro;
|
||||||
import org.jclouds.rest.annotations.*;
|
import org.jclouds.rest.annotations.*;
|
||||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
||||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
|
import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
|
||||||
|
import org.jclouds.rimuhosting.miro.binder.RimuHostingCreateInstanceBinder;
|
||||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||||
import org.jclouds.rimuhosting.miro.domain.*;
|
import org.jclouds.rimuhosting.miro.domain.*;
|
||||||
import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication;
|
import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication;
|
||||||
|
@ -76,30 +77,28 @@ public interface RimuHostingAsyncClient {
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
||||||
Future<NewInstanceResponse> createInstance(@BinderParam(RimuHostingJsonBinder.class) NewInstance newInstance);
|
@MapBinder(RimuHostingCreateInstanceBinder.class)
|
||||||
|
Future<NewInstanceResponse> createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId);
|
||||||
|
|
||||||
|
@POST @Path("/orders/new-vps")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
|
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
||||||
|
@MapBinder(RimuHostingCreateInstanceBinder.class)
|
||||||
|
Future<NewInstanceResponse> createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId, @MapEntityParam("password") String password);
|
||||||
|
|
||||||
@GET @Path("/orders/order-{id}-blah/vps")
|
@GET @Path("/orders/order-{id}-blah/vps")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ResponseParser(ParseInstanceInfoFromJsonResponse.class)
|
@ResponseParser(ParseInstanceInfoFromJsonResponse.class)
|
||||||
Future<InstanceInfo> getInstanceInfo(@PathParam("id") Long id);
|
Future<InstanceInfo> getInstanceInfo(@PathParam("id") Long id);
|
||||||
|
|
||||||
|
|
||||||
@GET @Path("/orders/order-{id}-blah")
|
@GET @Path("/orders/order-{id}-blah")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ResponseParser(ParseInstanceFromJsonResponse.class)
|
@ResponseParser(ParseInstanceFromJsonResponse.class)
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
Future<Instance> getInstance(@PathParam("id") Long id);
|
Future<Instance> getInstance(@PathParam("id") Long id);
|
||||||
|
|
||||||
|
|
||||||
//TODO fix this.
|
|
||||||
@PUT @Path("/orders/order-{id}-blah/vps/paramters")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@ResponseParser(ParseResizeResponseFromJsonResponse.class)
|
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
|
||||||
Future<ResizeResult> resizeInstance(@PathParam("id") Long id);
|
|
||||||
|
|
||||||
@PUT @Path("/orders/order-{id}-blah/vps/running-state")
|
@PUT @Path("/orders/order-{id}-blah/vps/running-state")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
|
|
@ -25,6 +25,7 @@ package org.jclouds.rimuhosting.miro;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
|
import org.jclouds.rest.annotations.MapEntityParam;
|
||||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
||||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||||
import org.jclouds.rimuhosting.miro.domain.*;
|
import org.jclouds.rimuhosting.miro.domain.*;
|
||||||
|
@ -33,6 +34,7 @@ import javax.ws.rs.PathParam;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to RimuHosting.
|
* Provides synchronous access to RimuHosting.
|
||||||
|
@ -51,15 +53,13 @@ public interface RimuHostingClient {
|
||||||
|
|
||||||
SortedSet<PricingPlan> getPricingPlanList();
|
SortedSet<PricingPlan> getPricingPlanList();
|
||||||
|
|
||||||
NewInstanceResponse createInstance(@BinderParam(RimuHostingJsonBinder.class)NewInstance newInstance);
|
NewInstanceResponse createInstance(String name, String imageId, String planId);
|
||||||
|
|
||||||
InstanceInfo getInstanceInfo(@PathParam("id") Long id);
|
NewInstanceResponse createInstance(String name, String imageId, String planId, String password);
|
||||||
|
|
||||||
Instance getInstance(@PathParam("id") Long id);
|
Instance getInstance(Long id);
|
||||||
|
|
||||||
InstanceInfo restartInstance(@PathParam("id") Long id);
|
InstanceInfo restartInstance(Long id);
|
||||||
|
|
||||||
ResizeResult resizeInstance(@PathParam("id") Long id);
|
List<String> destroyInstance(Long id);
|
||||||
|
|
||||||
List<String> destroyInstance(@PathParam("id") Long id);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.jclouds.rimuhosting.miro.binder;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||||
|
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Ivan Meredith
|
||||||
|
*/
|
||||||
|
public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
|
||||||
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
|
String name = checkNotNull(postParams.get("name"));
|
||||||
|
String imageId = checkNotNull(postParams.get("imageId"));
|
||||||
|
String planId = checkNotNull(postParams.get("planId"));
|
||||||
|
//There will be cases when the password is null.
|
||||||
|
String password = postParams.get("password");
|
||||||
|
NewInstance newInstance = new NewInstance(new CreateOptions(name, password, imageId), planId);
|
||||||
|
bindToRequest(request, newInstance);
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,8 +80,7 @@ public class RimuHostingClientLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLifeCycle() {
|
public void testLifeCycle() {
|
||||||
//Get the first image, we dont really care what it is in this test.
|
//Get the first image, we dont really care what it is in this test.
|
||||||
NewInstance inst = new NewInstance(new CreateOptions("test.jclouds.org",null,"lenny"),"MIRO1") ;
|
NewInstanceResponse instanceResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B");
|
||||||
NewInstanceResponse instanceResponse = connection.createInstance(inst);
|
|
||||||
Instance instance = instanceResponse.getInstance();
|
Instance instance = instanceResponse.getInstance();
|
||||||
//Now we have the instance, lets restart it
|
//Now we have the instance, lets restart it
|
||||||
assertNotNull(instance.getId());
|
assertNotNull(instance.getId());
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class RimuHostingComputeClient {
|
||||||
|
|
||||||
public Long start(String name, String planId, String imageId) {
|
public Long start(String name, String planId, String imageId) {
|
||||||
logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId);
|
logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId);
|
||||||
NewInstanceResponse instanceRespone = rhClient.createInstance(new NewInstance(new CreateOptions(name,null,imageId), planId));
|
NewInstanceResponse instanceRespone = rhClient.createInstance(name, imageId, planId);
|
||||||
logger.debug(">> VPS id(%d) started and running.", instanceRespone.getInstance().getId());
|
logger.debug(">> VPS id(%d) started and running.", instanceRespone.getInstance().getId());
|
||||||
return instanceRespone.getInstance().getId();
|
return instanceRespone.getInstance().getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class RimuHostingComputeClientLiveTest {
|
||||||
IOException {
|
IOException {
|
||||||
String imageId = "lenny";
|
String imageId = "lenny";
|
||||||
String serverName = "test.jclouds.org";
|
String serverName = "test.jclouds.org";
|
||||||
String planId = "MIRO1";
|
String planId = "MIRO1B";
|
||||||
|
|
||||||
id = client.start(serverName, planId, imageId);
|
id = client.start(serverName, planId, imageId);
|
||||||
Instance instance = rhClient.getInstance(id);
|
Instance instance = rhClient.getInstance(id);
|
||||||
|
|
Loading…
Reference in New Issue