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:
ivan@ivan.net.nz 2009-11-30 03:54:42 +00:00
parent 84116b387c
commit 77306b5d76
19 changed files with 133 additions and 146 deletions

View File

@ -24,10 +24,8 @@
package org.jclouds.rimuhosting.miro; 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.RimuHostingRebootJsonBinder; import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
import org.jclouds.rimuhosting.miro.binder.RimuHostingCreateInstanceBinder; 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.domain.*;
import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication; import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication;
import org.jclouds.rimuhosting.miro.functions.*; import org.jclouds.rimuhosting.miro.functions.*;
@ -63,7 +61,7 @@ public interface RimuHostingAsyncClient {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ParseRimuHostingException.class) @ExceptionParser(ParseRimuHostingException.class)
Future<SortedSet<Instance>> getInstanceList(); Future<SortedSet<Server>> getInstanceList();
@GET @Path("/pricing-plans") @GET @Path("/pricing-plans")
@MatrixParams(keys = "server-type", values = "VPS") @MatrixParams(keys = "server-type", values = "VPS")
@ -78,7 +76,7 @@ public interface RimuHostingAsyncClient {
@ExceptionParser(ParseRimuHostingException.class) @ExceptionParser(ParseRimuHostingException.class)
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class) @ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
@MapBinder(RimuHostingCreateInstanceBinder.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") @POST @Path("/orders/new-vps")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -86,18 +84,18 @@ public interface RimuHostingAsyncClient {
@ExceptionParser(ParseRimuHostingException.class) @ExceptionParser(ParseRimuHostingException.class)
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class) @ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
@MapBinder(RimuHostingCreateInstanceBinder.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") @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<ServerInfo> 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<Server> getInstance(@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)
@ -105,7 +103,7 @@ public interface RimuHostingAsyncClient {
@ResponseParser(ParseInstanceInfoFromJsonResponse.class) @ResponseParser(ParseInstanceInfoFromJsonResponse.class)
@MapBinder(RimuHostingRebootJsonBinder.class) @MapBinder(RimuHostingRebootJsonBinder.class)
@ExceptionParser(ParseRimuHostingException.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") @DELETE @Path("/orders/order-{id}-blah/vps")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)

View File

@ -24,17 +24,11 @@
package org.jclouds.rimuhosting.miro; 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.MapEntityParam;
import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder;
import org.jclouds.rimuhosting.miro.data.NewInstance;
import org.jclouds.rimuhosting.miro.domain.*; import org.jclouds.rimuhosting.miro.domain.*;
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.
@ -49,17 +43,17 @@ public interface RimuHostingClient {
SortedSet<Image> getImageList(); SortedSet<Image> getImageList();
SortedSet<Instance> getInstanceList(); SortedSet<Server> getInstanceList();
SortedSet<PricingPlan> getPricingPlanList(); 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); List<String> destroyInstance(Long id);
} }

View File

@ -1,7 +1,7 @@
package org.jclouds.rimuhosting.miro.binder; package org.jclouds.rimuhosting.miro.binder;
import org.jclouds.http.HttpRequest; 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 org.jclouds.rimuhosting.miro.data.CreateOptions;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -18,7 +18,7 @@ public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
String planId = checkNotNull(postParams.get("planId")); String planId = checkNotNull(postParams.get("planId"));
//There will be cases when the password is null. //There will be cases when the password is null.
String password = postParams.get("password"); String password = postParams.get("password");
NewInstance newInstance = new NewInstance(new CreateOptions(name, password, imageId), planId); NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
bindToRequest(request, newInstance); bindToRequest(request, newServerData);
} }
} }

View File

@ -31,7 +31,7 @@ import com.google.gson.annotations.SerializedName;
* *
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public class IpRequest implements PostData { public class IpRequestData implements PostData {
/** /**
* How many IPs you need.&nbsp; Typically 1.&nbsp; Typically you * How many IPs you need.&nbsp; Typically 1.&nbsp; Typically you
* only need more than one IP if your server has SSL certs for more * only need more than one IP if your server has SSL certs for more

View File

@ -24,7 +24,7 @@
package org.jclouds.rimuhosting.miro.data; package org.jclouds.rimuhosting.miro.data;
import com.google.gson.annotations.SerializedName; 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; import org.jclouds.rimuhosting.miro.domain.PricingPlan;
/** /**
@ -32,22 +32,22 @@ import org.jclouds.rimuhosting.miro.domain.PricingPlan;
* *
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public class NewInstance implements PostData{ public class NewServerData implements PostData{
public NewInstance(){} public NewServerData(){}
public NewInstance(CreateOptions createOptions, PricingPlan pricingPlan){ public NewServerData(CreateOptions createOptions, PricingPlan pricingPlan){
this.createOptions = createOptions; this.createOptions = createOptions;
if(pricingPlan != null){ if(pricingPlan != null){
this.planId = pricingPlan.getId(); this.planId = pricingPlan.getId();
} }
} }
public NewInstance(CreateOptions createOptions, String pricingPlanId){ public NewServerData(CreateOptions createOptions, String pricingPlanId){
this.createOptions = createOptions; this.createOptions = createOptions;
this.planId = pricingPlanId; this.planId = pricingPlanId;
} }
public NewInstance(CloneOptions cloneOptions){ public NewServerData(CloneOptions cloneOptions){
this.cloneOptions = cloneOptions; this.cloneOptions = cloneOptions;
} }
/** /**
@ -91,7 +91,7 @@ public class NewInstance implements PostData{
* most servers need). * most servers need).
*/ */
@SerializedName("ip_request") @SerializedName("ip_request")
private IpRequest ipRequest; private IpRequestData ipRequest;
/** /**
* The pricing plan code you want to use.&nbsp; Per the pricing plans * The pricing plan code you want to use.&nbsp; Per the pricing plans
* resource. * resource.
@ -118,7 +118,7 @@ public class NewInstance implements PostData{
* (that's not a problem on the bigger-, non-low contention-plans. * (that's not a problem on the bigger-, non-low contention-plans.
*/ */
@SerializedName("vps_paramters") @SerializedName("vps_paramters")
private InstanceParameters instanceParameters; private ServerParameters serverParameters;
public Long getBillingId() { public Long getBillingId() {
return billingId; return billingId;
@ -152,11 +152,11 @@ public class NewInstance implements PostData{
this.cloneOptions = cloneOptions; this.cloneOptions = cloneOptions;
} }
public IpRequest getIpRequest() { public IpRequestData getIpRequest() {
return ipRequest; return ipRequest;
} }
public void setIpRequest(IpRequest ipRequest) { public void setIpRequest(IpRequestData ipRequest) {
this.ipRequest = ipRequest; this.ipRequest = ipRequest;
} }
@ -176,12 +176,12 @@ public class NewInstance implements PostData{
this.userId = userId; this.userId = userId;
} }
public InstanceParameters getInstanceParameters() { public ServerParameters getInstanceParameters() {
return instanceParameters; return serverParameters;
} }
public void setInstanceParameters(InstanceParameters instanceParameters) { public void setInstanceParameters(ServerParameters serverParameters) {
this.instanceParameters = instanceParameters; this.serverParameters = serverParameters;
} }
public void validate(){ public void validate(){
@ -199,8 +199,8 @@ public class NewInstance implements PostData{
this.ipRequest.validate(); this.ipRequest.validate();
} }
if(this.instanceParameters != null){ if(this.serverParameters != null){
this.instanceParameters.validate(); this.serverParameters.validate();
} }
} }
} }

View File

@ -24,7 +24,7 @@
package org.jclouds.rimuhosting.miro.domain; package org.jclouds.rimuhosting.miro.domain;
import com.google.gson.annotations.SerializedName; 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 * 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 * @author Ivan Meredith
*/ */
public class NewInstanceResponse implements Comparable<NewInstanceResponse> { public class NewServerResponse implements Comparable<NewServerResponse> {
@SerializedName("about_order") @SerializedName("about_order")
private Instance instance; private Server server;
@SerializedName("new_order_request") @SerializedName("new_order_request")
private NewInstance newInstanceRequest; private NewServerData newServerDataRequest;
@SerializedName("running_vps_info") @SerializedName("running_vps_info")
private InstanceInfo instanceInfo; private ServerInfo serverInfo;
public Instance getInstance() { public Server getInstance() {
return instance; return server;
} }
public void setInstance(Instance instaince) { public void setInstance(Server instaince) {
this.instance = instaince; this.server = instaince;
} }
public NewInstance getNewInstanceRequest() { public NewServerData getNewInstanceRequest() {
return newInstanceRequest; return newServerDataRequest;
} }
public void setNewInstanceRequest(NewInstance newInstanceRequest) { public void setNewInstanceRequest(NewServerData newServerDataRequest) {
this.newInstanceRequest = newInstanceRequest; this.newServerDataRequest = newServerDataRequest;
} }
public InstanceInfo getInstanceInfo() { public ServerInfo getInstanceInfo() {
return instanceInfo; return serverInfo;
} }
public void setInstanceInfo(InstanceInfo instanceInfo) { public void setInstanceInfo(ServerInfo serverInfo) {
this.instanceInfo = instanceInfo; this.serverInfo = serverInfo;
} }
@Override @Override
public int compareTo(NewInstanceResponse instance) { public int compareTo(NewServerResponse server) {
return this.instance.getId().compareTo(instance.getInstance().getId()); return this.server.getId().compareTo(server.getInstance().getId());
} }
} }

View File

@ -24,7 +24,7 @@
package org.jclouds.rimuhosting.miro.domain; package org.jclouds.rimuhosting.miro.domain;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import org.jclouds.rimuhosting.miro.data.NewInstance; import org.jclouds.rimuhosting.miro.data.NewServerData;
/** /**
* Instance Object. * Instance Object.
@ -32,7 +32,7 @@ import org.jclouds.rimuhosting.miro.data.NewInstance;
* *
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public class Instance implements Comparable<Instance> { public class Server implements Comparable<Server> {
@SerializedName("allocated_ips") @SerializedName("allocated_ips")
@ -60,10 +60,10 @@ public class Instance implements Comparable<Instance> {
private String type; private String type;
private String slug; private String slug;
@SerializedName("vps_parameters") @SerializedName("vps_parameters")
private InstanceParameters instanceParameters; private ServerParameters serverParameters;
//Object returned back with //Object returned back with
private transient NewInstance instanceRequest; private transient NewServerData serverDataRequest;
public IpAddresses getIpAddresses() { public IpAddresses getIpAddresses() {
@ -162,24 +162,24 @@ public class Instance implements Comparable<Instance> {
this.slug = slug; this.slug = slug;
} }
public InstanceParameters getInstanceParameters() { public ServerParameters getInstanceParameters() {
return instanceParameters; return serverParameters;
} }
public void setInstanceParameters(InstanceParameters instanceParameters) { public void setInstanceParameters(ServerParameters serverParameters) {
this.instanceParameters = instanceParameters; this.serverParameters = serverParameters;
} }
public NewInstance getInstanceRequest() { public NewServerData getInstanceRequest() {
return instanceRequest; return serverDataRequest;
} }
public void setInstanceRequest(NewInstance instanceRequest) { public void setInstanceRequest(NewServerData serverDataRequest) {
this.instanceRequest = instanceRequest; this.serverDataRequest = serverDataRequest;
} }
@Override @Override
public int compareTo(Instance instance) { public int compareTo(Server server) {
return name.compareTo(instance.getName()); return name.compareTo(server.getName());
} }
} }

View File

@ -30,7 +30,7 @@ import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
/** /**
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public class InstanceInfo { public class ServerInfo {
/** /**
* Whether the server pinged from the host server. * Whether the server pinged from the host server.
*/ */

View File

