@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()); } });
@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 }
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()); } } }