@Override public boolean apply(Integer input) { checkNotNull(input, "action id cannot be null"); Action current = api.actionApi().get(input); switch (current.status()) { case COMPLETED: return true; case IN_PROGRESS: return false; case ERRORED: default: throw new IllegalStateException("Resource is in invalid status: " + current.status().name()); } }
private static Action action(Action.Status status) { return Action.create(1, status, "foo", new Date(), new Date(), 1, "", null, ""); } }
@Override public boolean apply(Action input) { return "snapshot".equals(input.type()); } }));
@Override public Image call() throws Exception { if (imageAvailablePredicate.apply(snapshotEvent.id())) { org.jclouds.digitalocean2.domain.Image snapshot = api.imageApi().list().concat() .firstMatch(new Predicate<org.jclouds.digitalocean2.domain.Image>() { @Override public boolean apply(org.jclouds.digitalocean2.domain.Image input) { return input.name().equals(cloneTemplate.getName()); } }).get(); return imageTransformer.apply(ImageInRegion.create(snapshot, droplet.region().slug())); } throw new UncheckedTimeoutException("Image was not created within the time limit: " + cloneTemplate.getName()); } });
@Override public Image call() throws Exception { if (imageAvailablePredicate.apply(snapshotEvent.id())) { org.jclouds.digitalocean2.domain.Image snapshot = api.imageApi().list().concat() .firstMatch(new Predicate<org.jclouds.digitalocean2.domain.Image>() { @Override public boolean apply(org.jclouds.digitalocean2.domain.Image input) { return input.name().equals(cloneTemplate.getName()); } }).get(); return imageTransformer.apply(ImageInRegion.create(snapshot, droplet.region().slug())); } throw new UncheckedTimeoutException("Image was not created within the time limit: " + cloneTemplate.getName()); } });
@Override public Image call() throws Exception { if (imageAvailablePredicate.apply(snapshotEvent.id())) { org.jclouds.digitalocean2.domain.Image snapshot = api.imageApi().list().concat() .firstMatch(new Predicate<org.jclouds.digitalocean2.domain.Image>() { @Override public boolean apply(org.jclouds.digitalocean2.domain.Image input) { return input.name().equals(cloneTemplate.getName()); } }).get(); return imageTransformer.apply(ImageInRegion.create(snapshot, droplet.region().slug())); } throw new UncheckedTimeoutException("Image was not created within the time limit: " + cloneTemplate.getName()); } });
@Override public boolean apply(Integer input) { checkNotNull(input, "action id cannot be null"); Action current = api.actionApi().get(input); switch (current.status()) { case COMPLETED: return true; case IN_PROGRESS: return false; case ERRORED: default: throw new IllegalStateException("Resource is in invalid status: " + current.status().name()); } }
@Override public boolean apply(Action input) { found.incrementAndGet(); return !isNullOrEmpty(input.type()); } }), "All actions must have the 'type' field populated");
@Test(groups = "live", dependsOnMethods = "testPowerCycle") public void testShutdown() { Action action = api().shutdown(dropletId); assertActionCompleted(action.id()); // The shutdown action can fail if the shutdown command fails in the guest OS // We can not guarantee that a graceful shutdown action will en up in the droplet // being in OFF state }
@Override public boolean apply(Integer input) { checkNotNull(input, "action id cannot be null"); Action current = api.actionApi().get(input); switch (current.status()) { case COMPLETED: return true; case IN_PROGRESS: return false; case ERRORED: default: throw new IllegalStateException("Resource is in invalid status: " + current.status().name()); } }
@Override public boolean apply(Action input) { found.incrementAndGet(); return !isNullOrEmpty(input.type()); } }), "All actions must have the 'type' field populated");
public void testGetAction() { Optional<Action> first = api().list().concat().first(); assertTrue(first.isPresent(), "At least one action was expected to exist"); assertNotNull(api().get(first.get().id())); }
@Test(groups = "live", dependsOnMethods = "testReboot") public void testPowerCycle() { Action action = api().powerCycle(dropletId); assertActionCompleted(action.id()); assertNodeRunning(dropletId); }
@Test(groups = "live", dependsOnMethods = "testSnapshots") public void testReboot() { Action action = api().reboot(dropletId); assertActionCompleted(action.id()); assertNodeRunning(dropletId); }
@Test(groups = "live", dependsOnMethods = "testPowerOn") public void testSnapshots() { Action action = api().snapshot(dropletId, prefix + dropletId + "-snapshot"); assertActionCompleted(action.id()); List<Snapshot> snapshots = api().listSnapshots(dropletId).concat().toList(); assertEquals(snapshots.size(), 1, "Must contain 1 snapshot"); for (Snapshot snapshot : snapshots) { try { api.imageApi().delete(snapshot.id()); } catch (Exception ex) { getAnonymousLogger().warning("Could not delete snapshot: " + snapshot.id()); } } }