diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Bandwidth.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Bandwidth.java
index 4fd98fead9..31d9d1aa5e 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Bandwidth.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Bandwidth.java
@@ -18,6 +18,8 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
+
/**
* Detailed information on Server bandwidth
*
@@ -89,9 +91,29 @@ public class Bandwidth {
return max;
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(today, last30Days, max);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Bandwidth) {
+ Bandwidth other = (Bandwidth) object;
+ return Objects.equal(today, other.today)
+ && Objects.equal(last30Days, other.last30Days)
+ && Objects.equal(max, other.max);
+ } else {
+ return false;
+ }
+ }
+
@Override
public String toString() {
- return String.format("Bandwidth[today=%d, last30Days=%d, max=%d]", today, last30Days, max);
+ return String.format("[today=%d, last30Days=%d, max=%d]", today, last30Days, max);
}
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cost.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cost.java
index df7f7bb895..08da121d17 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cost.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cost.java
@@ -18,6 +18,7 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -94,6 +95,26 @@ public class Cost {
return timePeriod;
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Cost) {
+ Cost other = (Cost) object;
+ return Objects.equal(amount, other.amount)
+ && Objects.equal(currency, other.currency)
+ && Objects.equal(timePeriod, other.timePeriod);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(amount, currency, timePeriod);
+ }
+
@Override
public String toString() {
return String.format(
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cpu.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cpu.java
index 3b5b5e7135..143df7ca1d 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cpu.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Cpu.java
@@ -18,6 +18,9 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
/**
* Detailed information on Server cpu usage
*
@@ -33,7 +36,7 @@ public class Cpu {
public static class Builder {
private double system;
private double user;
- private double nice;
+ private Double nice;
private double idle;
private String unit;
@@ -47,7 +50,7 @@ public class Cpu {
return this;
}
- public Builder nice(double nice) {
+ public Builder nice(Double nice) {
this.nice = nice;
return this;
}
@@ -73,11 +76,11 @@ public class Cpu {
private final double system;
private final double user;
- private final double nice;
+ private final Double nice;
private final double idle;
private final String unit;
- public Cpu(double system, double user, double nice, double idle, String unit) {
+ public Cpu(double system, double user, @Nullable Double nice, double idle, String unit) {
this.system = system;
this.user = user;
this.nice = nice;
@@ -95,7 +98,7 @@ public class Cpu {
/**
* @return the user time in use in #unit
*/
- public Double getUser() {
+ public double getUser() {
return user;
}
@@ -109,7 +112,7 @@ public class Cpu {
/**
* @return the idle time in #unit
*/
- public Double getIdle() {
+ public double getIdle() {
return idle;
}
@@ -120,9 +123,31 @@ public class Cpu {
return unit;
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Cpu) {
+ Cpu other = (Cpu) object;
+ return Objects.equal(system, other.system)
+ && Objects.equal(user, other.user)
+ && Objects.equal(nice, other.nice)
+ && Objects.equal(idle, other.idle)
+ && Objects.equal(unit, other.unit);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(system, user, nice, idle, unit);
+ }
+
@Override
public String toString() {
- return String.format("Cpu[system=%f, user=%f, nice=%f, idle=%f, unit=%s]",
+ return String.format("[system=%f, user=%f, nice=%f, idle=%f, unit=%s]",
system, user, nice, idle, unit);
}
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Disk.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Disk.java
index ac27c71f6a..7748276876 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Disk.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Disk.java
@@ -18,6 +18,8 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
+
/**
* Detailed information on Server disk usage
*
@@ -89,9 +91,29 @@ public class Disk {
return unit;
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Disk) {
+ Disk other = (Disk) object;
+ return Objects.equal(used, other.used)
+ && Objects.equal(size, other.size)
+ && Objects.equal(unit, other.unit);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(used, size, unit);
+ }
+
@Override
public String toString() {
- return String.format("Disk[used=%d, size=%d, unit=%s]", used, size, unit);
+ return String.format("[used=%d, size=%d, unit=%s]", used, size, unit);
}
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Memory.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Memory.java
index b95b0361e7..a5e48c19a6 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Memory.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Memory.java
@@ -18,6 +18,7 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName;
/**
@@ -93,8 +94,28 @@ public class Memory {
return unit;
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Memory) {
+ Memory other = (Memory) object;
+ return Objects.equal(usage, other.usage)
+ && Objects.equal(size, other.size)
+ && Objects.equal(unit, other.unit);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(usage, size, unit);
+ }
+
@Override
public String toString() {
- return String.format("Memory[usage=%d, size=%d, unit=%s]", usage, size, unit);
+ return String.format("[usage=%d, size=%d, unit=%s]", usage, size, unit);
}
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Server.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Server.java
index 554ceee2e6..055fee5906 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Server.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Server.java
@@ -18,13 +18,14 @@
*/
package org.jclouds.glesys.domain;
-import static com.google.common.base.Preconditions.checkNotNull;
-
+import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Listing of a server.
- *
+ *
* @author Adrian Cole
* @see
*/
@@ -110,46 +111,24 @@ public class Server {
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((datacenter == null) ? 0 : datacenter.hashCode());
- result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((platform == null) ? 0 : platform.hashCode());
- return result;
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Server) {
+ final Server other = (Server) object;
+ return Objects.equal(datacenter, other.datacenter)
+ && Objects.equal(hostname, other.hostname)
+ && Objects.equal(id, other.id)
+ && Objects.equal(platform, other.platform);
+ } else {
+ return false;
+ }
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Server other = (Server) obj;
- if (datacenter == null) {
- if (other.datacenter != null)
- return false;
- } else if (!datacenter.equals(other.datacenter))
- return false;
- if (hostname == null) {
- if (other.hostname != null)
- return false;
- } else if (!hostname.equals(other.hostname))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (platform == null) {
- if (other.platform != null)
- return false;
- } else if (!platform.equals(other.platform))
- return false;
- return true;
+ public int hashCode() {
+ return Objects.hashCode(datacenter, hostname, id, platform);
}
@Override
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerAllowedArguments.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerAllowedArguments.java
new file mode 100644
index 0000000000..ffe53dc50e
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerAllowedArguments.java
@@ -0,0 +1,231 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jclouds.glesys.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Lists the allowed arguments for some of the functions in this module such as disksize, cpucores etc.
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class ServerAllowedArguments {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private List diskSizes;
+ private List memorySizes;
+ private List cpuCores;
+ private List templates;
+ private List transfers;
+ private List dataCenters;
+
+ public Builder diskSizes(Integer... sizes) {
+ return diskSizes(Arrays.asList(sizes));
+ }
+
+ public Builder diskSizes(List sizes) {
+ this.diskSizes = sizes;
+ return this;
+ }
+
+ public Builder memorySizes(Integer... sizes) {
+ return memorySizes(Arrays.asList(sizes));
+ }
+
+ public Builder memorySizes(List sizes) {
+ this.memorySizes = sizes;
+ return this;
+ }
+
+ public Builder cpuCores(Integer... cpuCores) {
+ this.cpuCores = Arrays.asList(cpuCores);
+ return this;
+ }
+
+ public Builder cpuCores(List cpuCores) {
+ this.cpuCores = cpuCores;
+ return this;
+ }
+
+ public Builder templates(String... templates) {
+ return templates(Arrays.asList(templates));
+ }
+
+ public Builder templates(List templates) {
+ this.templates = templates;
+ return this;
+ }
+
+ public Builder transfers(Integer... transfers) {
+ return transfers(Arrays.asList(transfers));
+ }
+
+ public Builder transfers(List transfers) {
+ this.transfers = transfers;
+ return this;
+ }
+
+ public Builder dataCenters(String... dataCenters) {
+ return dataCenters(Arrays.asList(dataCenters));
+ }
+
+ public Builder dataCenters(List dataCenters) {
+ this.dataCenters = dataCenters;
+ return this;
+ }
+
+ public ServerAllowedArguments build() {
+ return new ServerAllowedArguments(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
+ }
+
+ public Builder fromAllowedArguments(ServerAllowedArguments in) {
+ return diskSizes(in.getDiskSizes())
+ .memorySizes(in.getMemorySizes())
+ .cpuCores(in.getCpuCores())
+ .templates(in.getTemplates())
+ .transfers(in.getTransfers())
+ .dataCenters(in.getDataCenters());
+ }
+ }
+
+ @SerializedName("disksize")
+ private final List diskSizes;
+ @SerializedName("memorysize")
+ private final List memorySizes;
+ @SerializedName("cpucores")
+ private final List cpuCores;
+ @SerializedName("template")
+ private final List templates;
+ @SerializedName("transfer")
+ private final List transfers;
+ @SerializedName("datacenter")
+ private final List dataCenters;
+
+ public ServerAllowedArguments(List diskSizes, List memorySizes, List cpuCores,
+ List templates, List transfers, List dataCenters) {
+ checkNotNull(diskSizes, "diskSizes");
+ checkNotNull(memorySizes, "memorySizes");
+ checkNotNull(cpuCores, "cpuCores");
+ checkNotNull(templates, "templates");
+ checkNotNull(transfers, "transfers");
+ checkNotNull(dataCenters, "dataCenters");
+
+ this.diskSizes = diskSizes;
+ this.memorySizes = memorySizes;
+ this.cpuCores = cpuCores;
+ this.templates = templates;
+ this.transfers = transfers;
+ this.dataCenters = dataCenters;
+ }
+
+ /**
+ * @return a list of disk sizes, in GB, that can be used for creating servers on this platform
+ * @see org.jclouds.glesys.domain.ServerTemplate#getMinDiskSize()
+ */
+ public List getDiskSizes() {
+ return diskSizes;
+ }
+
+ /**
+ * @return a list of memory sizes, in MB, that can be used for creating servers on this platform
+ * @see org.jclouds.glesys.domain.ServerTemplate#getMinMemSize()
+ */
+ public List getMemorySizes() {
+ return memorySizes;
+ }
+
+ /**
+ * @return a list of which core counts can be used for creating servers on this platform
+ */
+ public List getCpuCores() {
+ return cpuCores;
+ }
+
+ /**
+ * @return a list of template names available for creating servers on this platform
+ * @see org.jclouds.glesys.domain.ServerTemplate#getName()
+ */
+ public List getTemplates() {
+ return templates;
+ }
+
+ /**
+ * @return the list of transfer settings available for creating servers on this platform
+ */
+ public List getTransfers() {
+ return transfers;
+ }
+
+ /**
+ * @return the list of datacenters available that support creating servers on this platform
+ */
+ public List getDataCenters() {
+ return dataCenters;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerAllowedArguments) {
+ final ServerAllowedArguments other = (ServerAllowedArguments) object;
+ return Objects.equal(diskSizes, other.diskSizes)
+ && Objects.equal(memorySizes, other.memorySizes)
+ && Objects.equal(cpuCores, other.cpuCores)
+ && Objects.equal(templates, other.templates)
+ && Objects.equal(transfers, other.transfers)
+ && Objects.equal(dataCenters, other.dataCenters);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
+ }
+
+ @Override
+ public String toString() {
+ checkNotNull(diskSizes, "diskSizes");
+ checkNotNull(memorySizes, "memorySizes");
+ checkNotNull(cpuCores, "cpuCores");
+ checkNotNull(templates, "templates");
+ checkNotNull(transfers, "transfers");
+ checkNotNull(dataCenters, "dataCenters");
+
+ Joiner commaJoiner = Joiner.on(", ");
+ return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]",
+ commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates),
+ commaJoiner.join(transfers), commaJoiner.join(dataCenters));
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerConsole.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerConsole.java
new file mode 100644
index 0000000000..2337de5054
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerConsole.java
@@ -0,0 +1,102 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+
+/**
+ * Connection information to connect to a server with VNC.
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class ServerConsole {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String host;
+ private int port;
+ private String password;
+
+ public Builder host(String host) {
+ this.host = host;
+ return this;
+ }
+
+ public Builder port(int port) {
+ this.port = port;
+ return this;
+ }
+
+ public Builder password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ public ServerConsole build() {
+ return new ServerConsole(host, port, password);
+ }
+
+ public Builder fromServerConsole(ServerConsole in) {
+ return host(in.getHost()).port(in.getPort()).password(in.getPassword());
+ }
+
+ }
+
+ private final String host;
+ private final int port;
+ private final String password;
+
+ public ServerConsole(String host, int port, String password) {
+ this.host = host;
+ this.port = port;
+ this.password = password;
+ }
+
+ /**
+ * @return the host name to use to connect to the server
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @return the port to use to connect to the server
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @return the password to use to connect to the server
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerConsole) {
+ final ServerConsole other = (ServerConsole) object;
+ return Objects.equal(host, other.host)
+ && Objects.equal(port, other.port)
+ && Objects.equal(password, other.password);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(host, port, password);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[host=%s, port=%s, password=%s]", host, port, password);
+ }
+
+}
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
new file mode 100644
index 0000000000..7c243ca49b
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java
@@ -0,0 +1,99 @@
+package org.jclouds.glesys.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+import org.jclouds.javax.annotation.Nullable;
+
+/**
+ * Connection information to connect to a server with VNC.
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class ServerCreated {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String id;
+ private String hostname;
+ private List ips;
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+ public Builder port(List ips) {
+ this.ips = ips;
+ return this;
+ }
+
+ public Builder hostname(String hostname) {
+ this.hostname = hostname;
+ return this;
+ }
+
+ public ServerCreated build() {
+ return new ServerCreated(id, hostname, ips);
+ }
+
+ public Builder fromServerCreated(ServerCreated in) {
+ return id(in.getId()).hostname(in.getHostname()).port(in.getIps());
+ }
+ }
+
+ @SerializedName("serverid")
+ private final String id;
+ private final String hostname;
+ @SerializedName("iplist")
+ private final List ips;
+
+ public ServerCreated(String id, @Nullable String hostname, List ips) {
+ checkNotNull(id, "id");
+ this.id = id;
+ this.hostname = hostname;
+ this.ips = ips;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public List getIps() {
+ return ips;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerCreated) {
+ final ServerCreated other = (ServerCreated) object;
+ return Objects.equal(id, other.id)
+ && Objects.equal(ips, other.ips);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, ips);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[id=%s, hostname=%s, ips=%s]", id, hostname, ips);
+ }
+
+}
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/ServerCreatedIp.java
new file mode 100644
index 0000000000..f8c210185b
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java
@@ -0,0 +1,121 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+
+/**
+ * Represents detailed information about an available ip address of a new server.
+ *
+ * @author Adam Lowe
+ * @see ServerCreated
+ */
+public class ServerCreatedIp {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ protected String ip;
+ protected int version;
+ protected double cost;
+
+ public Builder version(int version) {
+ this.version = version;
+ return this;
+ }
+
+ public Builder ip(String ip) {
+ this.ip = ip;
+ return this;
+ }
+
+ public Builder cost(double cost) {
+ this.cost = cost;
+ return this;
+ }
+
+ public ServerCreatedIp build() {
+ return new ServerCreatedIp(ip, version, cost);
+ }
+
+ public Builder fromIpCreated(ServerCreatedIp from) {
+ return ip(from.getIp()).version(from.getVersion()).cost(from.getCost());
+ }
+ }
+
+ protected final String ip;
+ protected final int version;
+ protected final double cost;
+
+ public ServerCreatedIp(String ip, int version, double cost) {
+ this.ip = ip;
+ this.version = version;
+ this.cost = cost;
+ }
+
+ /**
+ * @return the IP version, ex. 4
+ */
+ public int getVersion() {
+ return version;
+ }
+
+ /**
+ * @return the ip address of the new server
+ */
+ public String getIp() {
+ return ip;
+ }
+
+ /**
+ * @return the cost of the ip address allocated to the new server
+ */
+ public double getCost() {
+ return cost;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerCreatedIp) {
+ final ServerCreatedIp other = (ServerCreatedIp) object;
+ return Objects.equal(ip, other.ip)
+ && Objects.equal(version, other.version)
+ && Objects.equal(cost, other.cost);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ip, version, cost);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[ip=%s, version=%d, cost=%f]",
+ ip, version, cost);
+ }
+}
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 022f44ebd5..258c1c93ba 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,12 +20,13 @@ package org.jclouds.glesys.domain;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName;
/**
* Detailed information about a server such as cpuCores, hardware configuration
* (cpu, memory and disk), ip adresses, cost, transfer, os and more.
- *
+ *
* @author Adrian Cole
* @see
*/
@@ -65,7 +66,7 @@ public class ServerDetails extends Server {
this.cost = cost;
return this;
}
-
+
public ServerDetails build() {
return new ServerDetails(id, hostname, datacenter, platform, description, cpuCores, memory, disk, cost);
}
@@ -100,16 +101,16 @@ public class ServerDetails extends Server {
return Builder.class.cast(super.fromServer(in));
}
}
-
+
private final String description;
@SerializedName("cpucores")
private final int cpuCores;
private final int memory;
private final int disk;
private final Cost cost;
-
+
public ServerDetails(String id, String hostname, String datacenter, String platform, String description,
- int cpuCores, int memory, int disk, Cost cost) {
+ int cpuCores, int memory, int disk, Cost cost) {
super(id, hostname, datacenter, platform);
this.description = checkNotNull(description, "description");
this.cpuCores = cpuCores;
@@ -147,10 +148,10 @@ public class ServerDetails extends Server {
}
/**
- * @return details of the cost of the server
- */
+ * @return details of the cost of the server
+ */
public Cost getCost() {
- return cost;
+ return cost;
}
@Override
@@ -160,4 +161,27 @@ public class ServerDetails extends Server {
hostname, datacenter, platform, description, cpuCores, memory, disk, cost);
}
+ @Override
+ public int hashCode() {
+ return super.hashCode() + Objects.hashCode(description, cpuCores, disk, memory, cost);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerDetails) {
+ final ServerDetails other = (ServerDetails) object;
+ return super.equals(other)
+ && Objects.equal(description, other.description)
+ && Objects.equal(cpuCores, other.cpuCores)
+ && Objects.equal(disk, other.disk)
+ && Objects.equal(memory, other.memory)
+ && Objects.equal(cost, other.cost);
+ } else {
+ return false;
+ }
+ }
+
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerLimit.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerLimit.java
new file mode 100644
index 0000000000..b0faaa0e1f
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerLimit.java
@@ -0,0 +1,113 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+
+/**
+ * Detailed information about an OpenVZ server's limits
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class ServerLimit {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private int held;
+ private int maxHeld;
+ private int barrier;
+ private int limit;
+ private int failCount;
+
+ public Builder held(int held) {
+ this.held = held;
+ return this;
+ }
+
+ public Builder maxHeld(int maxHeld) {
+ this.maxHeld = maxHeld;
+ return this;
+ }
+
+ public Builder barrier(int barrier) {
+ this.barrier = barrier;
+ return this;
+ }
+
+ public Builder limit(int limit) {
+ this.limit = limit;
+ return this;
+ }
+
+ public Builder failCount(int failCount) {
+ this.failCount = failCount;
+ return this;
+ }
+
+ public ServerLimit build() {
+ return new ServerLimit(held, maxHeld, barrier, limit, failCount);
+ }
+ }
+
+ private final long held;
+ private final long maxHeld;
+ private final long barrier;
+ private final long limit;
+ private final long failCount;
+
+ public ServerLimit(long held, long maxHeld, long barrier, long limit, long failCount) {
+ this.held = held;
+ this.maxHeld = maxHeld;
+ this.barrier = barrier;
+ this.limit = limit;
+ this.failCount = failCount;
+ }
+
+ public long getHeld() {
+ return held;
+ }
+
+ public long getMaxHeld() {
+ return maxHeld;
+ }
+
+ public long getBarrier() {
+ return barrier;
+ }
+
+ public long getLimit() {
+ return limit;
+ }
+
+ public long getFailCount() {
+ return failCount;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerLimit) {
+ final ServerLimit other = (ServerLimit) object;
+ return Objects.equal(held, other.held)
+ && Objects.equal(maxHeld, other.maxHeld)
+ && Objects.equal(barrier, other.barrier)
+ && Objects.equal(limit, other.limit)
+ && Objects.equal(failCount, other.failCount);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(held, maxHeld, barrier, limit, failCount);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[held=%d, maxHeld=%d, barrier=%d, limit=%d, failCount=%d]", held, maxHeld, barrier, limit, failCount);
+ }
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerState.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerState.java
index b5540f5312..b30a48d000 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerState.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerState.java
@@ -23,6 +23,8 @@ import com.google.common.base.CaseFormat;
import static com.google.common.base.Preconditions.checkNotNull;
/**
+ * Valid states for a server hosted in a Glesys cloud
+ *
* @author Adam Lowe
* @see ServerStatus
*/
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerStatus.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerStatus.java
index f8159742bb..9e802c34d9 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerStatus.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerStatus.java
@@ -18,6 +18,8 @@
*/
package org.jclouds.glesys.domain;
+import com.google.common.base.Objects;
+
/**
* Detailed information server status including hardware usage (cpu, memory and disk), bandwidth and up-time.
*
@@ -136,9 +138,32 @@ public class ServerStatus {
return uptime.getTime();
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerStatus) {
+ final ServerStatus other = (ServerStatus) object;
+ return Objects.equal(state, other.state)
+ && Objects.equal(cpu, other.cpu)
+ && Objects.equal(memory, other.memory)
+ && Objects.equal(disk, other.disk)
+ && Objects.equal(bandwidth, other.bandwidth)
+ && uptime == other.uptime;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(state, cpu, memory, disk, bandwidth, uptime);
+ }
+
@Override
public String toString() {
- return String.format("Status[state=%s, cpu=%s, memory=%s, disk=%s, bandwidth=%s, uptime=%s]",
+ return String.format("[state=%s, cpu=%s, memory=%s, disk=%s, bandwidth=%s, uptime=%s]",
state, cpu, memory, disk, bandwidth, uptime);
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerTemplate.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerTemplate.java
new file mode 100644
index 0000000000..7d5ccf3dfc
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerTemplate.java
@@ -0,0 +1,137 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Operating system template
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class ServerTemplate {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String name;
+ private int minDiskSize;
+ private int minMemSize;
+ private String os;
+ private String platform;
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder minDiskSize(int minDiskSize) {
+ this.minDiskSize = minDiskSize;
+ return this;
+ }
+
+ public Builder minMemSize(int minMemSize) {
+ this.minMemSize = minMemSize;
+ return this;
+ }
+
+ public Builder os(String os) {
+ this.os = os;
+ return this;
+ }
+
+ public Builder platform(String platform) {
+ this.platform = platform;
+ return this;
+ }
+
+ public ServerTemplate build() {
+ return new ServerTemplate(name, minDiskSize, minMemSize, os, platform);
+ }
+
+ public Builder fromTemplate(ServerTemplate in) {
+ return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
+ }
+
+ }
+
+ private final String name;
+ @SerializedName("min_disk_size")
+ private final int minDiskSize;
+ @SerializedName("min_mem_size")
+ private final int minMemSize;
+ private final String os;
+ private final String platform;
+
+ public ServerTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
+ this.name = name;
+ this.minDiskSize = minDiskSize;
+ this.minMemSize = minMemSize;
+ this.os = os;
+ this.platform = platform;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the minimum allowed disk size in GB
+ * @see org.jclouds.glesys.domain.ServerAllowedArguments#getDiskSizes()
+ */
+ public int getMinDiskSize() {
+ return minDiskSize;
+ }
+
+ /**
+ * @return the minimum allowed memory size in MB
+ * @see org.jclouds.glesys.domain.ServerAllowedArguments#getMemorySizes()
+ */
+ public int getMinMemSize() {
+ return minMemSize;
+ }
+
+ /**
+ * @return the name of the operating system type ex. "linux"
+ */
+ public String getOs() {
+ return os;
+ }
+
+ /**
+ * @return the name of the platform this template is available in, ex. "Xen"
+ */
+ public String getPlatform() {
+ return platform;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof ServerTemplate) {
+ final ServerTemplate other = (ServerTemplate) object;
+ return Objects.equal(name, other.name)
+ && Objects.equal(minDiskSize, other.minDiskSize)
+ && Objects.equal(minMemSize, other.minMemSize)
+ && Objects.equal(os, other.os)
+ && Objects.equal(platform, other.platform);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, minDiskSize, minMemSize, os, platform);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[name=%s, min_disk_size=%d, min_mem_size=%d, os=%s, platform=%s]",
+ name, minDiskSize, minMemSize, os, platform);
+ }
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java
index d2ce545597..24ab2a9792 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java
@@ -19,6 +19,7 @@
package org.jclouds.glesys.domain;
import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
@@ -27,13 +28,16 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
/**
+ * Represents an 'uptime' duration of server in a Glesys cloud
+ *
* @author Adam Lowe
+ * @see ServerStatus
*/
public class ServerUptime {
private final long time;
private final String timeString;
- public ServerUptime(long time) {
+ private ServerUptime(long time) {
this.time = time;
long days = TimeUnit.SECONDS.toDays(time);
long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days));
@@ -64,14 +68,14 @@ public class ServerUptime {
}
/**
- * @param uptimeString a Glesys uptime string
+ * @param uptimeString a Glesys uptime string, ex. "0 0 0 0 0 10 1 1"
*/
public static ServerUptime fromValue(String uptimeString) {
return new ServerUptime(uptimeString);
}
/**
- * @param time number of seconds
+ * @param time number of seconds the server has been up
*/
public static ServerUptime fromValue(long time) {
return new ServerUptime(time);
@@ -81,8 +85,23 @@ public class ServerUptime {
return time;
}
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ return object instanceof ServerUptime
+ && Objects.equal(time, ((ServerUptime) object).getTime());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(time);
+ }
+
@Override
public String toString() {
return timeString;
}
+
}
\ No newline at end of file
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncClient.java
index cca69a4262..30400e60f7 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncClient.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncClient.java
@@ -18,17 +18,8 @@
*/
package org.jclouds.glesys.features;
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.glesys.domain.Server;
-import org.jclouds.glesys.domain.ServerDetails;
-import org.jclouds.glesys.domain.ServerStatus;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.jclouds.glesys.domain.*;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters;
@@ -36,15 +27,18 @@ import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
-import com.google.common.util.concurrent.ListenableFuture;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.*;
/**
* Provides asynchronous access to Server via their REST API.
*
- *
+ *
+ * @author Adrian Cole
+ * @author Adam Lowe
* @see ServerClient
* @see
- * @author Adrian Cole
*/
@RequestFilters(BasicAuthentication.class)
public interface ServerAsyncClient {
@@ -69,9 +63,8 @@ public interface ServerAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture getServerDetails(@PathParam("id") String id);
-
/**
- * @see ServerClient#getServerDetails
+ * @see ServerClient#getServerStatus
*/
@GET
@Path("/server/status/serverid/{id}/format/json")
@@ -80,4 +73,121 @@ public interface ServerAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture getServerStatus(@PathParam("id") String id);
+ /**
+ * @see ServerClient#getServerLimits
+ */
+ @GET
+ @Path("/server/limits/serverid/{id}/format/json")
+ @SelectJson("limits")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ ListenableFuture> getServerLimits(@PathParam("id") String id);
+
+
+ /**
+ * @see ServerClient#getServerConsole
+ */
+ @GET
+ @Path("/server/console/serverid/{id}/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ ListenableFuture getServerConsole(@PathParam("id") String id);
+
+
+ /**
+ * @see ServerClient#getAllowedArguments
+ */
+ @GET
+ @Path("/server/allowedarguments/format/json")
+ @SelectJson("argumentslist")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ListenableFuture