public boolean removeAllSnapshots() throws Exception { VirtualMachineSnapshotInfo snapshotInfo = getSnapshotInfo(); if (snapshotInfo != null && snapshotInfo.getRootSnapshotList() != null) { List<VirtualMachineSnapshotTree> tree = snapshotInfo.getRootSnapshotList(); for (VirtualMachineSnapshotTree treeNode : tree) { ManagedObjectReference morTask = _context.getService().removeSnapshotTask(treeNode.getSnapshot(), true, true); boolean result = _context.getVimClient().waitForTask(morTask); if (result) { _context.waitForTaskProgressDone(morTask); } else { s_logger.error("VMware removeSnapshot_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask)); return false; } } } return true; }
public ManagedObjectReference findSnapshot(String vmName, String snapshotId) throws Exception { ManagedObjectReference vm = getVirtualMachine(vmName); VirtualMachineSnapshotInfo info = (VirtualMachineSnapshotInfo) getServiceUtil() .getDynamicProperty(vm, PROPERTY_SNAPSHOT); if (info == null) { return null; } return searchSnapshot(info.getRootSnapshotList(), snapshotId); }
static void listSnapshots(VirtualMachine vm) { if(vm==null) { return; } VirtualMachineSnapshotInfo snapInfo = vm.getSnapshot(); VirtualMachineSnapshotTree[] snapTree = snapInfo.getRootSnapshotList(); printSnapshots(snapTree); }
public ManagedObjectReference getSnapshotMor(String snapshotName) throws Exception { VirtualMachineSnapshotInfo info = getSnapshotInfo(); if (info != null) { List<VirtualMachineSnapshotTree> snapTree = info.getRootSnapshotList(); return VmwareHelper.findSnapshotInTree(snapTree, snapshotName); } return null; }
public boolean hasSnapshot() throws Exception { VirtualMachineSnapshotInfo info = getSnapshotInfo(); if (info != null) { ManagedObjectReference currentSnapshot = info.getCurrentSnapshot(); if (currentSnapshot != null) { return true; } List<VirtualMachineSnapshotTree> rootSnapshotList = info.getRootSnapshotList(); if (rootSnapshotList != null && rootSnapshotList.size() > 0) { return true; } } return false; }
public VirtualMachineSnapshotInfo getSnapshotInfo() throws Exception { return (VirtualMachineSnapshotInfo)_context.getVimClient().getDynamicProperty(_mor, "snapshot"); }