Skip to content

Instantly share code, notes, and snippets.

@lundvall
Created April 13, 2012 09:23
Show Gist options
  • Save lundvall/2375388 to your computer and use it in GitHub Desktop.
Save lundvall/2375388 to your computer and use it in GitHub Desktop.
ManagedObjectReference currentSnapshot;
public void printCurrentSnapshotName() {
VirtualMachineSnapshotInfo snapshotInfo = vm.getSnapshot();
if (snapshotInfo != null) {
currentSnapshot = snapshotInfo.currentSnapshot;
walkSnapshotTree(snapshotInfo.rootSnapshotList);
}
}
private void walkSnapshotTree(VirtualMachineSnapshotTree[] snapshotTree) {
for (VirtualMachineSnapshotTree snapshot : snapshotTree) {
if (snapshot.snapshot.equals(currentSnapshot)) {
System.out.println("Name: " + snapshot.name);
} else if (snapshot.childSnapshotList != null) {
walkSnapshotTree(snapshot.childSnapshotList);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment