mirror of
https://github.com/apache/jclouds.git
synced 2025-02-16 15:08:28 +00:00
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
import org.jclouds.rimuhosting.miro.data.CreateOptions;
|
||||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.MetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
@ -37,6 +39,7 @@ public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
|
|||||||
//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");
|
||||||
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
||||||
|
newServerData.setMetaData(new ArrayList<MetaData>());
|
||||||
bindToRequest(request, newServerData);
|
bindToRequest(request, newServerData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata apply(Server from) {
|
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]+", "");
|
String tag = from.getName().replaceAll("-[0-9]+", "");
|
||||||
Credentials creds = null;
|
Credentials creds = null;
|
||||||
NodeState state = runningStateToNodeState.get(from.getState());
|
NodeState state = runningStateToNodeState.get(from.getState());
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.data;
|
package org.jclouds.rimuhosting.miro.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
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.ServerParameters;
|
||||||
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
||||||
|
|
||||||
@ -115,6 +119,9 @@ public class NewServerData implements PostData{
|
|||||||
@SerializedName("vps_paramters")
|
@SerializedName("vps_paramters")
|
||||||
private ServerParameters serverParameters;
|
private ServerParameters serverParameters;
|
||||||
|
|
||||||
|
@SerializedName("meta_data")
|
||||||
|
private List<MetaData> metaData;
|
||||||
|
|
||||||
public Long getBillingId() {
|
public Long getBillingId() {
|
||||||
return billingId;
|
return billingId;
|
||||||
}
|
}
|
||||||
@ -198,4 +205,12 @@ public class NewServerData implements PostData{
|
|||||||
this.serverParameters.validate();
|
this.serverParameters.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMetaData(List<MetaData> metaData) {
|
||||||
|
this.metaData = metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MetaData> getMetaData() {
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ public class DataCenter implements Comparable<DataCenter> {
|
|||||||
private String id;
|
private String id;
|
||||||
@SerializedName("data_center_location_name")
|
@SerializedName("data_center_location_name")
|
||||||
private String name;
|
private String name;
|
||||||
|
@SerializedName("data_center_location_country_2ltr")
|
||||||
|
private String code;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -49,6 +51,14 @@ public class DataCenter implements Comparable<DataCenter> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(DataCenter dataCenter) {
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -57,11 +57,13 @@ public class Server implements Comparable<Server> {
|
|||||||
private String slug;
|
private String slug;
|
||||||
@SerializedName("vps_parameters")
|
@SerializedName("vps_parameters")
|
||||||
private ServerParameters serverParameters;
|
private ServerParameters serverParameters;
|
||||||
|
|
||||||
|
private DataCenter location;
|
||||||
|
|
||||||
//Object returned back with
|
//Object returned back with
|
||||||
private transient NewServerData serverDataRequest;
|
private transient NewServerData serverDataRequest;
|
||||||
|
|
||||||
|
|
||||||
public IpAddresses getIpAddresses() {
|
public IpAddresses getIpAddresses() {
|
||||||
return ipAddresses;
|
return ipAddresses;
|
||||||
}
|
}
|
||||||
@ -178,4 +180,12 @@ public class Server implements Comparable<Server> {
|
|||||||
public int compareTo(Server server) {
|
public int compareTo(Server server) {
|
||||||
return name.compareTo(server.getName());
|
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>>() {
|
Type setType = new TypeToken<Map<String, RimuHostingResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
|
String test = responseException.getContent();
|
||||||
Map<String, RimuHostingResponse> responseMap = gson.fromJson(responseException
|
Map<String, RimuHostingResponse> responseMap = gson.fromJson(test, setType);
|
||||||
.getContent(), setType);
|
|
||||||
throw new RuntimeException(responseMap.values().iterator().next().getErrorInfo()
|
throw new RuntimeException(responseMap.values().iterator().next().getErrorInfo()
|
||||||
.getErrorClass());
|
.getErrorClass());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user