diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Ip.java similarity index 86% rename from sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java rename to sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Ip.java index 464355f5bb..fef18f4c5a 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Ip.java @@ -22,12 +22,13 @@ package org.jclouds.glesys.domain; import com.google.common.base.Objects; /** - * Represents detailed information about an available ip address of a new server. + * Represents an ip address used by a server. * * @author Adam Lowe * @see ServerCreated + * @see ServerDetails */ -public class ServerCreatedIp { +public class Ip { public static Builder builder() { return new Builder(); @@ -61,11 +62,11 @@ public class ServerCreatedIp { return this; } - public ServerCreatedIp build() { - return new ServerCreatedIp(ip, version, cost); + public Ip build() { + return new Ip(ip, version, cost); } - public Builder fromIpCreated(ServerCreatedIp from) { + public Builder fromIpCreated(Ip from) { return ip(from.getIp()).version(from.getVersion()).cost(from.getCost()); } } @@ -74,7 +75,7 @@ public class ServerCreatedIp { protected final int version; protected final double cost; - public ServerCreatedIp(String ip, int version, double cost) { + public Ip(String ip, int version, double cost) { this.ip = ip; this.version = version; this.cost = cost; @@ -106,8 +107,8 @@ public class ServerCreatedIp { if (this == object) { return true; } - if (object instanceof ServerCreatedIp) { - final ServerCreatedIp other = (ServerCreatedIp) object; + if (object instanceof Ip) { + final Ip other = (Ip) object; return Objects.equal(ip, other.ip) && Objects.equal(version, other.version) && Objects.equal(cost, other.cost); diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java index 7f02659c96..bf0b17b1d9 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java @@ -43,19 +43,19 @@ public class ServerCreated { public static class Builder { private String id; private String hostname; - private List ips; + private List ips; public Builder id(String id) { this.id = id; return this; } - public Builder ips(List ips) { + public Builder ips(List ips) { this.ips = ips; return this; } - public Builder ips(ServerCreatedIp... ips) { + public Builder ips(Ip... ips) { return ips(Arrays.asList(ips)); } @@ -77,9 +77,9 @@ public class ServerCreated { private final String id; private final String hostname; @SerializedName("iplist") - private final List ips; + private final List ips; - public ServerCreated(String id, @Nullable String hostname, List ips) { + public ServerCreated(String id, @Nullable String hostname, List ips) { checkNotNull(id, "id"); this.id = id; this.hostname = hostname; @@ -100,8 +100,8 @@ public class ServerCreated { } /** @return the IP addresses assigned to the server */ - public List getIps() { - return ips == null ? ImmutableList.of() : ips; + public List getIps() { + return ips == null ? ImmutableList.of() : ips; } @Override diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerDetails.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerDetails.java index 4622233ac1..b597a11b4e 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerDetails.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerDetails.java @@ -20,8 +20,12 @@ package org.jclouds.glesys.domain; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.collect.ImmutableList; import com.google.gson.annotations.SerializedName; +import java.util.Arrays; +import java.util.List; + /** * Detailed information about a server such as cpuCores, hardware configuration * (cpu, memory and disk), ip adresses, cost, transfer, os and more. @@ -36,16 +40,24 @@ public class ServerDetails extends Server { public static class Builder extends Server.Builder { private String description; + private String template; private int cpuCores; private int memory; private int disk; + private int transfer; private Cost cost; + private List ips; public Builder description(String description) { this.description = description; return this; } + public Builder template(String template) { + this.template = template; + return this; + } + public Builder cpuCores(int cpuCores) { this.cpuCores = cpuCores; return this; @@ -61,18 +73,32 @@ public class ServerDetails extends Server { return this; } + public Builder transfer(int transfer) { + this.transfer = transfer; + return this; + } + public Builder cost(Cost cost) { this.cost = cost; return this; } + public Builder ips(Ip... ips) { + return ips(Arrays.asList(ips)); + } + + public Builder ips(List ips) { + this.ips = ips; + return this; + } + public ServerDetails build() { - return new ServerDetails(id, hostname, datacenter, platform, description, cpuCores, memory, disk, cost); + return new ServerDetails(id, hostname, datacenter, platform, template, description, cpuCores, memory, disk, transfer, cost, ips); } public Builder fromServerDetails(ServerDetails in) { - return fromServer(in).memory(in.getMemory()).disk(in.getDisk()).cpuCores(in.getCpuCores()).cost(in.getCost()) - .description(in.getDescription()); + return fromServer(in).template(in.getTemplate()).memory(in.getMemory()).disk(in.getDisk()).cpuCores(in.getCpuCores()).cost(in.getCost()) + .description(in.getDescription()).ips(in.getIps()); } @Override @@ -102,20 +128,27 @@ public class ServerDetails extends Server { } private final String description; + private final String template; @SerializedName("cpucores") private final int cpuCores; private final int memory; private final int disk; + private final int transfer; private final Cost cost; + @SerializedName("iplist") + private final List ips; - public ServerDetails(String id, String hostname, String datacenter, String platform, String description, - int cpuCores, int memory, int disk, Cost cost) { + public ServerDetails(String id, String hostname, String datacenter, String platform, String template, + String description, int cpuCores, int memory, int disk, int transfer, Cost cost, List ips) { super(id, hostname, datacenter, platform); + this.template = checkNotNull(template, "template"); this.description = description; this.cpuCores = cpuCores; this.memory = memory; this.disk = disk; + this.transfer = transfer; this.cost = checkNotNull(cost, "cost"); + this.ips = ips == null ? ImmutableList.of() : ips; } /** @@ -146,6 +179,13 @@ public class ServerDetails extends Server { return memory; } + /** + * @return the transfer of the server + */ + public int getTransfer() { + return transfer; + } + /** * @return details of the cost of the server */ @@ -153,11 +193,25 @@ public class ServerDetails extends Server { return cost; } + /** + * @return the ip addresses assigned to the server + */ + public List getIps() { + return ips; + } + + /** + * @return the name of the template used to create the server + */ + public String getTemplate() { + return template; + } + @Override public String toString() { return String.format( - "[id=%s, hostname=%s, datacenter=%s, platform=%s, description=%s, cpuCores=%s, memory=%s, disk=%s, cost=%s]", id, - hostname, datacenter, platform, description, cpuCores, memory, disk, cost); + "[id=%s, hostname=%s, datacenter=%s, platform=%s, template=%s, description=%s, cpuCores=%d, memory=%d, disk=%d, transfer=%d, cost=%s, ips=%s]", id, + hostname, datacenter, platform, template, description, cpuCores, memory, disk, transfer, cost, ips); } } diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java index b51208b08b..9240d6420a 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java @@ -49,8 +49,6 @@ public class DomainClientExpectTest extends BaseRestClientExpectTestbuilder() @@ -59,7 +57,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest expected = ImmutableSet.of( + Set expected = ImmutableSet.of( Domain.builder().domain("adamlowe.net").createTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-12-20 10:58:51")).build()); assertEquals(client.listDomains(), expected); diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java index 4826b52684..1b4b78c640 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java @@ -23,8 +23,8 @@ import com.google.common.collect.ImmutableSet; import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.domain.Server; import org.jclouds.glesys.domain.ServerCreated; -import org.jclouds.glesys.domain.ServerCreatedIp; import org.jclouds.glesys.domain.ServerDetails; +import org.jclouds.glesys.domain.Ip; import org.jclouds.glesys.options.*; import org.jclouds.glesys.parse.*; import org.jclouds.http.HttpRequest; @@ -128,7 +128,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest 0 : server; assert server.getMemory() > 0 : server; assert server.getCost() != null; + assert server.getTransfer() > 0 : server; + + assertNotNull(server.getTemplate()); + assertNotNull(server.getIps()); } private void checkStatus(ServerStatus status) { diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java index f08739f1d2..29982992f0 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java @@ -23,7 +23,7 @@ import com.google.inject.Guice; import com.google.inject.Injector; import org.jclouds.glesys.config.GleSYSParserModule; import org.jclouds.glesys.domain.ServerCreated; -import org.jclouds.glesys.domain.ServerCreatedIp; +import org.jclouds.glesys.domain.Ip; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.rest.annotations.SelectJson; @@ -47,7 +47,7 @@ public class ParseServerCreatedTest extends BaseItemParserTest { @SelectJson("server") @Consumes(MediaType.APPLICATION_JSON) public ServerCreated expected() { - return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(ServerCreatedIp.builder().ip("109.74.10.27").version4().cost(2.00).build()).build(); + return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(Ip.builder().ip("109.74.10.27").version4().cost(2.00).build()).build(); } diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsTest.java index c0c89eb14a..408a954070 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsTest.java @@ -23,9 +23,8 @@ import com.google.inject.Guice; import com.google.inject.Injector; import org.jclouds.glesys.config.GleSYSParserModule; import org.jclouds.glesys.domain.Cost; -import org.jclouds.glesys.domain.ServerCreated; -import org.jclouds.glesys.domain.ServerCreatedIp; import org.jclouds.glesys.domain.ServerDetails; +import org.jclouds.glesys.domain.Ip; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.rest.annotations.SelectJson; @@ -49,10 +48,11 @@ public class ParseServerDetailsTest extends BaseItemParserTest { @SelectJson("server") @Consumes(MediaType.APPLICATION_JSON) public ServerDetails expected() { + Ip ip = Ip.builder().version4().ip("31.192.226.45").cost(2.0).build(); Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build(); - return ServerDetails.builder().id("vz1908384").hostname("jclouds-unit").cpuCores(1). - memory(128).disk(5). - description("unit test server").datacenter("Falkenberg").platform("OpenVZ").cost(cost).build(); + return ServerDetails.builder().id("vz1375882").transfer(50).hostname("jclouds-unit").cpuCores(1).memory(128).disk(5) + .description("unit test server").datacenter("Falkenberg").platform("OpenVZ").template("Debian 6.0 64-bit") + .cost(cost).ips(ip).build(); } protected Injector injector() { diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsWithoutIPsTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsWithoutIPsTest.java index e3afd05aea..1f4c0f69ab 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsWithoutIPsTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerDetailsWithoutIPsTest.java @@ -52,7 +52,7 @@ public class ParseServerDetailsWithoutIPsTest extends BaseItemParserTest