本文整理汇总了Java中com.vmware.vim25.mo.VirtualMachine.getSnapshot方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachine.getSnapshot方法的具体用法?Java VirtualMachine.getSnapshot怎么用?Java VirtualMachine.getSnapshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.mo.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.getSnapshot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentSnapshotOrCreate
import com.vmware.vim25.mo.VirtualMachine; //导入方法依赖的package包/类
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();
}
示例2: removeVirtualMachineSnapshot
import com.vmware.vim25.mo.VirtualMachine; //导入方法依赖的package包/类
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");
}
}
}
}
}
示例3: listSnapshots
import com.vmware.vim25.mo.VirtualMachine; //导入方法依赖的package包/类
static void listSnapshots(VirtualMachine vm)
{
if(vm==null)
{
return;
}
VirtualMachineSnapshotInfo snapInfo = vm.getSnapshot();
VirtualMachineSnapshotTree[] snapTree =
snapInfo.getRootSnapshotList();
printSnapshots(snapTree);
}