glesys now returns server state in create response

This commit is contained in:
Adrian Cole 2012-02-15 00:40:51 +01:00
parent 73cc4a0837
commit 95935f861c
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)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSizeGB(), true, true)))
.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>() {
@Override

View File

@ -68,20 +68,7 @@ public class ServerDetailsToNodeMetadataTest extends BaseGleSYSComputeServiceExp
HttpResponse
.builder()
.statusCode(200)
.payload(
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"))
.payload(payloadFromResource("/server_details.json"))
.build()).build()
).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();
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")
.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

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"}}}}