2017-02-06 2 views
0

VMware 기능을 명령하거나 자동화하는 Windows 데스크톱 응용 프로그램이 있습니다. 기존 스냅 샷의 이름을 바꾸고 다음 플로우와 동일하게 업데이트하려고하지만 기존 스냅 샷의 이름을 바꾸는 VM웨어 API가 보이지 않습니다. 누구든지 내게 VM웨어 스냅 샷의 이름을 바꾸는 방법에 대한 정보를 제공 할 수 있습니까? 감사VM웨어 스냅 샷 이름 바꾸기

'등록 및 스냅 샷을 시작'에

클릭 -> 시작 게스트 VM Shutdown->에 현재 Snapshot- SS1의 이름을 변경 온도-SS1-> 현재 스냅 샷 이름 (예 : SS1)로 새 스냅 샷 를 타고 -> 이전의 이름을 스냅 샷으로 변경하십시오 (예 : Temp-SS1).

+0

관련 코드를 게시 할 수 있습니까? –

+0

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

답변

0

위는 간단한 다음 두 가지 방법으로 수행 할 수 있습니다

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; 
     } 
    } 

위의 두 후 단계 (온도) 스냅 사진.