mirror of https://github.com/apache/jclouds.git
GleSYS provider: updating domain objects to match changes to the GleSYS api; removing redundant Parse*Tests
This commit is contained in:
parent
c04da585af
commit
a08045982a
|
@ -20,15 +20,20 @@ package org.jclouds.glesys;
|
|||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC;
|
||||
|
||||
/**
|
||||
* Builds properties used in GleSYS Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class GleSYSPropertiesBuilder extends PropertiesBuilder {
|
||||
@Override
|
||||
|
@ -36,6 +41,12 @@ public class GleSYSPropertiesBuilder extends PropertiesBuilder {
|
|||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://api.glesys.com");
|
||||
properties.setProperty(PROPERTY_API_VERSION, "1");
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA,US-VA,BR-SP");
|
||||
properties.setProperty(PROPERTY_ZONE + ".Amsterdam.." + ISO3166_CODES, "NL-NH");
|
||||
properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N");
|
||||
properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY");
|
||||
properties.setProperty(PROPERTY_ZONE + ".Stockholm." + ISO3166_CODES, "SE-AB");
|
||||
properties.setProperty(PROPERTY_GLESYS_DEFAULT_DC, "Falkenberg");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class GleSYSProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> getIso3166Codes() {
|
||||
return ImmutableSet.of();
|
||||
return ImmutableSet.of("NL-NH","SE-N","US-NY","SE-AB");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ public class GleSYSParserModule extends AbstractModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
public Map<Type, Object> provideCustomAdapterBindings() {
|
||||
return ImmutableMap.<Type, Object> of(ServerState.class, new GleSYSTypeAdapters.ServerStateAdapter(),
|
||||
ServerUptime.class, new GleSYSTypeAdapters.ServerUptimeAdapter());
|
||||
return ImmutableMap.<Type, Object> of(ServerState.class, new GleSYSTypeAdapters.ServerStateAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Detailed information on Server bandwidth
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see ServerStatus
|
||||
*/
|
||||
public class Bandwidth {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private long today;
|
||||
private long last30Days;
|
||||
private long max;
|
||||
|
||||
public Builder today(long today) {
|
||||
this.today = today;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder last30Days(long last30Days) {
|
||||
this.last30Days = last30Days;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder max(long max) {
|
||||
this.max = max;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bandwidth build() {
|
||||
return new Bandwidth(today, last30Days, max);
|
||||
}
|
||||
|
||||
public Builder fromBandwidth(Bandwidth in) {
|
||||
return today(in.getToday()).last30Days(in.getLast30Days()).max(in.getMax());
|
||||
}
|
||||
}
|
||||
|
||||
private final long today;
|
||||
private final long last30Days;
|
||||
private final long max;
|
||||
|
||||
public Bandwidth(long today, long last30Days, long max) {
|
||||
this.today = today;
|
||||
this.last30Days = last30Days;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bandwidth used today in MB
|
||||
*/
|
||||
public long getToday() {
|
||||
return today;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bandwidth used in the past 30 days in GB
|
||||
*/
|
||||
public long getLast30Days() {
|
||||
return last30Days;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max bandwidth allowed over a 30 day period in GB
|
||||
*/
|
||||
public long getMax() {
|
||||
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("[today=%d, last30Days=%d, max=%d]", today, last30Days, max);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Detailed information on Server cpu usage
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see ServerStatus
|
||||
*/
|
||||
|
||||
public class Cpu {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private double system;
|
||||
private double user;
|
||||
private Double nice;
|
||||
private double idle;
|
||||
private String unit;
|
||||
|
||||
public Builder system(double system) {
|
||||
this.system = system;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder user(double user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nice(Double nice) {
|
||||
this.nice = nice;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder idle(double idle) {
|
||||
this.idle = idle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder unit(String unit) {
|
||||
this.unit = unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Cpu build() {
|
||||
return new Cpu(system, user, nice, idle, unit);
|
||||
}
|
||||
|
||||
public Builder fromCpu(Cpu in) {
|
||||
return system(in.getSystem()).user(in.getUser()).nice(in.getNice()).idle(in.getIdle()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private final double system;
|
||||
private final double user;
|
||||
private final Double nice;
|
||||
private final double idle;
|
||||
private final String unit;
|
||||
|
||||
public Cpu(double system, double user, @Nullable Double nice, double idle, String unit) {
|
||||
this.system = system;
|
||||
this.user = user;
|
||||
this.nice = nice;
|
||||
this.idle = idle;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the system time in use in #unit
|
||||
*/
|
||||
public double getSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user time in use in #unit
|
||||
*/
|
||||
public double getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nice setting
|
||||
*/
|
||||
public Double getNice() {
|
||||
return nice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the idle time in #unit
|
||||
*/
|
||||
public double getIdle() {
|
||||
return idle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unit used
|
||||
*/
|
||||
public String getUnit() {
|
||||
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("[system=%f, user=%f, nice=%f, idle=%f, unit=%s]",
|
||||
system, user, nice, idle, unit);
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Detailed information on Server disk usage
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see ServerStatus
|
||||
*/
|
||||
public class Disk {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private long used;
|
||||
private long size;
|
||||
private String unit;
|
||||
|
||||
public Builder used(long used) {
|
||||
this.used = used;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder size(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder unit(String unit) {
|
||||
this.unit = unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disk build() {
|
||||
return new Disk(used, size, unit);
|
||||
}
|
||||
|
||||
public Builder fromDisk(Disk in) {
|
||||
return used(in.getUsed()).size(in.getSize()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private final long used;
|
||||
private final long size;
|
||||
private final String unit;
|
||||
|
||||
public Disk(long used, long size, String unit) {
|
||||
this.used = used;
|
||||
this.size = size;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disk used in #unit
|
||||
*/
|
||||
public long getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disk size allocated in #unit
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unit used
|
||||
*/
|
||||
public String getUnit() {
|
||||
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("[used=%d, size=%d, unit=%s]", used, size, unit);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,31 +19,31 @@
|
|||
package org.jclouds.glesys.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Detailed information on Server memory usage
|
||||
* Detailed information on usage
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see ServerStatus
|
||||
*/
|
||||
public class Memory {
|
||||
|
||||
public class ResourceUsage {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private long usage;
|
||||
private long size;
|
||||
private Double usage;
|
||||
private double max;
|
||||
private String unit;
|
||||
|
||||
public Builder usage(long usage) {
|
||||
public Builder usage(Double usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder size(long size) {
|
||||
this.size = size;
|
||||
public Builder max(double max) {
|
||||
this.max = max;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -52,39 +52,37 @@ public class Memory {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Memory build() {
|
||||
return new Memory(usage, size, unit);
|
||||
public ResourceUsage build() {
|
||||
return new ResourceUsage(usage, max, unit);
|
||||
}
|
||||
|
||||
public Builder fromMemory(Memory in) {
|
||||
return usage(in.getUsage()).size(in.getSize()).unit(in.getUnit());
|
||||
public Builder fromCpu(ResourceUsage in) {
|
||||
return usage(in.getUsage()).max(in.getMax()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("memusage")
|
||||
private final long usage;
|
||||
@SerializedName("memsize")
|
||||
private final long size;
|
||||
private final Double usage;
|
||||
private final double max;
|
||||
private final String unit;
|
||||
|
||||
public Memory(long usage, long size, String unit) {
|
||||
public ResourceUsage(Double usage, double max, String unit) {
|
||||
this.usage = usage;
|
||||
this.size = size;
|
||||
this.max = max;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory usage in #unit
|
||||
* @return the usage in #unit
|
||||
*/
|
||||
public long getUsage() {
|
||||
public Double getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory size allocated in #unit
|
||||
* @return the max usage in #unit
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
public double getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,10 +97,10 @@ public class Memory {
|
|||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Memory) {
|
||||
Memory other = (Memory) object;
|
||||
if (object instanceof ResourceUsage) {
|
||||
ResourceUsage other = (ResourceUsage) object;
|
||||
return Objects.equal(usage, other.usage)
|
||||
&& Objects.equal(size, other.size)
|
||||
&& Objects.equal(max, other.max)
|
||||
&& Objects.equal(unit, other.unit);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -111,11 +109,12 @@ public class Memory {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(usage, size, unit);
|
||||
return Objects.hashCode(usage, max, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[usage=%d, size=%d, unit=%s]", usage, size, unit);
|
||||
return String.format("[usage=%f, max=%f, unit=%s]",
|
||||
usage, max, unit);
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ public class ServerConsole {
|
|||
public static class Builder {
|
||||
private String host;
|
||||
private int port;
|
||||
private String protocol;
|
||||
private String password;
|
||||
|
||||
public Builder host(String host) {
|
||||
|
@ -51,23 +52,30 @@ public class ServerConsole {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerConsole build() {
|
||||
return new ServerConsole(host, port, password);
|
||||
return new ServerConsole(host, port, protocol, password);
|
||||
}
|
||||
|
||||
public Builder fromServerConsole(ServerConsole in) {
|
||||
return host(in.getHost()).port(in.getPort()).password(in.getPassword());
|
||||
return host(in.getHost()).port(in.getPort()).password(in.getPassword()).protocol(in.getProtocol());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String protocol;
|
||||
private final String password;
|
||||
|
||||
public ServerConsole(String host, int port, String password) {
|
||||
public ServerConsole(String host, int port, String protocol, String password) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.protocol = protocol;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
@ -85,6 +93,13 @@ public class ServerConsole {
|
|||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protocol to use to connect to the server
|
||||
*/
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password to use to connect to the server
|
||||
*/
|
||||
|
@ -100,7 +115,8 @@ public class ServerConsole {
|
|||
if (object instanceof ServerConsole) {
|
||||
final ServerConsole other = (ServerConsole) object;
|
||||
return Objects.equal(host, other.host)
|
||||
&& Objects.equal(port, other.port);
|
||||
&& Objects.equal(port, other.port)
|
||||
&& Objects.equal(protocol, other.protocol);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -108,12 +124,12 @@ public class ServerConsole {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(host, port);
|
||||
return Objects.hashCode(host, port, protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[host=%s, port=%s, password=%s]", host, port, password);
|
||||
return String.format("[host=%s, port=%s, protocol=%s, password=%s]", host, port, protocol, password);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
/**
|
||||
* 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 org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Information about a new server
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_create" />
|
||||
*/
|
||||
public class ServerCreated {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String hostname;
|
||||
private List<Ip> ips;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ips(List<Ip> ips) {
|
||||
this.ips = ips;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ips(Ip... ips) {
|
||||
return ips(Arrays.asList(ips));
|
||||
}
|
||||
|
||||
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()).ips(in.getIps());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("serverid")
|
||||
private final String id;
|
||||
private final String hostname;
|
||||
@SerializedName("iplist")
|
||||
private final List<Ip> ips;
|
||||
|
||||
public ServerCreated(String id, @Nullable String hostname, List<Ip> ips) {
|
||||
checkNotNull(id, "id");
|
||||
this.id = id;
|
||||
this.hostname = hostname;
|
||||
this.ips = ips;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the server (used for other calls to identify the server.
|
||||
* @see org.jclouds.glesys.features.ServerClient
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/** @return the hostname of the server */
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/** @return the IP addresses assigned to the server */
|
||||
public List<Ip> getIps() {
|
||||
return ips == null ? ImmutableList.<Ip>of() : ips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
return object instanceof ServerCreated
|
||||
&& Objects.equal(id, ((ServerCreated) object).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[id=%s, hostname=%s, ips=%s]", id, hostname, ips);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,14 +18,14 @@
|
|||
*/
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Detailed information about a server such as cpuCores, hardware configuration
|
||||
* (cpu, memory and disk), ip adresses, cost, transfer, os and more.
|
||||
|
@ -40,10 +40,10 @@ public class ServerDetails extends Server {
|
|||
|
||||
public static class Builder extends Server.Builder {
|
||||
private String description;
|
||||
private String template;
|
||||
private String templateName;
|
||||
private int cpuCores;
|
||||
private int memory;
|
||||
private int disk;
|
||||
private int memorySize;
|
||||
private int diskSize;
|
||||
private int transfer;
|
||||
private Cost cost;
|
||||
private List<Ip> ips;
|
||||
|
@ -53,8 +53,8 @@ public class ServerDetails extends Server {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder template(String template) {
|
||||
this.template = template;
|
||||
public Builder templateName(String templateName) {
|
||||
this.templateName = templateName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,13 @@ public class ServerDetails extends Server {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder memory(int memory) {
|
||||
this.memory = memory;
|
||||
public Builder memorySize(int memorySize) {
|
||||
this.memorySize = memorySize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder disk(int disk) {
|
||||
this.disk = disk;
|
||||
public Builder diskSize(int diskSize) {
|
||||
this.diskSize = diskSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -93,11 +93,11 @@ public class ServerDetails extends Server {
|
|||
}
|
||||
|
||||
public ServerDetails build() {
|
||||
return new ServerDetails(id, hostname, datacenter, platform, template, description, cpuCores, memory, disk, transfer, cost, ips);
|
||||
return new ServerDetails(id, hostname, datacenter, platform, templateName, description, cpuCores, memorySize, diskSize, transfer, cost, ips);
|
||||
}
|
||||
|
||||
public Builder fromServerDetails(ServerDetails in) {
|
||||
return fromServer(in).template(in.getTemplate()).memory(in.getMemory()).disk(in.getDisk()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||
return fromServer(in).templateName(in.getTemplateName()).memorySize(in.getMemorySize()).diskSize(in.getDiskSize()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||
.description(in.getDescription()).ips(in.getIps());
|
||||
}
|
||||
|
||||
|
@ -128,24 +128,27 @@ public class ServerDetails extends Server {
|
|||
}
|
||||
|
||||
private final String description;
|
||||
private final String template;
|
||||
@SerializedName("templatename")
|
||||
private final String templateName;
|
||||
@SerializedName("cpucores")
|
||||
private final int cpuCores;
|
||||
private final int memory;
|
||||
private final int disk;
|
||||
@SerializedName("memorysize")
|
||||
private final int memorySize;
|
||||
@SerializedName("disksize")
|
||||
private final int diskSize;
|
||||
private final int transfer;
|
||||
private final Cost cost;
|
||||
@SerializedName("iplist")
|
||||
private final List<Ip> ips;
|
||||
|
||||
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<Ip> ips) {
|
||||
public ServerDetails(String id, String hostname, String datacenter, String platform, String templateName,
|
||||
String description, int cpuCores, int memorySize, int diskSize, int transfer, Cost cost, List<Ip> ips) {
|
||||
super(id, hostname, datacenter, platform);
|
||||
this.template = checkNotNull(template, "template");
|
||||
this.templateName = checkNotNull(templateName, "template");
|
||||
this.description = description;
|
||||
this.cpuCores = cpuCores;
|
||||
this.memory = memory;
|
||||
this.disk = disk;
|
||||
this.memorySize = memorySize;
|
||||
this.diskSize = diskSize;
|
||||
this.transfer = transfer;
|
||||
this.cost = checkNotNull(cost, "cost");
|
||||
this.ips = ips == null ? ImmutableList.<Ip>of() : ips;
|
||||
|
@ -168,15 +171,15 @@ public class ServerDetails extends Server {
|
|||
/**
|
||||
* @return the disk of the server in GB
|
||||
*/
|
||||
public int getDisk() {
|
||||
return disk;
|
||||
public int getDiskSize() {
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory of the server in MB
|
||||
*/
|
||||
public int getMemory() {
|
||||
return memory;
|
||||
public int getMemorySize() {
|
||||
return memorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,15 +206,15 @@ public class ServerDetails extends Server {
|
|||
/**
|
||||
* @return the name of the template used to create the server
|
||||
*/
|
||||
public String getTemplate() {
|
||||
return template;
|
||||
public String getTemplateName() {
|
||||
return templateName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"[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);
|
||||
"[id=%s, hostname=%s, datacenter=%s, platform=%s, templateName=%s, description=%s, cpuCores=%d, memorySize=%d, diskSize=%d, transfer=%d, cost=%s, ips=%s]", id,
|
||||
hostname, datacenter, platform, templateName, description, cpuCores, memorySize, diskSize, transfer, cost, ips);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,65 +35,57 @@ public class ServerStatus {
|
|||
|
||||
public static class Builder {
|
||||
private ServerState state;
|
||||
private Cpu cpu;
|
||||
private Memory memory;
|
||||
private Disk disk;
|
||||
private Bandwidth bandwidth;
|
||||
private long uptime;
|
||||
private ResourceUsage cpu;
|
||||
private ResourceUsage memory;
|
||||
private ResourceUsage disk;
|
||||
private ServerUptime uptime;
|
||||
|
||||
public Builder state(ServerState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder cpu(Cpu cpu) {
|
||||
public Builder cpu(ResourceUsage cpu) {
|
||||
this.cpu = cpu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder memory(Memory memory) {
|
||||
public Builder memory(ResourceUsage memory) {
|
||||
this.memory = memory;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder disk(Disk disk) {
|
||||
public Builder disk(ResourceUsage disk) {
|
||||
this.disk = disk;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder bandwidth(Bandwidth bandwidth) {
|
||||
this.bandwidth = bandwidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder uptime(long uptime) {
|
||||
public Builder uptime(ServerUptime uptime) {
|
||||
this.uptime = uptime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStatus build() {
|
||||
return new ServerStatus(state, cpu, memory, disk, bandwidth, uptime);
|
||||
return new ServerStatus(state, cpu, memory, disk, uptime);
|
||||
}
|
||||
|
||||
public Builder fromServerStatus(ServerStatus in) {
|
||||
return state(in.getState()).cpu(in.getCpu()).memory(in.getMemory()).disk(in.getDisk()).bandwidth(in.getBandwidth()).uptime(in.getUptime());
|
||||
return state(in.getState()).cpu(in.getCpu()).memory(in.getMemory()).disk(in.getDisk()).uptime(in.getUptime());
|
||||
}
|
||||
}
|
||||
|
||||
private final ServerState state;
|
||||
private final Cpu cpu;
|
||||
private final Memory memory;
|
||||
private final Disk disk;
|
||||
private final Bandwidth bandwidth;
|
||||
private final ResourceUsage cpu;
|
||||
private final ResourceUsage memory;
|
||||
private final ResourceUsage disk;
|
||||
private final ServerUptime uptime;
|
||||
|
||||
public ServerStatus(ServerState state, Cpu cpu, Memory memory, Disk disk, Bandwidth bandwidth, long uptime) {
|
||||
public ServerStatus(ServerState state, ResourceUsage cpu, ResourceUsage memory, ResourceUsage disk, ServerUptime uptime) {
|
||||
this.state = state;
|
||||
this.cpu = cpu;
|
||||
this.memory = memory;
|
||||
this.disk = disk;
|
||||
this.bandwidth = bandwidth;
|
||||
this.uptime = ServerUptime.fromValue(uptime);
|
||||
this.uptime = uptime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,36 +98,29 @@ public class ServerStatus {
|
|||
/**
|
||||
* @return CPU usage information
|
||||
*/
|
||||
public Cpu getCpu() {
|
||||
public ResourceUsage getCpu() {
|
||||
return cpu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of memory usage and limits
|
||||
*/
|
||||
public Memory getMemory() {
|
||||
public ResourceUsage getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of disk usage and limits
|
||||
*/
|
||||
public Disk getDisk() {
|
||||
public ResourceUsage getDisk() {
|
||||
return disk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of bandwidth usage and limits
|
||||
*/
|
||||
public Bandwidth getBandwidth() {
|
||||
return bandwidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uptime of the server
|
||||
*/
|
||||
public long getUptime() {
|
||||
return uptime.getTime();
|
||||
public ServerUptime getUptime() {
|
||||
return uptime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,7 +134,6 @@ public class ServerStatus {
|
|||
&& Objects.equal(cpu, other.cpu)
|
||||
&& Objects.equal(memory, other.memory)
|
||||
&& Objects.equal(disk, other.disk)
|
||||
&& Objects.equal(bandwidth, other.bandwidth)
|
||||
&& Objects.equal(uptime, other.uptime);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -158,13 +142,13 @@ public class ServerStatus {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(state, cpu, memory, disk, bandwidth, uptime);
|
||||
return Objects.hashCode(state, cpu, memory, disk, uptime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[state=%s, cpu=%s, memory=%s, disk=%s, bandwidth=%s, uptime=%s]",
|
||||
state, cpu, memory, disk, bandwidth, uptime);
|
||||
return String.format("[state=%s, cpu=%s, memory=%s, disk=%s, uptime=%s]",
|
||||
state, cpu, memory, disk, uptime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,10 +77,11 @@ public class ServerTemplate implements Comparable<ServerTemplate>{
|
|||
}
|
||||
|
||||
private final String name;
|
||||
@SerializedName("min_disk_size")
|
||||
@SerializedName("minimumdisksize")
|
||||
private final int minDiskSize;
|
||||
@SerializedName("min_mem_size")
|
||||
@SerializedName("minimummemorysize")
|
||||
private final int minMemSize;
|
||||
@SerializedName("operatingsystem")
|
||||
private final String os;
|
||||
private final String platform;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -34,59 +35,55 @@ import java.util.concurrent.TimeUnit;
|
|||
* @see ServerStatus
|
||||
*/
|
||||
public class ServerUptime {
|
||||
private final long time;
|
||||
private final String timeString;
|
||||
|
||||
private ServerUptime(long time) {
|
||||
this.time = time;
|
||||
long days = TimeUnit.SECONDS.toDays(time);
|
||||
long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days));
|
||||
Long[] bits = new Long[]{
|
||||
0L,
|
||||
(days / 365),
|
||||
((days % 365) / 30),
|
||||
((days % 365) % 30),
|
||||
hours,
|
||||
TimeUnit.SECONDS.toMinutes(time - TimeUnit.HOURS.toSeconds(hours) - TimeUnit.DAYS.toSeconds(days)),
|
||||
time % 60
|
||||
};
|
||||
this.timeString = Joiner.on(' ').join(bits);
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
private ServerUptime(String timeString) {
|
||||
Splitter splitter = Splitter.on(' ').omitEmptyStrings().trimResults();
|
||||
List<String> data = new ArrayList<String>();
|
||||
Iterables.addAll(data, splitter.split(timeString));
|
||||
long result = Integer.parseInt(data.get(6));
|
||||
result += TimeUnit.SECONDS.convert(Integer.parseInt(data.get(5)), TimeUnit.MINUTES);
|
||||
result += TimeUnit.SECONDS.convert(Integer.parseInt(data.get(4)), TimeUnit.HOURS);
|
||||
result += TimeUnit.SECONDS.convert(Integer.parseInt(data.get(3)), TimeUnit.DAYS);
|
||||
result += TimeUnit.SECONDS.convert(Integer.parseInt(data.get(2)) * 30, TimeUnit.DAYS);
|
||||
result += TimeUnit.SECONDS.convert(Integer.parseInt(data.get(1)) * 365, TimeUnit.DAYS);
|
||||
this.time = result;
|
||||
this.timeString = timeString;
|
||||
public static class Builder {
|
||||
private long current;
|
||||
private String unit;
|
||||
|
||||
public Builder current(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder unit(String unit) {
|
||||
this.unit = unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerUptime build() {
|
||||
return new ServerUptime(current, unit);
|
||||
}
|
||||
|
||||
public Builder fromServerUptime(ServerUptime from) {
|
||||
return current(from.getCurrent()).unit(from.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private final long current;
|
||||
private final String unit;
|
||||
|
||||
public ServerUptime(long current, String unit) {
|
||||
this.current = current;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uptimeString a Glesys uptime string, ex. "0 0 0 0 0 10 1 1"
|
||||
* @return the time the server has been up in #unit
|
||||
*/
|
||||
public static ServerUptime fromValue(String uptimeString) {
|
||||
return new ServerUptime(uptimeString);
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time number of seconds the server has been up
|
||||
* @return the unit used for #time
|
||||
*/
|
||||
public static ServerUptime fromValue(long time) {
|
||||
return new ServerUptime(time);
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of seconds the server has been up
|
||||
*/
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
|
@ -94,17 +91,18 @@ public class ServerUptime {
|
|||
return true;
|
||||
}
|
||||
return object instanceof ServerUptime
|
||||
&& Objects.equal(time, ((ServerUptime) object).getTime());
|
||||
&& Objects.equal(current, ((ServerUptime) object).getCurrent())
|
||||
&& Objects.equal(unit, ((ServerUptime) object).getUnit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(time);
|
||||
return Objects.hashCode(current, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return timeString;
|
||||
return String.format("[current=%d unit=%s]", current, unit);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,7 +32,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import org.jclouds.glesys.domain.Server;
|
||||
import org.jclouds.glesys.domain.ServerAllowedArguments;
|
||||
import org.jclouds.glesys.domain.ServerConsole;
|
||||
import org.jclouds.glesys.domain.ServerCreated;
|
||||
import org.jclouds.glesys.domain.ServerDetails;
|
||||
import org.jclouds.glesys.domain.ServerLimit;
|
||||
import org.jclouds.glesys.domain.ServerStatus;
|
||||
|
@ -112,7 +111,7 @@ public interface ServerAsyncClient {
|
|||
*/
|
||||
@POST
|
||||
@Path("/server/console/format/json")
|
||||
@SelectJson("remote")
|
||||
@SelectJson("console")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ServerConsole> getServerConsole(@FormParam("serverid") String id);
|
||||
|
@ -141,44 +140,51 @@ public interface ServerAsyncClient {
|
|||
*/
|
||||
@POST
|
||||
@Path("/server/resetlimit/format/json")
|
||||
ListenableFuture<Void> resetServerLimit(@FormParam("serverid") String id, @FormParam("type") String type);
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<SortedMap<String, ServerLimit>> resetServerLimit(@FormParam("serverid") String id, @FormParam("type") String type);
|
||||
|
||||
/**
|
||||
* @see ServerClient#rebootServer
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("server")
|
||||
@Path("/server/reboot/format/json")
|
||||
ListenableFuture<Void> rebootServer(@FormParam("serverid") String id);
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerDetails> rebootServer(@FormParam("serverid") String id);
|
||||
|
||||
/**
|
||||
* @see ServerClient#startServer
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("server")
|
||||
@Path("/server/start/format/json")
|
||||
ListenableFuture<Void> startServer(@FormParam("serverid") String id);
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerDetails> startServer(@FormParam("serverid") String id);
|
||||
|
||||
/**
|
||||
* @see ServerClient#stopServer
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("server")
|
||||
@Path("/server/stop/format/json")
|
||||
ListenableFuture<Void> stopServer(@FormParam("serverid") String id, ServerStopOptions... options);
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerDetails> stopServer(@FormParam("serverid") String id, ServerStopOptions... options);
|
||||
|
||||
/**
|
||||
* @see ServerClient#createServer
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/create/format/json")
|
||||
@SelectJson("server")
|
||||
@Path("/server/create/format/json")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerCreated> createServer(@FormParam("datacenter") String dataCenter,
|
||||
ListenableFuture<ServerDetails> createServer(@FormParam("datacenter") String datacenter,
|
||||
@FormParam("platform") String platform,
|
||||
@FormParam("hostname") String hostname,
|
||||
@FormParam("template") String template,
|
||||
@FormParam("templatename") String templateName,
|
||||
@FormParam("disksize") int diskSize,
|
||||
@FormParam("memorysize") int memorySize,
|
||||
@FormParam("cpucores") int cpucores,
|
||||
@FormParam("rootpw") String rootpw,
|
||||
@FormParam("cpucores") int cpuCores,
|
||||
@FormParam("rootpassword") String rootPassword,
|
||||
@FormParam("transfer") int transfer,
|
||||
ServerCreateOptions... options);
|
||||
|
||||
|
@ -189,7 +195,7 @@ public interface ServerAsyncClient {
|
|||
@Path("/server/clone/format/json")
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerCreated> cloneServer(@FormParam("serverid") String serverid,
|
||||
ListenableFuture<ServerDetails> cloneServer(@FormParam("serverid") String serverid,
|
||||
@FormParam("hostname") String hostname,
|
||||
ServerCloneOptions... options);
|
||||
|
||||
|
@ -198,7 +204,9 @@ public interface ServerAsyncClient {
|
|||
*/
|
||||
@POST
|
||||
@Path("/server/edit/format/json")
|
||||
ListenableFuture<Void> editServer(@FormParam("serverid") String serverid, ServerEditOptions... options);
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerDetails> editServer(@FormParam("serverid") String serverid, ServerEditOptions... options);
|
||||
|
||||
/**
|
||||
* @see ServerClient#destroyServer
|
||||
|
@ -214,4 +222,11 @@ public interface ServerAsyncClient {
|
|||
@Path("/server/destroy/format/json")
|
||||
ListenableFuture<Void> resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password);
|
||||
|
||||
/**
|
||||
* @see ServerClient#resourceUsage
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/resourceusage/format/json")
|
||||
void resourceUsage(@FormParam("serverid") String id, @FormParam("resource") String resource, @FormParam("resolution") String resolution);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.glesys.features;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
|
@ -28,7 +29,6 @@ import org.jclouds.concurrent.Timeout;
|
|||
import org.jclouds.glesys.domain.Server;
|
||||
import org.jclouds.glesys.domain.ServerAllowedArguments;
|
||||
import org.jclouds.glesys.domain.ServerConsole;
|
||||
import org.jclouds.glesys.domain.ServerCreated;
|
||||
import org.jclouds.glesys.domain.ServerDetails;
|
||||
import org.jclouds.glesys.domain.ServerLimit;
|
||||
import org.jclouds.glesys.domain.ServerStatus;
|
||||
|
@ -117,22 +117,21 @@ public interface ServerClient {
|
|||
* @param id id of the server
|
||||
* @param type the type of limit to reset
|
||||
*/
|
||||
|
||||
void resetServerLimit(String id, String type);
|
||||
Map<String, ServerLimit> resetServerLimit(String id, String type);
|
||||
|
||||
/**
|
||||
* Reboot a server
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
void rebootServer(String id);
|
||||
ServerDetails rebootServer(String id);
|
||||
|
||||
/**
|
||||
* Start a server
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
void startServer(String id);
|
||||
ServerDetails startServer(String id);
|
||||
|
||||
/**
|
||||
* Stop a server
|
||||
|
@ -148,17 +147,17 @@ public interface ServerClient {
|
|||
* @param datacenter the data center to create the new server in
|
||||
* @param platform the platform to use (i.e. "Xen" or "OpenVZ")
|
||||
* @param hostname the host name of the new server
|
||||
* @param template the template to use to create the new server
|
||||
* @param disksize the amount of disk space, in GB, to allocate
|
||||
* @param memorysize the memory, in MB, to allocate
|
||||
* @param cpucores the number of CPU cores to allocate
|
||||
* @param rootpw the root password to use
|
||||
* @param templateName the template to use to create the new server
|
||||
* @param diskSize the amount of disk space, in GB, to allocate
|
||||
* @param memorySize the memory, in MB, to allocate
|
||||
* @param cpuCores the number of CPU cores to allocate
|
||||
* @param rootPassword the root password to use
|
||||
* @param transfer the transfer size
|
||||
* @param options optional settings ex. description
|
||||
*/
|
||||
ServerCreated createServer(String datacenter, String platform,
|
||||
String hostname, String template, int disksize, int memorysize,
|
||||
int cpucores, String rootpw, int transfer, ServerCreateOptions... options);
|
||||
ServerDetails createServer(String datacenter,String platform,String hostname,
|
||||
String templateName, int diskSize, int memorySize, int cpuCores,
|
||||
String rootPassword, int transfer, ServerCreateOptions... options);
|
||||
|
||||
/**
|
||||
* Edit the configuration of a server
|
||||
|
@ -166,7 +165,7 @@ public interface ServerClient {
|
|||
* @param serverid the serverId of the server to edit
|
||||
* @param options the settings to change
|
||||
*/
|
||||
void editServer(String serverid, ServerEditOptions... options);
|
||||
ServerDetails editServer(String serverid, ServerEditOptions... options);
|
||||
|
||||
/**
|
||||
* Clone a server
|
||||
|
@ -175,7 +174,7 @@ public interface ServerClient {
|
|||
* @param hostname the new host name of the cloned server
|
||||
* @param options the settings to change
|
||||
*/
|
||||
ServerCreated cloneServer(String serverid, String hostname, ServerCloneOptions... options);
|
||||
ServerDetails cloneServer(String serverid, String hostname, ServerCloneOptions... options);
|
||||
|
||||
/**
|
||||
* Destroy a server
|
||||
|
@ -183,7 +182,7 @@ public interface ServerClient {
|
|||
* @param id the id of the server
|
||||
* @param keepIp if ServerDestroyOptions.keepIp(true) the servers ip will be retained for use in your GleSYS account
|
||||
*/
|
||||
void destroyServer(String id, ServerDestroyOptions keepIp);
|
||||
ServerDetails destroyServer(String id, ServerDestroyOptions keepIp);
|
||||
|
||||
/**
|
||||
* Reset the root password of a server
|
||||
|
@ -191,7 +190,16 @@ public interface ServerClient {
|
|||
* @param id the id of the server
|
||||
* @param password the new password to use
|
||||
*/
|
||||
void resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password);
|
||||
void resetPassword(String id, String password);
|
||||
|
||||
|
||||
/**
|
||||
* Return resource usage over time for server
|
||||
*
|
||||
* @param id the id of the server
|
||||
* @param resource the name of the resource to retrieve usage information for
|
||||
*/
|
||||
void resourceUsage(String id, String resource, String resolution);
|
||||
|
||||
|
||||
}
|
|
@ -44,15 +44,4 @@ public class GleSYSTypeAdapters {
|
|||
}
|
||||
}
|
||||
|
||||
public static class ServerUptimeAdapter extends TypeAdapter<ServerUptime> {
|
||||
@Override
|
||||
public void write(JsonWriter writer, ServerUptime value) throws IOException {
|
||||
writer.value(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerUptime read(JsonReader reader) throws IOException {
|
||||
return ServerUptime.fromValue(reader.nextString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.jclouds.glesys.reference;
|
||||
|
||||
import org.jclouds.compute.domain.ComputeMetadata;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants in GleSYS connections.
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class GleSYSConstants {
|
||||
public static final String PROPERTY_GLESYS_DEFAULT_DC = "jclouds.glesys.defaultdc";
|
||||
public static final String PROPERTY_GLESYS_MIN_DISK = "jclouds.glesys.mindisk";
|
||||
public static final String PROPERTY_GLESYS_MIN_RAM = "jclouds.glesys.minram";
|
||||
|
||||
public static final Pattern JCLOUDS_ID_TO_PLATFORM = Pattern.compile("([a-zA-Z]+) .*");
|
||||
|
||||
public static String getPlatform(ComputeMetadata jcloudsObject) {
|
||||
checkNotNull(jcloudsObject, "jcloudsObject");
|
||||
Matcher matcher = JCLOUDS_ID_TO_PLATFORM.matcher(jcloudsObject.getId());
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException(jcloudsObject.getId() + " not a GleSYS platform-based id!");
|
||||
}
|
||||
return matcher.group(1);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import static org.testng.Assert.*;
|
|||
import com.google.common.base.Predicate;
|
||||
import org.jclouds.glesys.GleSYSAsyncClient;
|
||||
import org.jclouds.glesys.GleSYSClient;
|
||||
import org.jclouds.glesys.domain.ServerCreated;
|
||||
import org.jclouds.glesys.domain.ServerDetails;
|
||||
import org.jclouds.glesys.domain.ServerState;
|
||||
import org.jclouds.glesys.domain.ServerStatus;
|
||||
import org.jclouds.glesys.options.ServerStatusOptions;
|
||||
|
@ -88,7 +88,7 @@ public class BaseGleSYSClientLiveTest {
|
|||
|
||||
protected ServerStatusChecker createServer(String hostName) {
|
||||
ServerClient client = context.getApi().getServerClient();
|
||||
ServerCreated testServer = client.createServer("Falkenberg", "OpenVZ", hostName, "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
|
||||
ServerDetails testServer = client.createServer("Falkenberg", "OpenVZ", hostName, "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
|
||||
|
||||
assertNotNull(testServer.getId());
|
||||
assertEquals(testServer.getHostname(), hostName);
|
||||
|
|
|
@ -21,12 +21,8 @@ package org.jclouds.glesys.features;
|
|||
import com.google.common.collect.ImmutableMultimap;
|
||||
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.ServerDetails;
|
||||
import org.jclouds.glesys.domain.Ip;
|
||||
import org.jclouds.glesys.domain.*;
|
||||
import org.jclouds.glesys.options.*;
|
||||
import org.jclouds.glesys.parse.*;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
@ -35,6 +31,8 @@ import org.jclouds.rest.ResourceNotFoundException;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jclouds.io.Payloads.newUrlEncodedFormPayload;
|
||||
import static org.testng.Assert.*;
|
||||
|
@ -83,7 +81,32 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build()).build(),
|
||||
HttpResponse.builder().statusCode(204).payload(payloadFromResource("/server_allowed_arguments.json")).build()).getServerClient();
|
||||
|
||||
assertEquals(client.getServerAllowedArguments(), new ParseServerAllowedArgumentsTest().expected());
|
||||
Map<String, ServerAllowedArguments> expected = new LinkedHashMap<String, ServerAllowedArguments>();
|
||||
ServerAllowedArguments openvz = ServerAllowedArguments.builder()
|
||||
.dataCenters("Amsterdam", "Falkenberg", "New York City", "Stockholm")
|
||||
.memorySizes(128, 256, 512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288)
|
||||
.diskSizes(5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 150)
|
||||
.cpuCores(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
.templates("Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit", "Debian 5.0 32-bit",
|
||||
"Debian 5.0 64-bit", "Debian 6.0 32-bit", "Debian 6.0 64-bit", "Fedora Core 11", "Fedora Core 11 64-bit",
|
||||
"Gentoo", "Gentoo 64-bit", "Scientific Linux 6", "Scientific Linux 6 64-bit", "Slackware 12",
|
||||
"Ubuntu 10.04 LTS 32-bit", "Ubuntu 10.04 LTS 64-bit", "Ubuntu 11.04 64-bit")
|
||||
.transfers(50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000)
|
||||
.build();
|
||||
ServerAllowedArguments xen = ServerAllowedArguments.builder()
|
||||
.memorySizes(512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 14336, 16384)
|
||||
.diskSizes(5, 10, 20, 30, 40, 50, 80, 100, 120, 140, 150, 160, 160, 200, 250, 300)
|
||||
.cpuCores(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
.templates("CentOS 5.5 x64", "CentOS 5.5 x86", "Centos 6 x64", "Centos 6 x86", "Debian-6 x64",
|
||||
"Debian 5.0.1 x64", "FreeBSD 8.2", "Gentoo 10.1 x64", "Ubuntu 8.04 x64", "Ubuntu 10.04 LTS 64-bit",
|
||||
"Ubuntu 10.10 x64", "Ubuntu 11.04 x64", "Windows Server 2008 R2 x64 std",
|
||||
"Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web")
|
||||
.transfers(50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000)
|
||||
.dataCenters("Falkenberg")
|
||||
.build();
|
||||
expected.put("Xen", xen);
|
||||
expected.put("OpenVZ", openvz);
|
||||
assertEquals(client.getServerAllowedArguments(), expected);
|
||||
}
|
||||
|
||||
public void testGetTemplatesWhenResponseIs2xx() throws Exception {
|
||||
|
@ -94,10 +117,29 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build()).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_templates.json")).build()).getServerClient();
|
||||
|
||||
assertEquals(client.getTemplates(), new ParseServerTemplatesTest().expected());
|
||||
ImmutableSet.Builder<ServerTemplate> expectedBuilder = ImmutableSet.<ServerTemplate> builder();
|
||||
|
||||
for (String name : new String[] { "Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit",
|
||||
"Debian 5.0 32-bit", "Debian 5.0 64-bit", "Debian 6.0 32-bit", "Debian 6.0 64-bit", "Fedora Core 11",
|
||||
"Fedora Core 11 64-bit", "Gentoo", "Gentoo 64-bit", "Scientific Linux 6", "Scientific Linux 6 64-bit",
|
||||
"Slackware 12", "Ubuntu 10.04 LTS 32-bit", "Ubuntu 10.04 LTS 64-bit", "Ubuntu 11.04 64-bit" }) {
|
||||
expectedBuilder.add(new ServerTemplate(name, 5, 128, "linux", "OpenVZ"));
|
||||
}
|
||||
|
||||
public void testGetServerWhenResponseIs2xx() throws Exception {
|
||||
for (String name : new String[] { "CentOS 5.5 x64", "CentOS 5.5 x86", "Centos 6 x64", "Centos 6 x86",
|
||||
"Debian-6 x64", "Debian 5.0.1 x64", "FreeBSD 8.2", "Gentoo 10.1 x64", "Ubuntu 8.04 x64",
|
||||
"Ubuntu 10.04 LTS 64-bit", "Ubuntu 10.10 x64", "Ubuntu 11.04 x64" }) {
|
||||
expectedBuilder.add(new ServerTemplate(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen"));
|
||||
}
|
||||
for (String name : new String[] { "Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web",
|
||||
"Windows Server 2008 x64 web", "Windows Server 2008 x86 web" }) {
|
||||
expectedBuilder.add(new ServerTemplate(name, 20, 1024, "windows", "Xen"));
|
||||
}
|
||||
|
||||
assertEquals(client.getTemplates(), expectedBuilder.build());
|
||||
}
|
||||
|
||||
public void testGetServerDetailsWhenResponseIs2xx() throws Exception {
|
||||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/details/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
|
@ -108,7 +150,29 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||
|
||||
ServerDetails actual = client.getServerDetails("server1ssg-1.1");
|
||||
assertEquals(actual.toString(), new ParseServerDetailsTest().expected().toString());
|
||||
assertEquals(actual.toString(), expectedServerDetails().toString());
|
||||
}
|
||||
|
||||
private ServerDetails expectedServerDetails() {
|
||||
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("vz1375882").transfer(50).hostname("jclouds-unit").cpuCores(1).memorySize(128)
|
||||
.diskSize(5).description("unit test server").datacenter("Falkenberg").platform("OpenVZ")
|
||||
.templateName("Debian 6.0 64-bit").cost(cost).ips(ip).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServerDetailsWhenResponseIs4xxReturnsNull() throws Exception {
|
||||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/details/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server111").build())).build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getServerClient();
|
||||
|
||||
assertNull(client.getServerDetails("server111"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -119,18 +183,22 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("cpucores", "1").put("memorysize", "512")
|
||||
.put("cpucores", "1")
|
||||
.put("memorysize", "512")
|
||||
.put("datacenter", "Falkenberg")
|
||||
.put("transfer", "50")
|
||||
.put("rootpw", "password")
|
||||
.put("rootpassword", "password")
|
||||
.put("hostname", "jclouds-test")
|
||||
.put("platform", "OpenVZ")
|
||||
.put("template", "Ubuntu 32-bit")
|
||||
.put("templatename", "Ubuntu 32-bit")
|
||||
.put("disksize", "5").build())).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_created.json")).build()).getServerClient();
|
||||
ServerCreated expected = ServerCreated.builder().hostname("jclouds-test").id("xm3630641").ips(Ip.builder().ip("109.74.10.27").build()).build();
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_noip.json")).build()).getServerClient();
|
||||
|
||||
assertEquals(client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 32-bit", 5, 512, 1, "password", 50), expected);
|
||||
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
||||
ServerDetails expected = ServerDetails.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ")
|
||||
.templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySize(128).diskSize(5).transfer(50).cost(cost).build();
|
||||
|
||||
assertEquals(client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 32-bit", 5, 512, 1, "password", 50).toString(), expected.toString());
|
||||
}
|
||||
|
||||
public void testCreateServerWithOptsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -143,18 +211,18 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("cpucores", "1").put("memorysize", "512")
|
||||
.put("datacenter", "Falkenberg")
|
||||
.put("transfer", "50")
|
||||
.put("rootpw", "password")
|
||||
.put("rootpassword", "password")
|
||||
.put("hostname", "jclouds-test")
|
||||
.put("platform", "OpenVZ")
|
||||
.put("template", "Ubuntu 32-bit")
|
||||
.put("templatename", "Ubuntu 32-bit")
|
||||
.put("disksize", "5")
|
||||
.put("description", "Description-of-server")
|
||||
.put("ip", "10.0.0.1").build())).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_created.json")).build()).getServerClient();
|
||||
ServerCreateOptions options = ServerCreateOptions.Builder.description("Description-of-server").ip("10.0.0.1");
|
||||
ServerCreated expected = ServerCreated.builder().hostname("jclouds-test").id("xm3630641").ips(Ip.builder().ip("109.74.10.27").build()).build();
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||
|
||||
assertEquals(client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 32-bit", 5, 512, 1, "password", 50, options), expected);
|
||||
ServerCreateOptions options = ServerCreateOptions.Builder.description("Description-of-server").ip("10.0.0.1");
|
||||
|
||||
assertEquals(client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 32-bit", 5, 512, 1, "password", 50, options), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -162,6 +230,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/edit/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server111").build())).build(),
|
||||
|
@ -175,6 +244,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/edit/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server111")
|
||||
|
@ -202,10 +272,9 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server111")
|
||||
.put("hostname", "hostname1").build())).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_created.json")).build()).getServerClient();
|
||||
ServerCreated expected = ServerCreated.builder().hostname("jclouds-test").id("xm3630641").ips(Ip.builder().ip("109.74.10.27").build()).build();
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||
|
||||
assertEquals(client.cloneServer("server111", "hostname1"), expected);
|
||||
assertEquals(client.cloneServer("server111", "hostname1"), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -222,11 +291,10 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("disksize", "1")
|
||||
.put("memorysize", "512")
|
||||
.put("cpucores", "1").build())).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_created.json")).build()).getServerClient();
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||
ServerCloneOptions options = (ServerCloneOptions) ServerCloneOptions.Builder.description("Description-of-server").disksize(1).memorysize(512).cpucores(1);
|
||||
ServerCreated expected = ServerCreated.builder().hostname("jclouds-test").id("xm3630641").ips(Ip.builder().ip("109.74.10.27").build()).build();
|
||||
|
||||
assertEquals(client.cloneServer("server111", "hostname1", options), expected);
|
||||
assertEquals(client.cloneServer("server111", "hostname1", options), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
|
@ -255,7 +323,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
|
||||
.getServerClient();
|
||||
|
||||
assertEquals(client.getServerStatus("server111"), new ParseServerStatusTest().expected());
|
||||
assertEquals(client.getServerStatus("server111"), expectedServerStatus());
|
||||
}
|
||||
|
||||
public void testGetServerStatusWithOptsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -269,7 +337,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
|
||||
.getServerClient();
|
||||
|
||||
assertEquals(client.getServerStatus("server321", ServerStatusOptions.Builder.state()), new ParseServerStatusTest().expected());
|
||||
assertEquals(client.getServerStatus("server321", ServerStatusOptions.Builder.state()), expectedServerStatus());
|
||||
}
|
||||
|
||||
public void testGetServerStatusWhenResponseIs4xx() throws Exception {
|
||||
|
@ -311,7 +379,9 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_console.json")).build())
|
||||
.getServerClient();
|
||||
|
||||
assertEquals(client.getServerConsole("server322"), new ParseServerConsoleTest().expected());
|
||||
ServerConsole expected = ServerConsole.builder().host("79.99.2.147").port(59478).password("1476897311").protocol("vnc").build();
|
||||
|
||||
assertEquals(client.getServerConsole("server322"), expected);
|
||||
}
|
||||
|
||||
public void testGetServerConsoleWhenResponseIs4xx() throws Exception {
|
||||
|
@ -332,6 +402,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/start/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -346,6 +417,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/start/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -359,6 +431,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/stop/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -372,6 +445,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/stop/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").put("type", "hard").build())).build(),
|
||||
|
@ -386,6 +460,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/stop/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -399,6 +474,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/reboot/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -413,6 +489,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
ServerClient client = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/server/reboot/format/json"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||
.put("serverid", "server777").build())).build(),
|
||||
|
@ -449,4 +526,14 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
client.destroyServer("server777", ServerDestroyOptions.Builder.discardIp());
|
||||
}
|
||||
|
||||
|
||||
private ServerStatus expectedServerStatus() {
|
||||
ResourceUsage cpu = ResourceUsage.builder().unit("cores").max(1.0).usage(null).build();
|
||||
ResourceUsage disk = ResourceUsage.builder().unit("MB").usage(372.0).max(5120).build();
|
||||
ResourceUsage memory = ResourceUsage.builder().unit("MB").usage(3.0).max(128).build();
|
||||
ServerUptime uptime = ServerUptime.builder().current(108).unit("seconds").build();
|
||||
return ServerStatus.builder().state(ServerState.RUNNING).uptime(uptime).
|
||||
cpu(cpu).disk(disk).memory(memory).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -135,11 +135,11 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
public void testServerDetails() throws Exception {
|
||||
ServerDetails details = client.getServerDetails(testServerId);
|
||||
checkServer(details);
|
||||
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplate());
|
||||
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
|
||||
assertEquals("Falkenberg", details.getDatacenter());
|
||||
assertEquals("OpenVZ", details.getPlatform());
|
||||
assertEquals(5, details.getDisk());
|
||||
assertEquals(512, details.getMemory());
|
||||
assertEquals(5, details.getDiskSize());
|
||||
assertEquals(512, details.getMemorySize());
|
||||
assertEquals(1, details.getCpuCores());
|
||||
assertEquals(50, details.getTransfer());
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
long uptime = 0;
|
||||
|
||||
while(uptime < 20) {
|
||||
uptime = client.getServerStatus(testServerId).getUptime();
|
||||
uptime = client.getServerStatus(testServerId).getUptime().getCurrent();
|
||||
}
|
||||
|
||||
assertTrue(uptime > 19);
|
||||
|
@ -164,7 +164,7 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
|
||||
Thread.sleep(1000);
|
||||
|
||||
uptime = client.getServerStatus(testServerId).getUptime();
|
||||
uptime = client.getServerStatus(testServerId).getUptime().getCurrent();
|
||||
|
||||
assertTrue(uptime < 20);
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
// takes a few minutes and requires an extra server (using 2 already)
|
||||
@Test(enabled=false)
|
||||
public void testCloneServer() throws Exception {
|
||||
ServerCreated testServer2 = client.cloneServer(testServerId, testHostName2, ServerCloneOptions.Builder.cpucores(1));
|
||||
ServerDetails testServer2 = client.cloneServer(testServerId, testHostName2, ServerCloneOptions.Builder.cpucores(1));
|
||||
|
||||
assertNotNull(testServer2.getId());
|
||||
assertEquals(testServer2.getHostname(), "jclouds-test2");
|
||||
|
@ -248,12 +248,12 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
private void checkServer(ServerDetails server) {
|
||||
// description can be null
|
||||
assert server.getCpuCores() > 0 : server;
|
||||
assert server.getDisk() > 0 : server;
|
||||
assert server.getMemory() > 0 : server;
|
||||
assert server.getDiskSize() > 0 : server;
|
||||
assert server.getMemorySize() > 0 : server;
|
||||
assert server.getCost() != null;
|
||||
assert server.getTransfer() > 0 : server;
|
||||
|
||||
assertNotNull(server.getTemplate());
|
||||
assertNotNull(server.getTemplateName());
|
||||
assertNotNull(server.getIps());
|
||||
}
|
||||
|
||||
|
@ -261,28 +261,18 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
|||
assertNotNull(status.getState());
|
||||
assertNotNull(status.getUptime());
|
||||
|
||||
assertNotNull(status.getBandwidth());
|
||||
assert status.getBandwidth().getToday() >= 0 : status;
|
||||
assert status.getBandwidth().getLast30Days() >= 0 : status;
|
||||
assert status.getBandwidth().getMax() >= 0 : status;
|
||||
|
||||
assertNotNull(status.getCpu());
|
||||
assert status.getCpu().getSystem() >= 0.0 : status;
|
||||
assert status.getCpu().getUser() >= 0.0 : status;
|
||||
if (status.getCpu().getNice() != null) {
|
||||
assert status.getCpu().getNice() >= 0.0 : status;
|
||||
for (ResourceUsage usage : new ResourceUsage[] { status.getCpu(), status.getDisk(), status.getMemory() }) {
|
||||
assertNotNull(usage);
|
||||
assert usage.getMax() >= 0.0 : status;
|
||||
if (usage.getUsage() != null) {
|
||||
assert usage.getUsage() >= 0.0 : status;
|
||||
}
|
||||
assertNotNull(usage.getUnit());
|
||||
}
|
||||
assert status.getCpu().getIdle() >= 0.0 : status;
|
||||
assertNotNull(status.getCpu().getUnit());
|
||||
|
||||
assertNotNull(status.getDisk());
|
||||
assert status.getDisk().getSize() >= 0 : status;
|
||||
assert status.getDisk().getUsed() >= 0 : status;
|
||||
assertNotNull(status.getDisk().getUnit());
|
||||
|
||||
assertNotNull(status.getMemory());
|
||||
assert status.getMemory().getSize() > 0 : status;
|
||||
assert status.getMemory().getUsage() >= 0 : status;
|
||||
assertNotNull(status.getMemory().getUnit());
|
||||
assertNotNull(status.getUptime());
|
||||
assert status.getUptime().getCurrent() > 0 : status;
|
||||
assertNotNull(status.getUptime().getUnit());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.ArchiveAllowedArguments;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerAllowedArgumentsTest")
|
||||
public class ParseArchiveAllowedArgumentsTest extends BaseItemParserTest<ArchiveAllowedArguments> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/archive_allowed_arguments.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("argumentslist")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ArchiveAllowedArguments expected() {
|
||||
return ArchiveAllowedArguments.builder().archiveSizes(new Integer[] {
|
||||
10,20,30,40,50,60,70,80,90,100,125,150,175,200,225,250,275,300,325,350,375,400,425,450,475,500,550,600,650,700,750,800,850,900,950,1000
|
||||
}).build();
|
||||
}
|
||||
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.ArchiveDetails;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseArchiveDetailsTest")
|
||||
public class ParseArchiveDetailsTest extends BaseItemParserTest<ArchiveDetails> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/archive_details.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ArchiveDetails expected() {
|
||||
return ArchiveDetails.builder().username("xxxxxx_test1").totalSize("30 GB").freeSize("30 GB").locked(false).build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Archive;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseArchiveListTest")
|
||||
public class ParseArchiveListTest extends BaseSetParserTest<Archive> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/archive_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("archives")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Archive> expected() {
|
||||
return ImmutableSet.of(Archive.builder().username("xxxxx_test1").totalSize("30 GB").freeSize("30 GB").locked(false).build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Domain;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseDomainListTest")
|
||||
public class ParseDomainListTest extends BaseSetParserTest<Domain> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/domain_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("domains")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Domain> expected() {
|
||||
Date creationTime = null;
|
||||
try {
|
||||
creationTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-12-20 10:58:51");
|
||||
} catch (ParseException e) {
|
||||
fail("Bad dates!");
|
||||
}
|
||||
Domain domain = Domain.builder().domain("adamlowe.net").createTime(creationTime).recordCount(9).glesysNameServer(false).build();
|
||||
return Sets.newHashSet(domain);
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.DomainRecord;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseDomainRecordListTest")
|
||||
public class ParseDomainRecordListTest extends BaseSetParserTest<DomainRecord> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/domain_list_records.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("records")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<DomainRecord> expected() {
|
||||
return ImmutableSortedSet.copyOf(
|
||||
Arrays.asList(
|
||||
DomainRecord.builder().id("213227").zone("adamlowe.net").host("@").type("NS").data("ns1.namesystem.se.").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213228").zone("adamlowe.net").host("@").type("NS").data("ns2.namesystem.se.").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213229").zone("adamlowe.net").host("@").type("NS").data("ns3.namesystem.se.").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213230").zone("adamlowe.net").host("@").type("A").data("127.0.0.1").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213231").zone("adamlowe.net").host("www").type("A").data("127.0.0.1").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213232").zone("adamlowe.net").host("mail").type("A").data("79.99.4.40").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213233").zone("adamlowe.net").host("@").type("MX").data("mx01.glesys.se.").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213234").zone("adamlowe.net").host("@").type("MX").data("mx02.glesys.se.").ttl(3600).build(),
|
||||
DomainRecord.builder().id("213235").zone("adamlowe.net").host("@").type("TXT").data("v=spf1 include:spf.glesys.se -all").ttl(3600).build()
|
||||
));
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Email;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseEmailListTest")
|
||||
public class ParseEmailListTest extends BaseSetParserTest<Email> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/email_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("emailaccounts")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Email> expected() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
Email.Builder builder = Email.builder().quota("200 MB").usedQuota("0 MB").antispamLevel(3).antiVirus(true).autoRespond(false).autoRespondSaveEmail(true).autoRespondMessage("false");
|
||||
try {
|
||||
return ImmutableSet.of(
|
||||
builder.account("test@adamlowe.net").created(dateFormat.parse("2011-12-22T12:13:14")).modified(dateFormat.parse("2011-12-22T12:13:35")).build(),
|
||||
builder.account("test2@adamlowe.net").created(dateFormat.parse("2011-12-22T12:14:29")).modified(dateFormat.parse("2011-12-22T12:14:31")).build()
|
||||
);
|
||||
} catch(ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.EmailOverview;
|
||||
import org.jclouds.glesys.domain.EmailOverviewDomain;
|
||||
import org.jclouds.glesys.domain.EmailOverviewSummary;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseEmailListTest")
|
||||
public class ParseEmailOverviewTest extends BaseItemParserTest<EmailOverview> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/email_overview.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("response")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public EmailOverview expected() {
|
||||
return EmailOverview.builder().summary(EmailOverviewSummary.builder().accounts(2).aliases(0).maxAccounts(50).maxAliases(1000).build()).domains(EmailOverviewDomain.builder().accounts(2).aliases(0).domain("adamlowe.net").build()).build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.*;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.ServerAllowedArguments;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerAllowedArgumentsTest")
|
||||
public class ParseServerAllowedArgumentsTest extends BaseItemParserTest<Map<String, ServerAllowedArguments>> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_allowed_arguments.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("argumentslist")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Map<String, ServerAllowedArguments> expected() {
|
||||
Map<String, ServerAllowedArguments> result = new LinkedHashMap<String, ServerAllowedArguments>();
|
||||
ServerAllowedArguments openvz = ServerAllowedArguments.builder()
|
||||
.dataCenters("Amsterdam", "Falkenberg", "New York City", "Stockholm")
|
||||
.memorySizes(128, 256, 512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288)
|
||||
.diskSizes(5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 150)
|
||||
.cpuCores(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
.templates("Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit", "Debian 5.0 32-bit",
|
||||
"Debian 5.0 64-bit", "Debian 6.0 32-bit", "Debian 6.0 64-bit", "Fedora Core 11", "Fedora Core 11 64-bit",
|
||||
"Gentoo", "Gentoo 64-bit", "Scientific Linux 6", "Scientific Linux 6 64-bit", "Slackware 12",
|
||||
"Ubuntu 10.04 LTS 32-bit", "Ubuntu 10.04 LTS 64-bit", "Ubuntu 11.04 64-bit")
|
||||
.transfers(50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000)
|
||||
.build();
|
||||
ServerAllowedArguments xen = ServerAllowedArguments.builder()
|
||||
.memorySizes(512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 14336, 16384)
|
||||
.diskSizes(5, 10, 20, 30, 40, 50, 80, 100, 120, 140, 150, 160, 160, 200, 250, 300)
|
||||
.cpuCores(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
.templates("CentOS 5.5 x64", "CentOS 5.5 x86", "Centos 6 x64", "Centos 6 x86", "Debian-6 x64",
|
||||
"Debian 5.0.1 x64", "FreeBSD 8.2", "Gentoo 10.1 x64", "Ubuntu 8.04 x64", "Ubuntu 10.04 LTS 64-bit",
|
||||
"Ubuntu 10.10 x64", "Ubuntu 11.04 x64", "Windows Server 2008 R2 x64 std",
|
||||
"Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web")
|
||||
.transfers(50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000)
|
||||
.dataCenters("Falkenberg")
|
||||
.build();
|
||||
result.put("Xen", xen);
|
||||
result.put("OpenVZ", openvz);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.ServerConsole;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerCreatedTest")
|
||||
public class ParseServerConsoleTest extends BaseItemParserTest<ServerConsole> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_console.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("remote")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ServerConsole expected() {
|
||||
return ServerConsole.builder().host("79.99.2.147").port(59478).password("1476897311").build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
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.Ip;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerCreatedTest")
|
||||
public class ParseServerCreatedTest extends BaseItemParserTest<ServerCreated> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_created.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ServerCreated expected() {
|
||||
return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(Ip.builder().ip("109.74.10.27").version4().cost(2.00).build()).build();
|
||||
}
|
||||
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
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.ServerDetails;
|
||||
import org.jclouds.glesys.domain.Ip;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerDetailsTest")
|
||||
public class ParseServerDetailsTest extends BaseItemParserTest<ServerDetails> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_details.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@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("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() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Cost;
|
||||
import org.jclouds.glesys.domain.ServerDetails;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerDetailsWithoutIPsTest")
|
||||
public class ParseServerDetailsWithoutIPsTest extends BaseItemParserTest<ServerDetails> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_noip.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ServerDetails expected() {
|
||||
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
||||
return ServerDetails.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ")
|
||||
.template("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memory(128).disk(5).transfer(50).cost(cost).build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Server;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerListTest")
|
||||
public class ParseServerListTest extends BaseSetParserTest<Server> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("servers")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Server> expected() {
|
||||
return ImmutableSet.of(Server.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg")
|
||||
.platform("OpenVZ").build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.Bandwidth;
|
||||
import org.jclouds.glesys.domain.Cpu;
|
||||
import org.jclouds.glesys.domain.Disk;
|
||||
import org.jclouds.glesys.domain.Memory;
|
||||
import org.jclouds.glesys.domain.ServerState;
|
||||
import org.jclouds.glesys.domain.ServerStatus;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerStatusTest")
|
||||
public class ParseServerStatusTest extends BaseItemParserTest<ServerStatus> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_status.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ServerStatus expected() {
|
||||
Bandwidth bandwidth = Bandwidth.builder().today(0).last30Days(0).max(50).build();
|
||||
Cpu cpu = Cpu.builder().unit("%").idle(100.0).system(0.0).user(0.0).nice(0.0).build();
|
||||
Disk disk = Disk.builder().unit("MB").size(0).used(0).build();
|
||||
Memory memory = Memory.builder().unit("MB").usage(3).size(128).build();
|
||||
return ServerStatus.builder().state(ServerState.RUNNING).uptime(38 * 60 + 6).bandwidth(bandwidth).
|
||||
cpu(cpu).disk(disk).memory(memory).build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.ServerTemplate;
|
||||
import org.jclouds.glesys.functions.ParseServerTemplatesFromHttpResponse;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseServerTemplatesTest")
|
||||
public class ParseServerTemplatesTest extends BaseSetParserTest<ServerTemplate> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/server_templates.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ResponseParser(ParseServerTemplatesFromHttpResponse.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<ServerTemplate> expected() {
|
||||
Builder<ServerTemplate> builder = ImmutableSet.<ServerTemplate> builder();
|
||||
|
||||
for (String name : new String[] { "Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit",
|
||||
"Debian 5.0 32-bit", "Debian 5.0 64-bit", "Debian 6.0 32-bit", "Debian 6.0 64-bit", "Fedora Core 11",
|
||||
"Fedora Core 11 64-bit", "Gentoo", "Gentoo 64-bit", "Scientific Linux 6", "Scientific Linux 6 64-bit",
|
||||
"Slackware 12", "Ubuntu 10.04 LTS 32-bit", "Ubuntu 10.04 LTS 64-bit", "Ubuntu 11.04 64-bit" }) {
|
||||
builder.add(new ServerTemplate(name, 5, 128, "linux", "OpenVZ"));
|
||||
}
|
||||
|
||||
for (String name : new String[] { "CentOS 5.5 x64", "CentOS 5.5 x86", "Centos 6 x64", "Centos 6 x86",
|
||||
"Debian-6 x64", "Debian 5.0.1 x64", "FreeBSD 8.2", "Gentoo 10.1 x64", "Ubuntu 8.04 x64",
|
||||
"Ubuntu 10.04 LTS 64-bit", "Ubuntu 10.10 x64", "Ubuntu 11.04 x64" }) {
|
||||
builder.add(new ServerTemplate(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen"));
|
||||
}
|
||||
for (String name : new String[] { "Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web",
|
||||
"Windows Server 2008 x64 web", "Windows Server 2008 x86 web" }) {
|
||||
builder.add(new ServerTemplate(name, 20, 1024, "windows", "Xen"));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||
import org.jclouds.glesys.domain.IpDetails;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @author Mattias Holmqvist
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseSimpleIpDetailsTest")
|
||||
public class ParseSimpleIpDetailsTest extends BaseItemParserTest<IpDetails> {
|
||||
|
||||
@Override
|
||||
protected String resource() {
|
||||
return "/ip_get_details.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public IpDetails expected() {
|
||||
|
||||
return IpDetails.builder()
|
||||
.datacenter("Falkenberg")
|
||||
.ipversion("4")
|
||||
.platform("OpenVZ")
|
||||
.ptr("31-192-227-37-static.serverhotell.net.").build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"argumentslist":{"Xen":{"disksize":["5","10","20","30","40","50","80","100","120","140","150","160","160","200","250","300"],"memorysize":["512","768","1024","1536","2048","2560","3072","3584","4096","5120","6144","7168","8192","9216","10240","11264","12288","14336","16384"],"cpucores":["1","2","3","4","5","6","7","8"],"template":["CentOS 5.5 x64","CentOS 5.5 x86","Centos 6 x64","Centos 6 x86","Debian-6 x64","Debian 5.0.1 x64","FreeBSD 8.2","Gentoo 10.1 x64","Ubuntu 8.04 x64","Ubuntu 10.04 LTS 64-bit","Ubuntu 10.10 x64","Ubuntu 11.04 x64","Windows Server 2008 R2 x64 std","Windows Server 2008 R2 x64 web","Windows Server 2008 x64 web","Windows Server 2008 x86 web"],"transfer":["50","100","250","500","1000","2000","3000","4000","5000","6000","7000","8000","9000","10000"],"datacenter":["Falkenberg"]},"OpenVZ":{"disksize":["5","10","20","30","40","50","60","70","80","90","100","120","140","150"],"memorysize":["128","256","512","768","1024","1536","2048","2560","3072","3584","4096","5120","6144","7168","8192","9216","10240","11264","12288"],"cpucores":["1","2","3","4","5","6","7","8"],"template":["Centos 5","Centos 5 64-bit","Centos 6 32-bit","Centos 6 64-bit","Debian 5.0 32-bit","Debian 5.0 64-bit","Debian 6.0 32-bit","Debian 6.0 64-bit","Fedora Core 11","Fedora Core 11 64-bit","Gentoo","Gentoo 64-bit","Scientific Linux 6","Scientific Linux 6 64-bit","Slackware 12","Ubuntu 10.04 LTS 32-bit","Ubuntu 10.04 LTS 64-bit","Ubuntu 11.04 64-bit"],"transfer":["50","100","250","500","1000","2000","3000","4000","5000","6000","7000","8000","9000","10000"],"datacenter":["Amsterdam","Falkenberg","New York City","Stockholm"]}},"debug":{"input":[]}}}
|
||||
{"response":{"status":{"code":200,"text":"OK"},"argumentslist":{"Xen":{"disksize":["5","10","20","30","40","50","80","100","120","140","150","160","160","200","250","300"],"memorysize":["512","768","1024","1536","2048","2560","3072","3584","4096","5120","6144","7168","8192","9216","10240","11264","12288","14336","16384"],"cpucores":["1","2","3","4","5","6","7","8"],"template":["CentOS 5.5 x64","CentOS 5.5 x86","Centos 6 x64","Centos 6 x86","Debian-6 x64","Debian 5.0.1 x64","FreeBSD 8.2","Gentoo 10.1 x64","Ubuntu 8.04 x64","Ubuntu 10.04 LTS 64-bit","Ubuntu 10.10 x64","Ubuntu 11.04 x64","Windows Server 2008 R2 x64 std","Windows Server 2008 R2 x64 web","Windows Server 2008 x64 web","Windows Server 2008 x86 web"],"transfer":["50","100","250","500","1000","2000","3000","4000","5000","6000","7000","8000","9000","10000"],"datacenter":["Falkenberg"]},"OpenVZ":{"disksize":["5","10","20","30","40","50","60","70","80","90","100","120","140","150"],"memorysize":["128","256","512","768","1024","1536","2048","2560","3072","3584","4096","5120","6144","7168","8192","9216","10240","11264","12288"],"cpucores":["1","2","3","4","5","6","7","8"],"template":["Centos 5","Centos 5 64-bit","Centos 6 32-bit","Centos 6 64-bit","Debian 5.0 32-bit","Debian 5.0 64-bit","Debian 6.0 32-bit","Debian 6.0 64-bit","Fedora Core 11","Fedora Core 11 64-bit","Gentoo","Gentoo 64-bit","Scientific Linux 6","Scientific Linux 6 64-bit","Slackware 12","Ubuntu 10.04 LTS 32-bit","Ubuntu 10.04 LTS 64-bit","Ubuntu 11.04 64-bit"],"transfer":["50","100","250","500","1000","2000","3000","4000","5000","6000","7000","8000","9000","10000"],"datacenter":["Amsterdam","Falkenberg","New York City","Stockholm"]}},"debug":{"input":[]}}}
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"remote":{"host":"79.99.2.147","port":"59478","password":"1476897311"},"debug":{"input":{"serverid":"vz1842554"}}}}
|
||||
{"response":{"status":{"code":"200","text":"OK"},"console":{"host":"79.99.2.147","port":"59478","protocol":"vnc","password":"1476897311"},"debug":{"input":{"serverid":"vz1842554"}}}}
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"server":{"serverid":"vz1375882","hostname":"jclouds-unit","description":"unit test server","cpucores":"1","memory":"128","disk":"5","transfer":"50","template":"Debian 6.0 64-bit","datacenter":"Falkenberg","managedhosting":"no","platform":"OpenVZ","cost":{"amount":6.38,"currency":"EUR","timeperiod":"month"},"iplist":[{"ip":"31.192.226.45","version":"4","cost":"2.00"}]},"debug":{"input":{"serverid":"vz1375882"}}}}
|
||||
{"response":{"status":{"code":"200","text":"OK"},"server":{"serverid":"vz1375882","hostname":"jclouds-unit","description":"unit test server","cpucores":"1","memorysize":"128","disksize":"5","transfer":"50","templatename":"Debian 6.0 64-bit","datacenter":"Falkenberg","managedhosting":"no","platform":"OpenVZ","cost":{"amount":6.38,"currency":"EUR","timeperiod":"month"},"iplist":[{"ip":"31.192.226.45","version":"4","cost":"2.00"}]},"debug":{"input":{"serverid":"vz1375882"}}}}
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"server":{"serverid":"vz1541880","hostname":"mammamia","description":"description","cpucores":"1","memory":"128","disk":"5","transfer":"50","template":"Ubuntu 11.04 64-bit","datacenter":"Falkenberg","managedhosting":"no","platform":"OpenVZ","cost":{"amount":6.38,"currency":"EUR","timeperiod":"month"},"iplist":[]},"debug":{"serverid":"vz1541880"}}}
|
||||
{"response":{"status":{"code":"200","text":"OK"},"server":{"serverid":"vz1541880","hostname":"mammamia","description":"description","cpucores":"1","memorysize":"128","disksize":"5","transfer":"50","templatename":"Ubuntu 11.04 64-bit","datacenter":"Falkenberg","managedhosting":"no","platform":"OpenVZ","cost":{"amount":6.38,"currency":"EUR","timeperiod":"month"},"iplist":[]},"debug":{"serverid":"vz1541880"}}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"server":{"state":"running","cpu":{"system":"0.00","user":"0.00","nice":"0.00","idle":"100.00","unit":"%"},"memory":{"memusage":"3","memsize":"128","unit":"MB"},"disk":{"diskused":372,"disksize":5120,"unit":"MB"},"bandwidth":{"today":0,"last30days":0,"max":"50"},"uptime":"0 0 0 0 0 38 6"},"debug":{"input":{"serverid":"vz1188183"}}}}
|
||||
{"response":{"status":{"code":200,"text":"OK"},"server":{"state":"running","cpu":{"usage":null,"max":"1","unit":"cores"},"memory":{"usage":"3","max":"128","unit":"MB"},"disk":{"usage":372,"max":5120,"unit":"MB"},"transfer":{"usage":0,"max":"50","unit":"GB last 30 days"},"uptime":{"current":108,"unit":"seconds"}},"debug":{"input":{"serverid":"vz1596078"}}}}
|
|
@ -1 +1 @@
|
|||
{"response":{"status":{"code":"200","text":"OK"},"templates":{"OpenVZ":[{"name":"Centos 5","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Centos 5 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Centos 6 32-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Centos 6 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Debian 5.0 32-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Debian 5.0 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Debian 6.0 32-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Debian 6.0 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Fedora Core 11","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Fedora Core 11 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Gentoo","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Gentoo 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Scientific Linux 6","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Scientific Linux 6 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Slackware 12","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Ubuntu 10.04 LTS 32-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Ubuntu 10.04 LTS 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"},{"name":"Ubuntu 11.04 64-bit","min_disk_size":"5","min_mem_size":"128","os":"linux","platform":"OpenVZ"}],"Xen":[{"name":"CentOS 5.5 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"CentOS 5.5 x86","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Centos 6 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Centos 6 x86","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Debian-6 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Debian 5.0.1 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"FreeBSD 8.2","min_disk_size":"5","min_mem_size":"512","os":"freebsd","platform":"Xen"},{"name":"Gentoo 10.1 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Ubuntu 8.04 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Ubuntu 10.04 LTS 64-bit","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Ubuntu 10.10 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Ubuntu 11.04 x64","min_disk_size":"5","min_mem_size":"512","os":"linux","platform":"Xen"},{"name":"Windows Server 2008 R2 x64 std","min_disk_size":"20","min_mem_size":"1024","os":"windows","platform":"Xen"},{"name":"Windows Server 2008 R2 x64 web","min_disk_size":"20","min_mem_size":"1024","os":"windows","platform":"Xen"},{"name":"Windows Server 2008 x64 web","min_disk_size":"20","min_mem_size":"1024","os":"windows","platform":"Xen"},{"name":"Windows Server 2008 x86 web","min_disk_size":"20","min_mem_size":"1024","os":"windows","platform":"Xen"}]},"debug":{"input":[]}}}
|
||||
{"response":{"status":{"code":200,"text":"OK"},"templates":{"OpenVZ":[{"name":"Centos 5","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Centos 5 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Centos 6 32-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Centos 6 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Debian 5.0 32-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Debian 5.0 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Debian 6.0 32-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Debian 6.0 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Fedora Core 11","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Fedora Core 11 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Gentoo","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Gentoo 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Scientific Linux 6","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Scientific Linux 6 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Slackware 12","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Ubuntu 10.04 LTS 32-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Ubuntu 10.04 LTS 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"},{"name":"Ubuntu 11.04 64-bit","minimumdisksize":"5","minimummemorysize":"128","operatingsystem":"linux","platform":"OpenVZ"}],"Xen":[{"name":"CentOS 5.5 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"CentOS 5.5 x86","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Centos 6 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Centos 6 x86","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Debian-6 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Debian 5.0.1 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"FreeBSD 8.2","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"freebsd","platform":"Xen"},{"name":"Gentoo 10.1 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Ubuntu 8.04 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Ubuntu 10.04 LTS 64-bit","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Ubuntu 10.10 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Ubuntu 11.04 x64","minimumdisksize":"5","minimummemorysize":"512","operatingsystem":"linux","platform":"Xen"},{"name":"Windows Server 2008 R2 x64 std","minimumdisksize":"20","minimummemorysize":"1024","operatingsystem":"windows","platform":"Xen"},{"name":"Windows Server 2008 R2 x64 web","minimumdisksize":"20","minimummemorysize":"1024","operatingsystem":"windows","platform":"Xen"},{"name":"Windows Server 2008 x64 web","minimumdisksize":"20","minimummemorysize":"1024","operatingsystem":"windows","platform":"Xen"},{"name":"Windows Server 2008 x86 web","minimumdisksize":"20","minimummemorysize":"1024","operatingsystem":"windows","platform":"Xen"}]},"debug":{"input":[]}}}
|
Loading…
Reference in New Issue