public T fromServerExtendedStatus(ServerExtendedStatus in) { return this .taskState(in.getTaskState()) .vmState(in.getVmState()) .powerState(in.getPowerState()); } }
public ServerExtendedStatus build() { return new ServerExtendedStatus(taskState, vmState, powerState); }
@Override public String toString() { return string().toString(); }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.class)); } Server.Builder<?> result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { result.extendedStatus(extendedStatus); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
/** * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded * this will continue to block while any task is in progress. */ protected void blockUntilServerInState(String serverId, ServerApi api, Status status) { Server currentDetails = null; for (currentDetails = api.get(serverId); currentDetails.getStatus() != status || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get() .getTaskState() != null)); currentDetails = api.get(serverId)) { System.out.printf("blocking on status %s%n%s%n", status, currentDetails); try { Thread.sleep(5 * 1000); } catch (InterruptedException e) { throw Throwables.propagate(e); } } }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.class)); } Server.Builder<?> result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { result.extendedStatus(extendedStatus); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
/** * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded * this will continue to block while any task is in progress. */ protected void blockUntilServerInState(String serverId, ServerApi api, Status status) { Server currentDetails = null; for (currentDetails = api.get(serverId); currentDetails.getStatus() != status || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get() .getTaskState() != null)); currentDetails = api.get(serverId)) { System.out.printf("blocking on status %s%n%s%n", status, currentDetails); try { Thread.sleep(15 * 1000); } catch (InterruptedException e) { throw Throwables.propagate(e); } } }
public T fromServerExtendedStatus(ServerExtendedStatus in) { return this .taskState(in.getTaskState()) .vmState(in.getVmState()) .powerState(in.getPowerState()); } }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); Server.Builder<?> result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { result.extendedStatus(extendedStatus); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
@Override public String toString() { return string().toString(); }
public ServerExtendedStatus build() { return new ServerExtendedStatus(taskState, vmState, powerState); }
public T fromServerExtendedStatus(ServerExtendedStatus in) { return this .taskState(in.getTaskState()) .vmState(in.getVmState()) .powerState(in.getPowerState()); } }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); Server.Builder<?> result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { result.extendedStatus(extendedStatus); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
@Override public String toString() { return string().toString(); }
public ServerExtendedStatus build() { return new ServerExtendedStatus(taskState, vmState, powerState); }
public T fromServerExtendedStatus(ServerExtendedStatus in) { return this .taskState(in.getTaskState()) .vmState(in.getVmState()) .powerState(in.getPowerState()); } }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.class)); } Server.Builder<?> result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { result.extendedStatus(extendedStatus); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
@Override public String toString() { return string().toString(); }
public ServerExtendedStatus build() { return new ServerExtendedStatus(taskState, vmState, powerState); }
public T fromServerExtendedStatus(ServerExtendedStatus in) { return this .taskState(in.getTaskState()) .vmState(in.getVmState()) .powerState(in.getPowerState()); } }