mirror of https://github.com/apache/jclouds.git
Refactored some of the naming for classes
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2348 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
84116b387c
commit
77306b5d76
|
@ -24,10 +24,8 @@
|
|||
package org.jclouds.rimuhosting.miro;
|
||||
|
||||
import org.jclouds.rest.annotations.*;
|
||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
||||
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.domain.*;
|
||||
import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication;
|
||||
import org.jclouds.rimuhosting.miro.functions.*;
|
||||
|
@ -63,7 +61,7 @@ public interface RimuHostingAsyncClient {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ParseRimuHostingException.class)
|
||||
Future<SortedSet<Instance>> getInstanceList();
|
||||
Future<SortedSet<Server>> getInstanceList();
|
||||
|
||||
@GET @Path("/pricing-plans")
|
||||
@MatrixParams(keys = "server-type", values = "VPS")
|
||||
|
@ -78,7 +76,7 @@ public interface RimuHostingAsyncClient {
|
|||
@ExceptionParser(ParseRimuHostingException.class)
|
||||
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
||||
@MapBinder(RimuHostingCreateInstanceBinder.class)
|
||||
Future<NewInstanceResponse> createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId);
|
||||
Future<NewServerResponse> createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId);
|
||||
|
||||
@POST @Path("/orders/new-vps")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -86,18 +84,18 @@ public interface RimuHostingAsyncClient {
|
|||
@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);
|
||||
Future<NewServerResponse> createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId, @MapEntityParam("password") String password);
|
||||
|
||||
@GET @Path("/orders/order-{id}-blah/vps")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ResponseParser(ParseInstanceInfoFromJsonResponse.class)
|
||||
Future<InstanceInfo> getInstanceInfo(@PathParam("id") Long id);
|
||||
Future<ServerInfo> getInstanceInfo(@PathParam("id") Long id);
|
||||
|
||||
@GET @Path("/orders/order-{id}-blah")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ResponseParser(ParseInstanceFromJsonResponse.class)
|
||||
@ExceptionParser(ParseRimuHostingException.class)
|
||||
Future<Instance> getInstance(@PathParam("id") Long id);
|
||||
Future<Server> getInstance(@PathParam("id") Long id);
|
||||
|
||||
@PUT @Path("/orders/order-{id}-blah/vps/running-state")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -105,7 +103,7 @@ public interface RimuHostingAsyncClient {
|
|||
@ResponseParser(ParseInstanceInfoFromJsonResponse.class)
|
||||
@MapBinder(RimuHostingRebootJsonBinder.class)
|
||||
@ExceptionParser(ParseRimuHostingException.class)
|
||||
Future<InstanceInfo> restartInstance(@PathParam("id") Long id);
|
||||
Future<ServerInfo> restartInstance(@PathParam("id") Long id);
|
||||
|
||||
@DELETE @Path("/orders/order-{id}-blah/vps")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
|
|
@ -24,17 +24,11 @@
|
|||
package org.jclouds.rimuhosting.miro;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.MapEntityParam;
|
||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.domain.*;
|
||||
|
||||
import javax.ws.rs.PathParam;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to RimuHosting.
|
||||
|
@ -49,17 +43,17 @@ public interface RimuHostingClient {
|
|||
|
||||
SortedSet<Image> getImageList();
|
||||
|
||||
SortedSet<Instance> getInstanceList();
|
||||
SortedSet<Server> getInstanceList();
|
||||
|
||||
SortedSet<PricingPlan> getPricingPlanList();
|
||||
|
||||
NewInstanceResponse createInstance(String name, String imageId, String planId);
|
||||
NewServerResponse createInstance(String name, String imageId, String planId);
|
||||
|
||||
NewInstanceResponse createInstance(String name, String imageId, String planId, String password);
|
||||
NewServerResponse createInstance(String name, String imageId, String planId, String password);
|
||||
|
||||
Instance getInstance(Long id);
|
||||
Server getInstance(Long id);
|
||||
|
||||
InstanceInfo restartInstance(Long id);
|
||||
ServerInfo restartInstance(Long id);
|
||||
|
||||
List<String> destroyInstance(Long id);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.jclouds.rimuhosting.miro.binder;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -18,7 +18,7 @@ public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
|
|||
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);
|
||||
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
||||
bindToRequest(request, newServerData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.google.gson.annotations.SerializedName;
|
|||
*
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class IpRequest implements PostData {
|
||||
public class IpRequestData implements PostData {
|
||||
/**
|
||||
* How many IPs you need. Typically 1. Typically you
|
||||
* only need more than one IP if your server has SSL certs for more
|
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.rimuhosting.miro.data;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jclouds.rimuhosting.miro.domain.InstanceParameters;
|
||||
import org.jclouds.rimuhosting.miro.domain.ServerParameters;
|
||||
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
||||
|
||||
/**
|
||||
|
@ -32,22 +32,22 @@ import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
|||
*
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class NewInstance implements PostData{
|
||||
public NewInstance(){}
|
||||
public class NewServerData implements PostData{
|
||||
public NewServerData(){}
|
||||
|
||||
public NewInstance(CreateOptions createOptions, PricingPlan pricingPlan){
|
||||
public NewServerData(CreateOptions createOptions, PricingPlan pricingPlan){
|
||||
this.createOptions = createOptions;
|
||||
if(pricingPlan != null){
|
||||
this.planId = pricingPlan.getId();
|
||||
}
|
||||
}
|
||||
|
||||
public NewInstance(CreateOptions createOptions, String pricingPlanId){
|
||||
public NewServerData(CreateOptions createOptions, String pricingPlanId){
|
||||
this.createOptions = createOptions;
|
||||
this.planId = pricingPlanId;
|
||||
}
|
||||
|
||||
public NewInstance(CloneOptions cloneOptions){
|
||||
public NewServerData(CloneOptions cloneOptions){
|
||||
this.cloneOptions = cloneOptions;
|
||||
}
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ public class NewInstance implements PostData{
|
|||
* most servers need).
|
||||
*/
|
||||
@SerializedName("ip_request")
|
||||
private IpRequest ipRequest;
|
||||
private IpRequestData ipRequest;
|
||||
/**
|
||||
* The pricing plan code you want to use. Per the pricing plans
|
||||
* resource.
|
||||
|
@ -118,7 +118,7 @@ public class NewInstance implements PostData{
|
|||
* (that's not a problem on the bigger-, non-low contention-plans.
|
||||
*/
|
||||
@SerializedName("vps_paramters")
|
||||
private InstanceParameters instanceParameters;
|
||||
private ServerParameters serverParameters;
|
||||
|
||||
public Long getBillingId() {
|
||||
return billingId;
|
||||
|
@ -152,11 +152,11 @@ public class NewInstance implements PostData{
|
|||
this.cloneOptions = cloneOptions;
|
||||
}
|
||||
|
||||
public IpRequest getIpRequest() {
|
||||
public IpRequestData getIpRequest() {
|
||||
return ipRequest;
|
||||
}
|
||||
|
||||
public void setIpRequest(IpRequest ipRequest) {
|
||||
public void setIpRequest(IpRequestData ipRequest) {
|
||||
this.ipRequest = ipRequest;
|
||||
}
|
||||
|
||||
|
@ -176,12 +176,12 @@ public class NewInstance implements PostData{
|
|||
this.userId = userId;
|
||||
}
|
||||
|
||||
public InstanceParameters getInstanceParameters() {
|
||||
return instanceParameters;
|
||||
public ServerParameters getInstanceParameters() {
|
||||
return serverParameters;
|
||||
}
|
||||
|
||||
public void setInstanceParameters(InstanceParameters instanceParameters) {
|
||||
this.instanceParameters = instanceParameters;
|
||||
public void setInstanceParameters(ServerParameters serverParameters) {
|
||||
this.serverParameters = serverParameters;
|
||||
}
|
||||
|
||||
public void validate(){
|
||||
|
@ -199,8 +199,8 @@ public class NewInstance implements PostData{
|
|||
this.ipRequest.validate();
|
||||
}
|
||||
|
||||
if(this.instanceParameters != null){
|
||||
this.instanceParameters.validate();
|
||||
if(this.serverParameters != null){
|
||||
this.serverParameters.validate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.rimuhosting.miro.domain;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||
|
||||
/**
|
||||
* Wrapper object to get back all data from a Instance create. The Password has been populated the NewInstance
|
||||
|
@ -32,42 +32,42 @@ import org.jclouds.rimuhosting.miro.data.NewInstance;
|
|||
*
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class NewInstanceResponse implements Comparable<NewInstanceResponse> {
|
||||
public class NewServerResponse implements Comparable<NewServerResponse> {
|
||||
@SerializedName("about_order")
|
||||
private Instance instance;
|
||||
private Server server;
|
||||
|
||||
@SerializedName("new_order_request")
|
||||
private NewInstance newInstanceRequest;
|
||||
private NewServerData newServerDataRequest;
|
||||
|
||||
@SerializedName("running_vps_info")
|
||||
private InstanceInfo instanceInfo;
|
||||
private ServerInfo serverInfo;
|
||||
|
||||
public Instance getInstance() {
|
||||
return instance;
|
||||
public Server getInstance() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setInstance(Instance instaince) {
|
||||
this.instance = instaince;
|
||||
public void setInstance(Server instaince) {
|
||||
this.server = instaince;
|
||||
}
|
||||
|
||||
public NewInstance getNewInstanceRequest() {
|
||||
return newInstanceRequest;
|
||||
public NewServerData getNewInstanceRequest() {
|
||||
return newServerDataRequest;
|
||||
}
|
||||
|
||||
public void setNewInstanceRequest(NewInstance newInstanceRequest) {
|
||||
this.newInstanceRequest = newInstanceRequest;
|
||||
public void setNewInstanceRequest(NewServerData newServerDataRequest) {
|
||||
this.newServerDataRequest = newServerDataRequest;
|
||||
}
|
||||
|
||||
public InstanceInfo getInstanceInfo() {
|
||||
return instanceInfo;
|
||||
public ServerInfo getInstanceInfo() {
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
public void setInstanceInfo(InstanceInfo instanceInfo) {
|
||||
this.instanceInfo = instanceInfo;
|
||||
public void setInstanceInfo(ServerInfo serverInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NewInstanceResponse instance) {
|
||||
return this.instance.getId().compareTo(instance.getInstance().getId());
|
||||
public int compareTo(NewServerResponse server) {
|
||||
return this.server.getId().compareTo(server.getInstance().getId());
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.rimuhosting.miro.domain;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||
|
||||
/**
|
||||
* Instance Object.
|
||||
|
@ -32,7 +32,7 @@ import org.jclouds.rimuhosting.miro.data.NewInstance;
|
|||
*
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class Instance implements Comparable<Instance> {
|
||||
public class Server implements Comparable<Server> {
|
||||
|
||||
|
||||
@SerializedName("allocated_ips")
|
||||
|
@ -60,10 +60,10 @@ public class Instance implements Comparable<Instance> {
|
|||
private String type;
|
||||
private String slug;
|
||||
@SerializedName("vps_parameters")
|
||||
private InstanceParameters instanceParameters;
|
||||
private ServerParameters serverParameters;
|
||||
|
||||
//Object returned back with
|
||||
private transient NewInstance instanceRequest;
|
||||
private transient NewServerData serverDataRequest;
|
||||
|
||||
|
||||
public IpAddresses getIpAddresses() {
|
||||
|
@ -162,24 +162,24 @@ public class Instance implements Comparable<Instance> {
|
|||
this.slug = slug;
|
||||
}
|
||||
|
||||
public InstanceParameters getInstanceParameters() {
|
||||
return instanceParameters;
|
||||
public ServerParameters getInstanceParameters() {
|
||||
return serverParameters;
|
||||
}
|
||||
|
||||
public void setInstanceParameters(InstanceParameters instanceParameters) {
|
||||
this.instanceParameters = instanceParameters;
|
||||
public void setInstanceParameters(ServerParameters serverParameters) {
|
||||
this.serverParameters = serverParameters;
|
||||
}
|
||||
|
||||
public NewInstance getInstanceRequest() {
|
||||
return instanceRequest;
|
||||
public NewServerData getInstanceRequest() {
|
||||
return serverDataRequest;
|
||||
}
|
||||
|
||||
public void setInstanceRequest(NewInstance instanceRequest) {
|
||||
this.instanceRequest = instanceRequest;
|
||||
public void setInstanceRequest(NewServerData serverDataRequest) {
|
||||
this.serverDataRequest = serverDataRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Instance instance) {
|
||||
return name.compareTo(instance.getName());
|
||||
public int compareTo(Server server) {
|
||||
return name.compareTo(server.getName());
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
|||
/**
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class InstanceInfo {
|
||||
public class ServerInfo {
|
||||
/**
|
||||
* Whether the server pinged from the host server.
|
||||
*/
|
|
@ -33,7 +33,7 @@ import org.jclouds.rimuhosting.miro.data.PostData;
|
|||
*
|
||||
* @author Ivan Meredith
|
||||
*/
|
||||
public class InstanceParameters implements PostData {
|
||||
public class ServerParameters implements PostData {
|
||||
/**
|
||||
* File system image size.
|
||||
*/
|
|
@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -42,24 +42,24 @@ import java.util.Map;
|
|||
*/
|
||||
|
||||
@Singleton
|
||||
public class ParseInstanceFromJsonResponse extends ParseJson<Instance> {
|
||||
public class ParseInstanceFromJsonResponse extends ParseJson<Server> {
|
||||
@Inject
|
||||
public ParseInstanceFromJsonResponse(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
private static class OrderResponse extends RimuHostingResponse {
|
||||
private Instance about_order;
|
||||
public Instance getAboutOrder() {
|
||||
private Server about_order;
|
||||
public Server getAboutOrder() {
|
||||
return about_order;
|
||||
}
|
||||
|
||||
public void setAboutOrder(Instance about_orders) {
|
||||
public void setAboutOrder(Server about_orders) {
|
||||
this.about_order = about_orders;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected Instance apply(InputStream stream) {
|
||||
protected Server apply(InputStream stream) {
|
||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||
}.getType();
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rimuhosting.miro.domain.InstanceInfo;
|
||||
import org.jclouds.rimuhosting.miro.domain.ServerInfo;
|
||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -41,25 +41,25 @@ import java.util.Map;
|
|||
* @author Ivan Meredith
|
||||
*/
|
||||
@Singleton
|
||||
public class ParseInstanceInfoFromJsonResponse extends ParseJson<InstanceInfo> {
|
||||
public class ParseInstanceInfoFromJsonResponse extends ParseJson<ServerInfo> {
|
||||
@Inject
|
||||
public ParseInstanceInfoFromJsonResponse(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
private static class OrderResponse extends RimuHostingResponse {
|
||||
private InstanceInfo running_vps_info;
|
||||
private ServerInfo running_vps_info;
|
||||
|
||||
public InstanceInfo getInstanceInfo() {
|
||||
public ServerInfo getInstanceInfo() {
|
||||
return running_vps_info;
|
||||
}
|
||||
|
||||
public void setInstanceInfo(InstanceInfo running_vps_info) {
|
||||
public void setInstanceInfo(ServerInfo running_vps_info) {
|
||||
this.running_vps_info = running_vps_info;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected InstanceInfo apply(InputStream stream) {
|
||||
protected ServerInfo apply(InputStream stream) {
|
||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||
}.getType();
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -42,24 +42,24 @@ import java.util.SortedSet;
|
|||
* @author Ivan Meredith
|
||||
*/
|
||||
@Singleton
|
||||
public class ParseInstancesFromJsonResponse extends ParseJson<SortedSet<Instance>> {
|
||||
public class ParseInstancesFromJsonResponse extends ParseJson<SortedSet<Server>> {
|
||||
@Inject
|
||||
public ParseInstancesFromJsonResponse(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
private static class OrderResponse extends RimuHostingResponse {
|
||||
private SortedSet<Instance> about_orders;
|
||||
public SortedSet<Instance> getAboutOrders() {
|
||||
private SortedSet<Server> about_orders;
|
||||
public SortedSet<Server> getAboutOrders() {
|
||||
return about_orders;
|
||||
}
|
||||
|
||||
public void setAboutOrders(SortedSet<Instance> about_orders) {
|
||||
public void setAboutOrders(SortedSet<Server> about_orders) {
|
||||
this.about_orders = about_orders;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected SortedSet<Instance> apply(InputStream stream) {
|
||||
protected SortedSet<Server> apply(InputStream stream) {
|
||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||
}.getType();
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -42,18 +42,18 @@ import java.util.Map;
|
|||
*/
|
||||
|
||||
@Singleton
|
||||
public class ParseNewInstanceResponseFromJsonResponse extends ParseJson<NewInstanceResponse> {
|
||||
public class ParseNewInstanceResponseFromJsonResponse extends ParseJson<NewServerResponse> {
|
||||
@Inject
|
||||
public ParseNewInstanceResponseFromJsonResponse(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NewInstanceResponse apply(InputStream stream) {
|
||||
Type setType = new TypeToken<Map<String, NewInstanceResponse>>() {
|
||||
protected NewServerResponse apply(InputStream stream) {
|
||||
Type setType = new TypeToken<Map<String, NewServerResponse>>() {
|
||||
}.getType();
|
||||
try {
|
||||
Map<String, NewInstanceResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
||||
Map<String, NewServerResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
||||
return responseMap.values().iterator().next();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -47,7 +47,7 @@ public class ParseResizeResponseFromJsonResponse extends ParseJson<ParseResizeRe
|
|||
}
|
||||
|
||||
public static class ResizeResponse extends RimuHostingResponse {
|
||||
private Instance about_order;
|
||||
private Server about_order;
|
||||
private ResizeResponse resource_change_result;
|
||||
|
||||
public ResizeResponse getResourceChangeResult() {
|
||||
|
@ -58,11 +58,11 @@ public class ParseResizeResponseFromJsonResponse extends ParseJson<ParseResizeRe
|
|||
this.resource_change_result = resource_change_result;
|
||||
}
|
||||
|
||||
public Instance getAboutOrder() {
|
||||
public Server getAboutOrder() {
|
||||
return about_order;
|
||||
}
|
||||
|
||||
public void setAboutOrder(Instance about_orders) {
|
||||
public void setAboutOrder(Server about_orders) {
|
||||
this.about_order = about_orders;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@ package org.jclouds.rimuhosting.miro;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.domain.*;
|
||||
import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
||||
import static org.testng.Assert.*;
|
||||
|
@ -80,15 +78,15 @@ public class RimuHostingClientLiveTest {
|
|||
@Test
|
||||
public void testLifeCycle() {
|
||||
//Get the first image, we dont really care what it is in this test.
|
||||
NewInstanceResponse instanceResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B");
|
||||
Instance instance = instanceResponse.getInstance();
|
||||
//Now we have the instance, lets restart it
|
||||
assertNotNull(instance.getId());
|
||||
InstanceInfo instanceInfo = connection.restartInstance(instance.getId());
|
||||
connection.destroyInstance(instance.getId());
|
||||
NewServerResponse serverResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B");
|
||||
Server server = serverResponse.getInstance();
|
||||
//Now we have the server, lets restart it
|
||||
assertNotNull(server.getId());
|
||||
ServerInfo serverInfo = connection.restartInstance(server.getId());
|
||||
connection.destroyInstance(server.getId());
|
||||
//Should be running now.
|
||||
assertEquals(instanceInfo.getState(), RunningState.RUNNING);
|
||||
assertEquals(instance.getName(),"test.jclouds.org");
|
||||
assertEquals(instance.getImageId(), "lenny");
|
||||
assertEquals(serverInfo.getState(), RunningState.RUNNING);
|
||||
assertEquals(server.getName(),"test.jclouds.org");
|
||||
assertEquals(server.getImageId(), "lenny");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,8 @@ package org.jclouds.rimuhosting.miro;
|
|||
|
||||
import com.google.common.base.Predicate;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||
import org.jclouds.rimuhosting.miro.data.NewInstance;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
||||
import org.jclouds.ssh.SshClient.Factory;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -58,23 +56,23 @@ public class RimuHostingComputeClient {
|
|||
|
||||
public Long start(String name, String planId, String imageId) {
|
||||
logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId);
|
||||
NewInstanceResponse instanceRespone = rhClient.createInstance(name, imageId, planId);
|
||||
logger.debug(">> VPS id(%d) started and running.", instanceRespone.getInstance().getId());
|
||||
return instanceRespone.getInstance().getId();
|
||||
NewServerResponse serverRespone = rhClient.createInstance(name, imageId, planId);
|
||||
logger.debug(">> VPS id(%d) started and running.", serverRespone.getInstance().getId());
|
||||
return serverRespone.getInstance().getId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void reboot(Long id) {
|
||||
Instance instance = rhClient.getInstance(id);
|
||||
logger.debug(">> rebooting VPS(%d)", instance.getId());
|
||||
Server server = rhClient.getInstance(id);
|
||||
logger.debug(">> rebooting VPS(%d)", server.getId());
|
||||
rhClient.restartInstance(id);
|
||||
logger.debug("<< on VPS(%d)", instance.getId());
|
||||
logger.debug("<< on VPS(%d)", server.getId());
|
||||
}
|
||||
|
||||
public void destroy(Long id) {
|
||||
Instance instance = rhClient.getInstance(id);
|
||||
logger.debug(">> destroy VPS(%d)", instance.getId());
|
||||
Server server = rhClient.getInstance(id);
|
||||
logger.debug(">> destroy VPS(%d)", server.getId());
|
||||
rhClient.destroyInstance(id);
|
||||
logger.debug(">> destroyed VPS");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|||
import org.jclouds.predicates.AddressReachable;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import org.testng.annotations.AfterTest;
|
||||
|
@ -68,10 +68,10 @@ public class RimuHostingComputeClientLiveTest {
|
|||
String planId = "MIRO1B";
|
||||
|
||||
id = client.start(serverName, planId, imageId);
|
||||
Instance instance = rhClient.getInstance(id);
|
||||
assertEquals(imageId, instance.getImageId());
|
||||
assertEquals(serverName, instance.getName());
|
||||
assertEquals(new Integer(160), instance.getInstanceParameters().getRam());
|
||||
Server server = rhClient.getInstance(id);
|
||||
assertEquals(imageId, server.getImageId());
|
||||
assertEquals(serverName, server.getName());
|
||||
assertEquals(new Integer(160), server.getInstanceParameters().getRam());
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.jclouds.rimuhosting.miro.servers;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.Server;
|
||||
import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
||||
import org.jclouds.rimuhosting.miro.domain.Instance;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse;
|
||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.inject.Inject;
|
||||
|
@ -24,25 +23,25 @@ public class RimuHostingComputeService implements ComputeService {
|
|||
this.rhClient = rhClient;
|
||||
}
|
||||
|
||||
public Server createServerAndWait(String name, String profile, String image) {
|
||||
NewInstanceResponse instanceResp = rhClient.createInstance(name, image, profile);
|
||||
return new RimuHostingServer(instanceResp.getInstance(), rhClient);
|
||||
public org.jclouds.compute.Server createServerAndWait(String name, String profile, String image) {
|
||||
NewServerResponse serverResp = rhClient.createInstance(name, image, profile);
|
||||
return new RimuHostingServer(serverResp.getInstance(), rhClient);
|
||||
}
|
||||
|
||||
public Future<Server> createServer(String name, String profile, String image) {
|
||||
public Future<org.jclouds.compute.Server> createServer(String name, String profile, String image) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public SortedSet<Server> listServers() {
|
||||
SortedSet<Server> servers = new TreeSet<Server>();
|
||||
SortedSet<Instance> rhServers = rhClient.getInstanceList();
|
||||
for(Instance rhServer : rhServers) {
|
||||
public SortedSet<org.jclouds.compute.Server> listServers() {
|
||||
SortedSet<org.jclouds.compute.Server> servers = new TreeSet<org.jclouds.compute.Server>();
|
||||
SortedSet<Server> rhServers = rhClient.getInstanceList();
|
||||
for(Server rhServer : rhServers) {
|
||||
servers.add(new RimuHostingServer(rhServer,rhClient));
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
public Server getServer(String id) {
|
||||
public org.jclouds.compute.Server getServer(String id) {
|
||||
return new RimuHostingServer(rhClient.getInstance(Long.valueOf(id)), rhClient);
|
||||
}
|
||||
}
|
|
@ -8,17 +8,17 @@ import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
|||
import java.util.SortedSet;
|
||||
|
||||
public class RimuHostingServer implements Server {
|
||||
org.jclouds.rimuhosting.miro.domain.Instance rhInstance;
|
||||
org.jclouds.rimuhosting.miro.domain.Server rhServer;
|
||||
|
||||
RimuHostingClient rhClient;
|
||||
|
||||
public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Instance rhInstance, RimuHostingClient rhClient){
|
||||
this.rhInstance = rhInstance;
|
||||
public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Server rhServer, RimuHostingClient rhClient){
|
||||
this.rhServer = rhServer;
|
||||
this.rhClient = rhClient;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return rhInstance.toString();
|
||||
return rhServer.toString();
|
||||
}
|
||||
|
||||
public Platform createPlatform(String id) {
|
||||
|
@ -38,7 +38,7 @@ public class RimuHostingServer implements Server {
|
|||
}
|
||||
|
||||
public Boolean destroyServer() {
|
||||
rhClient.destroyInstance(rhInstance.getId());
|
||||
rhClient.destroyInstance(rhServer.getId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue