glesys now returns server state in create response

This commit is contained in:
Adrian Cole 2012-02-15 00:40:51 +01:00
parent e88a32a75d
commit 0dad59cc42
4 changed files with 4 additions and 17 deletions

View File

@ -109,7 +109,7 @@ public class ServerDetailsToNodeMetadata implements Function<ServerDetails, Node
.processors(ImmutableList.of(new Processor(from.getCpuCores(), 1.0))) .processors(ImmutableList.of(new Processor(from.getCpuCores(), 1.0)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSizeGB(), true, true))) .volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSizeGB(), true, true)))
.hypervisor(from.getPlatform()).build()); .hypervisor(from.getPlatform()).build());
builder.state(from.getState() != null ? serverStateToNodeState.get(from.getState()) : NodeState.PENDING); builder.state(serverStateToNodeState.get(from.getState()));
Iterable<String> addresses = Iterables.filter(Iterables.transform(from.getIps(), new Function<Ip, String>() { Iterable<String> addresses = Iterables.filter(Iterables.transform(from.getIps(), new Function<Ip, String>() {
@Override @Override

View File

@ -68,20 +68,7 @@ public class ServerDetailsToNodeMetadataTest extends BaseGleSYSComputeServiceExp
HttpResponse HttpResponse
.builder() .builder()
.statusCode(200) .statusCode(200)
.payload( .payload(payloadFromResource("/server_details.json"))
payloadFromString("{\"response\":{\"status\":{\"code\":200,\"timestamp\":\"2012-02-10T11:28:50+01:00\",\"text\":\"OK\"},\"server\":{\"state\":\"running\"},\"debug\":{\"input\":{\"serverid\":\"xm3276891\",\"statustype\":\"state\"}}}}"))
.build())
.put(HttpRequest
.builder()
.method("POST")
.endpoint(URI.create("https://api.glesys.com/server/status/format/json"))
.headers(
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
.payload(
newUrlEncodedFormPayload(ImmutableMultimap.<String, String> builder()
.put("serverid", "xm3276891").put("statustype", "state").build())).build(),
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json"))
.build()).build() .build()).build()
).getInstance(ServerDetailsToNodeMetadata.class); ).getInstance(ServerDetailsToNodeMetadata.class);

View File

@ -159,7 +159,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
Cost cost = Cost.builder().amount(13.22).currency("EUR").timePeriod("month").build(); Cost cost = Cost.builder().amount(13.22).currency("EUR").timePeriod("month").build();
return ServerDetails.builder().id("xm3276891").transferGB(50).hostname("glesys-s-6dd").cpuCores(1).memorySizeMB(512) return ServerDetails.builder().id("xm3276891").transferGB(50).hostname("glesys-s-6dd").cpuCores(1).memorySizeMB(512)
.diskSizeGB(5).description("glesys-s-6dd").datacenter("Falkenberg").platform("Xen") .diskSizeGB(5).description("glesys-s-6dd").datacenter("Falkenberg").platform("Xen")
.templateName("Ubuntu 11.04 x64").cost(cost).ips(ip).build(); .templateName("Ubuntu 11.04 x64").state(Server.State.LOCKED).cost(cost).ips(ip).build();
} }
@Test @Test

View File

@ -1 +1 @@
{"response":{"status":{"code":200,"timestamp":"2012-02-10T11:11:05+01:00","text":"OK"},"server":{"serverid":"xm3276891","hostname":"glesys-s-6dd","description":"glesys-s-6dd","cpucores":1,"memorysize":512,"disksize":5,"transfer":50,"templatename":"Ubuntu 11.04 x64","datacenter":"Falkenberg","managedhosting":"no","platform":"Xen","cost":{"amount":13.22,"currency":"EUR","timeperiod":"month"},"iplist":[{"ipaddress":"109.74.10.45","version":4,"cost":2,"currency":"EUR"}]},"debug":{"input":{"serverid":"xm3276891"}}}} {"response":{"status":{"code":200,"timestamp":"2012-02-10T11:11:05+01:00","text":"OK"},"server":{"serverid":"xm3276891","hostname":"glesys-s-6dd","description":"glesys-s-6dd","cpucores":1,"memorysize":512,"disksize":5,"transfer":50,"templatename":"Ubuntu 11.04 x64","datacenter":"Falkenberg","managedhosting":"no","platform":"Xen","cost":{"amount":13.22,"currency":"EUR","timeperiod":"month"},"iplist":[{"ipaddress":"109.74.10.45","version":4,"cost":2,"currency":"EUR"}], "state":"locked"},"debug":{"input":{"serverid":"xm3276891"}}}}