@ -33,7 +33,7 @@ import org.jclouds.rimuhosting.miro.data.PostData;
* *
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public class InstanceParameters implements PostData { public class ServerParameters implements PostData {
/** /**
* File system image size. * File system image size.
*/ */

View File

@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jclouds.http.functions.ParseJson; 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 org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
import javax.inject.Inject; import javax.inject.Inject;
@ -42,24 +42,24 @@ import java.util.Map;
*/ */
@Singleton @Singleton
public class ParseInstanceFromJsonResponse extends ParseJson<Instance> { public class ParseInstanceFromJsonResponse extends ParseJson<Server> {
@Inject @Inject
public ParseInstanceFromJsonResponse(Gson gson) { public ParseInstanceFromJsonResponse(Gson gson) {
super(gson); super(gson);
} }
private static class OrderResponse extends RimuHostingResponse { private static class OrderResponse extends RimuHostingResponse {
private Instance about_order; private Server about_order;
public Instance getAboutOrder() { public Server getAboutOrder() {
return about_order; return about_order;
} }
public void setAboutOrder(Instance about_orders) { public void setAboutOrder(Server about_orders) {
this.about_order = about_orders; this.about_order = about_orders;
} }
} }
@Override @Override
protected Instance apply(InputStream stream) { protected Server apply(InputStream stream) {
Type setType = new TypeToken<Map<String, OrderResponse>>() { Type setType = new TypeToken<Map<String, OrderResponse>>() {
}.getType(); }.getType();
try { try {

View File

@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jclouds.http.functions.ParseJson; 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 org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
import javax.inject.Inject; import javax.inject.Inject;
@ -41,25 +41,25 @@ import java.util.Map;
* @author Ivan Meredith * @author Ivan Meredith
*/ */
@Singleton @Singleton
public class ParseInstanceInfoFromJsonResponse extends ParseJson<InstanceInfo> { public class ParseInstanceInfoFromJsonResponse extends ParseJson<ServerInfo> {
@Inject @Inject
public ParseInstanceInfoFromJsonResponse(Gson gson) { public ParseInstanceInfoFromJsonResponse(Gson gson) {
super(gson); super(gson);
} }
private static class OrderResponse extends RimuHostingResponse { 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; 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; this.running_vps_info = running_vps_info;
} }
} }
@Override @Override
protected InstanceInfo apply(InputStream stream) { protected ServerInfo apply(InputStream stream) {
Type setType = new TypeToken<Map<String, OrderResponse>>() { Type setType = new TypeToken<Map<String, OrderResponse>>() {
}.getType(); }.getType();
try { try {

View File

@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jclouds.http.functions.ParseJson; 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 org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
import javax.inject.Inject; import javax.inject.Inject;
@ -42,24 +42,24 @@ import java.util.SortedSet;
* @author Ivan Meredith * @author Ivan Meredith
*/ */
@Singleton @Singleton
public class ParseInstancesFromJsonResponse extends ParseJson<SortedSet<Instance>> { public class ParseInstancesFromJsonResponse extends ParseJson<SortedSet<Server>> {
@Inject @Inject
public ParseInstancesFromJsonResponse(Gson gson) { public ParseInstancesFromJsonResponse(Gson gson) {
super(gson); super(gson);
} }
private static class OrderResponse extends RimuHostingResponse { private static class OrderResponse extends RimuHostingResponse {
private SortedSet<Instance> about_orders; private SortedSet<Server> about_orders;
public SortedSet<Instance> getAboutOrders() { public SortedSet<Server> getAboutOrders() {
return about_orders; return about_orders;
} }
public void setAboutOrders(SortedSet<Instance> about_orders) { public void setAboutOrders(SortedSet<Server> about_orders) {
this.about_orders = about_orders; this.about_orders = about_orders;
} }
} }
@Override @Override
protected SortedSet<Instance> apply(InputStream stream) { protected SortedSet<Server> apply(InputStream stream) {
Type setType = new TypeToken<Map<String, OrderResponse>>() { Type setType = new TypeToken<Map<String, OrderResponse>>() {
}.getType(); }.getType();
try { try {

View File

@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jclouds.http.functions.ParseJson; 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.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -42,18 +42,18 @@ import java.util.Map;
*/ */
@Singleton @Singleton
public class ParseNewInstanceResponseFromJsonResponse extends ParseJson<NewInstanceResponse> { public class ParseNewInstanceResponseFromJsonResponse extends ParseJson<NewServerResponse> {
@Inject @Inject
public ParseNewInstanceResponseFromJsonResponse(Gson gson) { public ParseNewInstanceResponseFromJsonResponse(Gson gson) {
super(gson); super(gson);
} }
@Override @Override
protected NewInstanceResponse apply(InputStream stream) { protected NewServerResponse apply(InputStream stream) {
Type setType = new TypeToken<Map<String, NewInstanceResponse>>() { Type setType = new TypeToken<Map<String, NewServerResponse>>() {
}.getType(); }.getType();
try { 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(); return responseMap.values().iterator().next();
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException("jclouds requires UTF-8 encoding", e); throw new RuntimeException("jclouds requires UTF-8 encoding", e);

View File

@ -26,7 +26,7 @@ package org.jclouds.rimuhosting.miro.functions;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jclouds.http.functions.ParseJson; 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 org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
import javax.inject.Inject; import javax.inject.Inject;
@ -47,7 +47,7 @@ public class ParseResizeResponseFromJsonResponse extends ParseJson<ParseResizeRe
} }
public static class ResizeResponse extends RimuHostingResponse { public static class ResizeResponse extends RimuHostingResponse {
private Instance about_order; private Server about_order;
private ResizeResponse resource_change_result; private ResizeResponse resource_change_result;
public ResizeResponse getResourceChangeResult() { public ResizeResponse getResourceChangeResult() {
@ -58,11 +58,11 @@ public class ParseResizeResponseFromJsonResponse extends ParseJson<ParseResizeRe
this.resource_change_result = resource_change_result; this.resource_change_result = resource_change_result;
} }
public Instance getAboutOrder() { public Server getAboutOrder() {
return about_order; return about_order;
} }
public void setAboutOrder(Instance about_orders) { public void setAboutOrder(Server about_orders) {
this.about_order = about_orders; this.about_order = about_orders;
} }
} }

View File

@ -25,8 +25,6 @@ package org.jclouds.rimuhosting.miro;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; 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.*;
import org.jclouds.rimuhosting.miro.domain.internal.RunningState; import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
import static org.testng.Assert.*; import static org.testng.Assert.*;
@ -80,15 +78,15 @@ 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.
NewInstanceResponse instanceResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B"); NewServerResponse serverResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B");
Instance instance = instanceResponse.getInstance(); Server server = serverResponse.getInstance();
//Now we have the instance, lets restart it //Now we have the server, lets restart it
assertNotNull(instance.getId()); assertNotNull(server.getId());
InstanceInfo instanceInfo = connection.restartInstance(instance.getId()); ServerInfo serverInfo = connection.restartInstance(server.getId());
connection.destroyInstance(instance.getId()); connection.destroyInstance(server.getId());
//Should be running now. //Should be running now.
assertEquals(instanceInfo.getState(), RunningState.RUNNING); assertEquals(serverInfo.getState(), RunningState.RUNNING);
assertEquals(instance.getName(),"test.jclouds.org"); assertEquals(server.getName(),"test.jclouds.org");
assertEquals(instance.getImageId(), "lenny"); assertEquals(server.getImageId(), "lenny");
} }
} }

View File

@ -25,10 +25,8 @@ package org.jclouds.rimuhosting.miro;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rimuhosting.miro.data.CreateOptions; import org.jclouds.rimuhosting.miro.domain.Server;
import org.jclouds.rimuhosting.miro.data.NewInstance; import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
import org.jclouds.rimuhosting.miro.domain.Instance;
import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse;
import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshClient.Factory;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -58,23 +56,23 @@ 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(name, imageId, planId); NewServerResponse serverRespone = rhClient.createInstance(name, imageId, planId);
logger.debug(">> VPS id(%d) started and running.", instanceRespone.getInstance().getId()); logger.debug(">> VPS id(%d) started and running.", serverRespone.getInstance().getId());
return instanceRespone.getInstance().getId(); return serverRespone.getInstance().getId();
} }
public void reboot(Long id) { public void reboot(Long id) {
Instance instance = rhClient.getInstance(id); Server server = rhClient.getInstance(id);
logger.debug(">> rebooting VPS(%d)", instance.getId()); logger.debug(">> rebooting VPS(%d)", server.getId());
rhClient.restartInstance(id); rhClient.restartInstance(id);
logger.debug("<< on VPS(%d)", instance.getId()); logger.debug("<< on VPS(%d)", server.getId());
} }
public void destroy(Long id) { public void destroy(Long id) {
Instance instance = rhClient.getInstance(id); Server server = rhClient.getInstance(id);
logger.debug(">> destroy VPS(%d)", instance.getId()); logger.debug(">> destroy VPS(%d)", server.getId());
rhClient.destroyInstance(id); rhClient.destroyInstance(id);
logger.debug(">> destroyed VPS"); logger.debug(">> destroyed VPS");
} }

View File

@ -30,7 +30,7 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.predicates.AddressReachable; import org.jclouds.predicates.AddressReachable;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; 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 org.jclouds.ssh.jsch.config.JschSshClientModule;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
@ -68,10 +68,10 @@ public class RimuHostingComputeClientLiveTest {
String planId = "MIRO1B"; String planId = "MIRO1B";
id = client.start(serverName, planId, imageId); id = client.start(serverName, planId, imageId);
Instance instance = rhClient.getInstance(id); Server server = rhClient.getInstance(id);
assertEquals(imageId, instance.getImageId()); assertEquals(imageId, server.getImageId());
assertEquals(serverName, instance.getName()); assertEquals(serverName, server.getName());
assertEquals(new Integer(160), instance.getInstanceParameters().getRam()); assertEquals(new Integer(160), server.getInstanceParameters().getRam());
} }
@AfterTest @AfterTest

View File

@ -1,10 +1,9 @@
package org.jclouds.rimuhosting.miro.servers; package org.jclouds.rimuhosting.miro.servers;
import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeService;
import org.jclouds.compute.Server;
import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.rimuhosting.miro.RimuHostingClient;
import org.jclouds.rimuhosting.miro.domain.Instance; import org.jclouds.rimuhosting.miro.domain.Server;
import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse; import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.inject.Inject; import javax.inject.Inject;
@ -24,25 +23,25 @@ public class RimuHostingComputeService implements ComputeService {
this.rhClient = rhClient; this.rhClient = rhClient;
} }
public Server createServerAndWait(String name, String profile, String image) { public org.jclouds.compute.Server createServerAndWait(String name, String profile, String image) {
NewInstanceResponse instanceResp = rhClient.createInstance(name, image, profile); NewServerResponse serverResp = rhClient.createInstance(name, image, profile);
return new RimuHostingServer(instanceResp.getInstance(), rhClient); 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. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public SortedSet<Server> listServers() { public SortedSet<org.jclouds.compute.Server> listServers() {
SortedSet<Server> servers = new TreeSet<Server>(); SortedSet<org.jclouds.compute.Server> servers = new TreeSet<org.jclouds.compute.Server>();
SortedSet<Instance> rhServers = rhClient.getInstanceList(); SortedSet<Server> rhServers = rhClient.getInstanceList();
for(Instance rhServer : rhServers) { for(Server rhServer : rhServers) {
servers.add(new RimuHostingServer(rhServer,rhClient)); servers.add(new RimuHostingServer(rhServer,rhClient));
} }
return servers; return servers;
} }
public Server getServer(String id) { public org.jclouds.compute.Server getServer(String id) {
return new RimuHostingServer(rhClient.getInstance(Long.valueOf(id)), rhClient); return new RimuHostingServer(rhClient.getInstance(Long.valueOf(id)), rhClient);
} }
} }

View File

@ -8,17 +8,17 @@ import org.jclouds.rimuhosting.miro.RimuHostingClient;
import java.util.SortedSet; import java.util.SortedSet;
public class RimuHostingServer implements Server { public class RimuHostingServer implements Server {
org.jclouds.rimuhosting.miro.domain.Instance rhInstance; org.jclouds.rimuhosting.miro.domain.Server rhServer;
RimuHostingClient rhClient; RimuHostingClient rhClient;
public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Instance rhInstance, RimuHostingClient rhClient){ public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Server rhServer, RimuHostingClient rhClient){
this.rhInstance = rhInstance; this.rhServer = rhServer;
this.rhClient = rhClient; this.rhClient = rhClient;
} }
public String getId() { public String getId() {
return rhInstance.toString(); return rhServer.toString();
} }
public Platform createPlatform(String id) { public Platform createPlatform(String id) {
@ -38,7 +38,7 @@ public class RimuHostingServer implements Server {
} }
public Boolean destroyServer() { public Boolean destroyServer() {
rhClient.destroyInstance(rhInstance.getId()); rhClient.destroyInstance(rhServer.getId());
return Boolean.TRUE; return Boolean.TRUE;
} }
} }