위는 간단한 다음 두 가지 방법으로 수행 할 수 있습니다
public bool CreateSnapShot(string vmName, string snapShotName, string snapShotDescription, bool replaceSnapShot, string currentSnapShotName)
{
try
{
NameValueCollection filter = new NameValueCollection();
filter.Add(Constants.VM_FILTER_NAME, vmName);
ManagedObjectReference snapShotMor = null;
VirtualMachine vmObject = (VirtualMachine) vimClient.FindEntityViews(typeof(VirtualMachine), null, filter, null).FirstOrDefault();
if (vmObject != null)
{
if (vmObject.Runtime.PowerState == VirtualMachinePowerState.poweredOn)
vmObject.ShutdownGuest();
while (vmObject.Runtime.PowerState == VirtualMachinePowerState.poweredOn)
{
Thread.Sleep(5000);
vmObject.UpdateViewData();//This will refresh VM object state
}
if (replaceSnapShot && currentSnapShotName!= "")
{
if (RenameSnapshot(snapShotName, vmObject))
snapShotMor = vmObject.CreateSnapshot(snapShotName, snapShotDescription, false, false);
}
else snapShotMor = vmObject.CreateSnapshot(snapShotName, snapShotDescription, false, false);
if (snapShotMor != null)
return true;
else return false;
}
else return false;
}
catch (Exception ex)
{
return false;
}
}
스냅 샷 이름 변경은 다음과 같은 방법으로 수행 할 수 있습니다 : 당신이 이름을 변경 삭제할 수
public bool RenameSnapshot(string snapShotName, VirtualMachine vmObject)
{
try
{
ManagedObjectReference snapshotObject = vmObject.Snapshot.CurrentSnapshot;
VirtualMachineSnapshot currentSnapshotName = new VirtualMachineSnapshot(vimClient, snapshotObject);
currentSnapshotName.RenameSnapshot("Temp-" + snapShotName, "Renamed for deletion");
return true;
}
catch (Exception ex)
{
return false;
}
}
위의 두 후 단계 (온도) 스냅 사진.
관련 코드를 게시 할 수 있습니까? –
VirtualMachine vmObject = (VirtualMachine) vimClient.FindEntityViews (typeof (VirtualMachine), null, filter, null) .FirstOrDefault(); if (vmObject! = null) { vmObject.ShutdownGuest(); \t \t \t \t \t은 "여기 내 이전 스냅 샷 이름을 바꿀 (SS를 '임시 SS1'에!)" \t \t \t \t \t vmObject.CreateSnapshot (snapShotName, snapshotdescription을, 거짓, 거짓); } – user7393522