Search in sources :

Example 6 with VirtualMachineSnapshotTree

use of com.vmware.vim25.VirtualMachineSnapshotTree in project vsphere-cloud-plugin by jenkinsci.

the class VSphere method getSnapshotInTree.

public VirtualMachineSnapshot getSnapshotInTree(VirtualMachine vm, String snapName) {
    if (vm == null || snapName == null) {
        return null;
    }
    LOGGER.log(Level.FINER, "Looking for snapshot " + snapName + " in " + vm.getName());
    VirtualMachineSnapshotInfo info = vm.getSnapshot();
    if (info != null) {
        VirtualMachineSnapshotTree[] snapTree = info.getRootSnapshotList();
        if (snapTree != null) {
            ManagedObjectReference mor = findSnapshotInTree(snapTree, snapName);
            if (mor != null) {
                return new VirtualMachineSnapshot(vm.getServerConnection(), mor);
            }
        }
    }
    return null;
}
Also used : VirtualMachineSnapshotInfo(com.vmware.vim25.VirtualMachineSnapshotInfo) VirtualMachineSnapshot(com.vmware.vim25.mo.VirtualMachineSnapshot) VirtualMachineSnapshotTree(com.vmware.vim25.VirtualMachineSnapshotTree) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 7 with VirtualMachineSnapshotTree

use of com.vmware.vim25.VirtualMachineSnapshotTree in project cloudstack by apache.

the class VirtualMachineMO method hasSnapshot.

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;
}
Also used : VirtualMachineSnapshotInfo(com.vmware.vim25.VirtualMachineSnapshotInfo) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) VirtualMachineSnapshotTree(com.vmware.vim25.VirtualMachineSnapshotTree)

Aggregations

VirtualMachineSnapshotTree (com.vmware.vim25.VirtualMachineSnapshotTree)7 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)6 VirtualMachineSnapshotInfo (com.vmware.vim25.VirtualMachineSnapshotInfo)4 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)3 ComputeEnumerateResourceRequest (com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest)1 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 SnapshotState (com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState)1 VirtualMachineSnapshot (com.vmware.vim25.mo.VirtualMachineSnapshot)1 DeferredResult (com.vmware.xenon.common.DeferredResult)1 Operation (com.vmware.xenon.common.Operation)1 ServiceDocumentQueryResult (com.vmware.xenon.common.ServiceDocumentQueryResult)1 UriUtils (com.vmware.xenon.common.UriUtils)1 QueryTask (com.vmware.xenon.services.common.QueryTask)1 Builder (com.vmware.xenon.services.common.QueryTask.Query.Builder)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Level (java.util.logging.Level)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1