mirror of https://github.com/apache/jclouds.git
GleSYS provider: standardizing on memorySizeMB, diskSizeGB and transferGB
This commit is contained in:
parent
78c7b91c8a
commit
8c7ef457c6
|
@ -42,9 +42,9 @@ public class ServerDetails extends Server {
|
|||
private String description;
|
||||
private String templateName;
|
||||
private int cpuCores;
|
||||
private int memorySize;
|
||||
private int diskSize;
|
||||
private int transfer;
|
||||
private int memorySizeMB;
|
||||
private int diskSizeGB;
|
||||
private int transferGB;
|
||||
private Cost cost;
|
||||
private List<Ip> ips;
|
||||
|
||||
|
@ -63,18 +63,18 @@ public class ServerDetails extends Server {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder memorySize(int memorySize) {
|
||||
this.memorySize = memorySize;
|
||||
public Builder memorySizeMB(int memorySizeMB) {
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder diskSize(int diskSize) {
|
||||
this.diskSize = diskSize;
|
||||
public Builder diskSizeGB(int diskSizeGB) {
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder transfer(int transfer) {
|
||||
this.transfer = transfer;
|
||||
public Builder transferGB(int transferGB) {
|
||||
this.transferGB = transferGB;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,12 @@ public class ServerDetails extends Server {
|
|||
}
|
||||
|
||||
public ServerDetails build() {
|
||||
return new ServerDetails(id, hostname, datacenter, platform, templateName, description, cpuCores, memorySize, diskSize, transfer, cost, ips);
|
||||
return new ServerDetails(id, hostname, datacenter, platform, templateName, description, cpuCores, memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||
}
|
||||
|
||||
public Builder fromServerDetails(ServerDetails in) {
|
||||
return fromServer(in).templateName(in.getTemplateName()).memorySize(in.getMemorySizeMB()).diskSize(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||
.description(in.getDescription()).ips(in.getIps());
|
||||
return fromServer(in).templateName(in.getTemplateName()).memorySizeMB(in.getMemorySizeMB()).diskSizeGB(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||
.transferGB(in.getTransferGB()).description(in.getDescription()).ips(in.getIps());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,23 +133,24 @@ public class ServerDetails extends Server {
|
|||
@SerializedName("cpucores")
|
||||
private final int cpuCores;
|
||||
@SerializedName("memorysize")
|
||||
private final int memorySize;
|
||||
private final int memorySizeMB;
|
||||
@SerializedName("disksize")
|
||||
private final int diskSize;
|
||||
private final int transfer;
|
||||
private final int diskSizeGB;
|
||||
@SerializedName("transfer")
|
||||
private final int transferGB;
|
||||
private final Cost cost;
|
||||
@SerializedName("iplist")
|
||||
private final 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) {
|
||||
String description, int cpuCores, int memorySizeMB, int diskSizeGB, int transferGB, Cost cost, List<Ip> ips) {
|
||||
super(id, hostname, datacenter, platform);
|
||||
this.templateName = checkNotNull(templateName, "template");
|
||||
this.description = description;
|
||||
this.cpuCores = cpuCores;
|
||||
this.memorySize = memorySize;
|
||||
this.diskSize = diskSize;
|
||||
this.transfer = transfer;
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
this.transferGB = transferGB;
|
||||
this.cost = checkNotNull(cost, "cost");
|
||||
this.ips = ips == null ? ImmutableList.<Ip>of() : ips;
|
||||
}
|
||||
|
@ -172,21 +173,21 @@ public class ServerDetails extends Server {
|
|||
* @return the disk of the server in GB
|
||||
*/
|
||||
public int getDiskSizeGB() {
|
||||
return diskSize;
|
||||
return diskSizeGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory of the server in MB
|
||||
*/
|
||||
public int getMemorySizeMB() {
|
||||
return memorySize;
|
||||
return memorySizeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the transfer of the server
|
||||
*/
|
||||
public int getTransferGB() {
|
||||
return transfer;
|
||||
return transferGB;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,8 +214,8 @@ public class ServerDetails extends Server {
|
|||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"[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);
|
||||
"[id=%s, hostname=%s, datacenter=%s, platform=%s, templateName=%s, description=%s, cpuCores=%d, memorySizeMB=%d, diskSizeGB=%d, transferGB=%d, cost=%s, ips=%s]", id,
|
||||
hostname, datacenter, platform, templateName, description, cpuCores, memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,31 +24,31 @@ package org.jclouds.glesys.options;
|
|||
public class CloneServerOptions extends EditServerOptions {
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#disksize
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#diskSizeGB
|
||||
*/
|
||||
public static CloneServerOptions disksize(int disksize) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().disksize(disksize));
|
||||
public static CloneServerOptions diskSizeGB(int diskSizeGB) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().diskSizeGB(diskSizeGB));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#memorysize
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#memorySizeMB
|
||||
*/
|
||||
public static CloneServerOptions memorysize(int memorysize) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().memorysize(memorysize));
|
||||
public static CloneServerOptions memorySizeMB(int memorySizeMB) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().memorySizeMB(memorySizeMB));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#cpucores
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#cpuCores
|
||||
*/
|
||||
public static CloneServerOptions cpucores(int cpucores) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().cpucores(cpucores));
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().cpuCores(cpucores));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#cpucores
|
||||
* @see org.jclouds.glesys.options.CloneServerOptions#transferGB
|
||||
*/
|
||||
public static CloneServerOptions transfer(int transfer) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().transfer(transfer));
|
||||
public static CloneServerOptions transferGB(int transferGB) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().transferGB(transferGB));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,35 +28,32 @@ public class EditServerOptions extends BaseHttpRequestOptions {
|
|||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#disksize
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#diskSizeGB
|
||||
*/
|
||||
public static EditServerOptions disksize(int disksize) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
return options.disksize(disksize);
|
||||
public static EditServerOptions disksizeGB(int disksizeGB) {
|
||||
return new EditServerOptions().diskSizeGB(disksizeGB);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#memorysize
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#memorySizeMB
|
||||
*/
|
||||
public static EditServerOptions memorysize(int memorysize) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
return options.memorysize(memorysize);
|
||||
public static EditServerOptions memorysizeMB(int memorysizeMB) {
|
||||
return new EditServerOptions().memorySizeMB(memorysizeMB);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#cpucores
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#cpuCores
|
||||
*/
|
||||
public static EditServerOptions cpucores(int cpucores) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
return options.cpucores(cpucores);
|
||||
return options.cpuCores(cpucores);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#cpucores
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#transferGB
|
||||
*/
|
||||
public static EditServerOptions transfer(int transfer) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
return options.transfer(transfer);
|
||||
public static EditServerOptions transferGB(int transferGB) {
|
||||
return new EditServerOptions().transferGB(transferGB);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,26 +74,26 @@ public class EditServerOptions extends BaseHttpRequestOptions {
|
|||
}
|
||||
|
||||
/** Configure the size of the disk, in GB, of the server */
|
||||
public EditServerOptions disksize(int disksize) {
|
||||
formParameters.put("disksize", Integer.toString(disksize));
|
||||
public EditServerOptions diskSizeGB(int diskSizeGB) {
|
||||
formParameters.put("disksize", Integer.toString(diskSizeGB));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the amount of RAM, in MB, allocated to the server */
|
||||
public EditServerOptions memorysize(int memorysize) {
|
||||
formParameters.put("memorysize", Integer.toString(memorysize));
|
||||
public EditServerOptions memorySizeMB(int memorySizeMB) {
|
||||
formParameters.put("memorysize", Integer.toString(memorySizeMB));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the number of CPU cores allocated to the server */
|
||||
public EditServerOptions cpucores(int cpucores) {
|
||||
public EditServerOptions cpuCores(int cpucores) {
|
||||
formParameters.put("cpucores", Integer.toString(cpucores));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the transfer setting for the server */
|
||||
public EditServerOptions transfer(int transfer) {
|
||||
formParameters.put("cpucores", Integer.toString(transfer));
|
||||
public EditServerOptions transferGB(int transferGB) {
|
||||
formParameters.put("transfer", Integer.toString(transferGB));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,8 +156,8 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
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")
|
||||
return ServerDetails.builder().id("vz1375882").transferGB(50).hostname("jclouds-unit").cpuCores(1).memorySizeMB(128)
|
||||
.diskSizeGB(5).description("unit test server").datacenter("Falkenberg").platform("OpenVZ")
|
||||
.templateName("Debian 6.0 64-bit").cost(cost).ips(ip).build();
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
|
||||
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();
|
||||
.templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySizeMB(128).diskSizeGB(5).transferGB(50).cost(cost).build();
|
||||
|
||||
assertEquals(
|
||||
client.createServerWithHostnameAndRootPassword(
|
||||
|
@ -267,7 +267,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
HttpResponse.builder().statusCode(200).build()).getServerClient();
|
||||
|
||||
EditServerOptions options =
|
||||
EditServerOptions.Builder.description("Description-of-server").disksize(1).memorysize(512).cpucores(1).hostname("jclouds-test");
|
||||
EditServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test");
|
||||
|
||||
client.editServer("server111", options);
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
|||
.put("memorysize", "512")
|
||||
.put("cpucores", "1").build())).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||
CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").disksize(1).memorysize(512).cpucores(1);
|
||||
CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1);
|
||||
|
||||
assertEquals(client.cloneServer("server111", "hostname1", options), expectedServerDetails());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue