mirror of https://github.com/apache/jclouds.git
Added location, and a fix to make node creation work.
This commit is contained in:
parent
2d61447e05
commit
39f3b6d12d
|
@ -20,11 +20,13 @@ package org.jclouds.rimuhosting.miro.binder;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||
import org.jclouds.rimuhosting.miro.domain.MetaData;
|
||||
|
||||
/**
|
||||
* @author Ivan Meredith
|
||||
|
@ -37,6 +39,7 @@ public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
|
|||
//There will be cases when the password is null.
|
||||
String password = postParams.get("password");
|
||||
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
||||
newServerData.setMetaData(new ArrayList<MetaData>());
|
||||
bindToRequest(request, newServerData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,7 +274,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
|||
|
||||
@Override
|
||||
public NodeMetadata apply(Server from) {
|
||||
Location location = new LocationImpl(LocationScope.ZONE, "//TODO", null, null);
|
||||
|
||||
Location location = new LocationImpl(LocationScope.ZONE, from.getLocation().getId(), from.getLocation().getName(), null);
|
||||
String tag = from.getName().replaceAll("-[0-9]+", "");
|
||||
Credentials creds = null;
|
||||
NodeState state = runningStateToNodeState.get(from.getState());
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.rimuhosting.miro.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.jclouds.rimuhosting.miro.domain.MetaData;
|
||||
import org.jclouds.rimuhosting.miro.domain.ServerParameters;
|
||||
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
||||
|
||||
|
@ -115,6 +119,9 @@ public class NewServerData implements PostData{
|
|||
@SerializedName("vps_paramters")
|
||||
private ServerParameters serverParameters;
|
||||
|
||||
@SerializedName("meta_data")
|
||||
private List<MetaData> metaData;
|
||||
|
||||
public Long getBillingId() {
|
||||
return billingId;
|
||||
}
|
||||
|
@ -198,4 +205,12 @@ public class NewServerData implements PostData{
|
|||
this.serverParameters.validate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMetaData(List<MetaData> metaData) {
|
||||
this.metaData = metaData;
|
||||
}
|
||||
|
||||
public List<MetaData> getMetaData() {
|
||||
return metaData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public class DataCenter implements Comparable<DataCenter> {
|
|||
private String id;
|
||||
@SerializedName("data_center_location_name")
|
||||
private String name;
|
||||
@SerializedName("data_center_location_country_2ltr")
|
||||
private String code;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -49,6 +51,14 @@ public class DataCenter implements Comparable<DataCenter> {
|
|||
|
||||
@Override
|
||||
public int compareTo(DataCenter dataCenter) {
|
||||
return id.compareTo(dataCenter.getId());
|
||||
return id.compareTo(dataCenter.getId());
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.jclouds.rimuhosting.miro.domain;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class MetaData {
|
||||
@SerializedName("key_name")
|
||||
private String key;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -58,6 +58,8 @@ public class Server implements Comparable<Server> {
|
|||
@SerializedName("vps_parameters")
|
||||
private ServerParameters serverParameters;
|
||||
|
||||
private DataCenter location;
|
||||
|
||||
//Object returned back with
|
||||
private transient NewServerData serverDataRequest;
|
||||
|
||||
|
@ -178,4 +180,12 @@ public class Server implements Comparable<Server> {
|
|||
public int compareTo(Server server) {
|
||||
return name.compareTo(server.getName());
|
||||
}
|
||||
|
||||
public void setLocation(DataCenter location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public DataCenter getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,8 @@ public class ParseRimuHostingException implements Function<Exception, Object> {
|
|||
|
||||
Type setType = new TypeToken<Map<String, RimuHostingResponse>>() {
|
||||
}.getType();
|
||||
|
||||
Map<String, RimuHostingResponse> responseMap = gson.fromJson(responseException
|
||||
.getContent(), setType);
|
||||
String test = responseException.getContent();
|
||||
Map<String, RimuHostingResponse> responseMap = gson.fromJson(test, setType);
|
||||
throw new RuntimeException(responseMap.values().iterator().next().getErrorInfo()
|
||||
.getErrorClass());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue