@Override public void suspendNode(final String id) { final DataCenterAndId datacenterAndId = DataCenterAndId.fromSlashEncoded(id); final ServerInDataCenter node = getRequiredNode(id); // Intentionally didn't include SHUTDOWN (only achieved via UI; soft-shutdown). // A SHUTOFF server is no longer billed, so we execute method for all other status if (node.getServer().properties().vmState() == Server.Status.SHUTOFF) { return; } provisioningManager.provision( jobFactory.create( datacenterAndId.getDataCenter(), new Supplier<Object>() { @Override public Object get() { URI requestStatusURI = api.serverApi() .stopServer(datacenterAndId.getDataCenter(), datacenterAndId.getId()); trackables.waitUntilRequestCompleted(requestStatusURI); waitServerUntilSuspended.apply( ServerRef.create(datacenterAndId.getDataCenter(), datacenterAndId.getId())); return node; } })); }
@Override public void resumeNode(final String id) { final DataCenterAndId datacenterAndId = DataCenterAndId.fromSlashEncoded(id); final ServerInDataCenter node = getRequiredNode(id); if (node.getServer().properties().vmState() == Server.Status.RUNNING) { return; } provisioningManager.provision( jobFactory.create( datacenterAndId.getDataCenter(), new Supplier<Object>() { @Override public Object get() { URI requestStatusURI = api.serverApi() .startServer(datacenterAndId.getDataCenter(), datacenterAndId.getId()); trackables.waitUntilRequestCompleted(requestStatusURI); waitServerUntilRunning.apply( ServerRef.create(datacenterAndId.getDataCenter(), datacenterAndId.getId())); return node; } })); }