use of com.vmware.vim25.VirtualMachineSnapshotTree in project cloudstack by apache.
the class VirtualMachineMO method removeAllSnapshots.
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;
}
use of com.vmware.vim25.VirtualMachineSnapshotTree in project cloudstack by apache.
the class VmwareHelper method findSnapshotInTree.
public static ManagedObjectReference findSnapshotInTree(List<VirtualMachineSnapshotTree> snapTree, String findName) {
assert (findName != null);
ManagedObjectReference snapMor = null;
if (snapTree == null)
return snapMor;
for (int i = 0; i < snapTree.size() && snapMor == null; i++) {
VirtualMachineSnapshotTree node = snapTree.get(i);
if (node.getName().equals(findName)) {
snapMor = node.getSnapshot();
} else {
List<VirtualMachineSnapshotTree> childTree = node.getChildSnapshotList();
snapMor = findSnapshotInTree(childTree, findName);
}
}
return snapMor;
}
use of com.vmware.vim25.VirtualMachineSnapshotTree in project CloudStack-archive by CloudStack-extras.
the class VirtualMachineMO method removeAllSnapshots.
public boolean removeAllSnapshots() throws Exception {
VirtualMachineSnapshotInfo snapshotInfo = getSnapshotInfo();
if (snapshotInfo != null && snapshotInfo.getRootSnapshotList() != null) {
VirtualMachineSnapshotTree[] tree = snapshotInfo.getRootSnapshotList();
for (VirtualMachineSnapshotTree treeNode : tree) {
ManagedObjectReference morTask = _context.getService().removeSnapshot_Task(treeNode.getSnapshot(), true);
String result = _context.getServiceUtil().waitForTask(morTask);
if (result.equals("sucess")) {
_context.waitForTaskProgressDone(morTask);
} else {
s_logger.error("VMware removeSnapshot_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
return false;
}
}
}
return true;
}
use of com.vmware.vim25.VirtualMachineSnapshotTree in project CloudStack-archive by CloudStack-extras.
the class VmwareHelper method findSnapshotInTree.
public static ManagedObjectReference findSnapshotInTree(VirtualMachineSnapshotTree[] snapTree, String findName) {
assert (findName != null);
ManagedObjectReference snapMor = null;
if (snapTree == null)
return snapMor;
for (int i = 0; i < snapTree.length && snapMor == null; i++) {
VirtualMachineSnapshotTree node = snapTree[i];
if (node.getName().equals(findName)) {
snapMor = node.getSnapshot();
} else {
VirtualMachineSnapshotTree[] childTree = node.getChildSnapshotList();
snapMor = findSnapshotInTree(childTree, findName);
}
}
return snapMor;
}
use of com.vmware.vim25.VirtualMachineSnapshotTree in project photon-model by vmware.
the class VSphereVMSnapshotEnumerationHelper method processSnapshot.
static void processSnapshot(VSphereIncrementalEnumerationService service, VirtualMachineSnapshotTree current, String parentLink, EnumerationProgress enumerationProgress, VmOverlay vm, String vmSelfLink) {
enumerationProgress.getSnapshotTracker().register();
QueryTask task = queryForSnapshot(enumerationProgress, current.getId().toString(), vmSelfLink);
VsphereEnumerationHelper.withTaskResults(service, task, (ServiceDocumentQueryResult result) -> {
VsphereEnumerationHelper.submitWorkToVSpherePool(service, () -> {
SnapshotState snapshotState = constructSnapshot(service, current, parentLink, vmSelfLink, enumerationProgress, vm);
if (result.documentLinks.isEmpty()) {
VSphereVirtualMachineEnumerationHelper.createSnapshot(service, snapshotState).thenCompose(createdSnapshotState -> trackAndProcessChildSnapshots(service, current, enumerationProgress, vm, vmSelfLink, createdSnapshotState)).whenComplete((ss, e) -> {
if (e != null) {
service.log(Level.SEVERE, "Creation of snapshot with name {%s} failed.", snapshotState.name);
}
enumerationProgress.getSnapshotTracker().arrive();
});
} else {
SnapshotState oldState = VsphereEnumerationHelper.convertOnlyResultToDocument(result, SnapshotState.class);
updateSnapshot(service, enumerationProgress, vm, oldState, snapshotState, current.getId().toString()).thenCompose(updatedSnapshotState -> trackAndProcessChildSnapshots(service, current, enumerationProgress, vm, vmSelfLink, updatedSnapshotState)).whenComplete((ss, e) -> {
if (e != null) {
service.logSevere("Updating of snapshot with name {%s}, selfLink {%s} failed", snapshotState.name, oldState.documentSelfLink);
}
enumerationProgress.getSnapshotTracker().arrive();
});
}
});
});
}
Aggregations