Java 类com.vmware.vim25.mo.VirtualMachineSnapshot 实例源码

项目:jcloud-vsphere    文件:MasterToVirtualMachineCloneSpec.java   
private VirtualMachineSnapshot getCurrentSnapshotOrCreate(String snapshotName, String snapshotDescription,
                                                          VirtualMachine master) throws InvalidName, VmConfigFault, SnapshotFault, TaskInProgress, FileFault,
        InvalidState, RuntimeFault, RemoteException {
   if (master.getSnapshot() == null) {
      Task task = master.createSnapshot_Task(snapshotName, snapshotDescription, false, false);
      try {
         if (task.waitForTask().equals(Task.SUCCESS)) {
            logger.debug(String.format("snapshot taken for '%s'", master.getName()));
         }
      } catch (Exception e) {
         logger.debug(String.format("Can't take snapshot for '%s'", master.getName()), e);
         throw propagate(e);
      }
   } else
      logger.debug(String.format("snapshot already available for '%s'", master.getName()));
   return master.getCurrentSnapShot();
}
项目:vijava    文件:VMSnapshot.java   
static VirtualMachineSnapshot getSnapshotInTree(
    VirtualMachine vm, String snapName)
{
  if (vm == null || snapName == null) 
  {
    return null;
  }

  VirtualMachineSnapshotTree[] snapTree = 
      vm.getSnapshot().getRootSnapshotList();
  if(snapTree!=null)
  {
    ManagedObjectReference mor = findSnapshotInTree(
        snapTree, snapName);
    if(mor!=null)
    {
      return new VirtualMachineSnapshot(
          vm.getServerConnection(), mor);
    }
  }
  return null;
}
项目:WBSAirback    文件:HypervisorManagerVMware.java   
public void removeVirtualMachineSnapshot(VirtualMachine vm, String nameVm) throws Exception {
    logger.info("Launching old snapshot removing process for {}", nameVm);
    if(vm.getSnapshot() != null) {
        logger.info("Deleting snapshot ...");
        VirtualMachineSnapshotTree[] _stree = vm.getSnapshot().getRootSnapshotList();
        if(_stree != null) {
            for(VirtualMachineSnapshotTree _st : _stree) {
                if(_st.getName().equals(nameVm)) {
                    logger.info("Old snahpot {} found");
                    VirtualMachineSnapshot _vmsSnap = new VirtualMachineSnapshot(vm.getServerConnection(), _st.getSnapshot());
                    Task _taskSnap = _vmsSnap.removeSnapshot_Task(true);
                    logger.info("Removing process launched...");
                    if(_taskSnap.waitForTask() != Task.SUCCESS) {
                        logger.error("Error on snapshot removing process. {}",_taskSnap.getTaskInfo().getError().getLocalizedMessage());
                        throw new Exception(_taskSnap.getTaskInfo().getError().getLocalizedMessage());
                    }
                    logger.info("Snapshot removed successfully");
                }
            }
        }
    }
}