added waitForCompletion on snapshot creation and deletion has multi-node was failing

This commit is contained in:
David Ribeiro Alves 2012-03-15 02:57:22 +00:00
parent 6967743044
commit ec7552cdbb
2 changed files with 4 additions and 1 deletions

View File

@ -47,6 +47,7 @@ import org.jclouds.virtualbox.statements.SetIpAddress;
import org.jclouds.virtualbox.util.MachineUtils;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.IProgress;
import org.virtualbox_4_1.ISession;
import org.virtualbox_4_1.NetworkAttachmentType;
import org.virtualbox_4_1.VirtualBoxManager;
@ -116,7 +117,8 @@ public class NodeCreator implements Function<NodeSpec, NodeAndInitialCredentials
} catch (Exception e) {
throw new RuntimeException("error opening vbox machine session: " + e.getMessage(), e);
}
session.getConsole().deleteSnapshot(master.getMachine().getCurrentSnapshot().getId());
IProgress progress = session.getConsole().deleteSnapshot(master.getMachine().getCurrentSnapshot().getId());
progress.waitForCompletion(-1);
session.unlockMachine();
}
String masterNameWithoutPrefix = master.getSpec().getVmSpec().getVmName().replace(VIRTUALBOX_IMAGE_PREFIX, "");

View File

@ -64,6 +64,7 @@ public class TakeSnapshotIfNotAlreadyAttached implements Function<IMachine, ISna
try {
session = manager.get().openMachineSession(machine);
IProgress progress = session.getConsole().takeSnapshot(snapshotName, snapshotDesc);
progress.waitForCompletion(-1);
if (progress.getCompleted())
logger.debug("Snapshot %s (description: %s) taken from %s", snapshotName, snapshotDesc, machine.getName());
} catch (Exception e) {