2017-02-07 4 views
0

저는 vsphere Esx 5.5에서 가상 머신을 관리하는 웹 인터페이스를 연구 중입니다. 내 프로그램은 .net 웹 양식 (MVC 아님)으로 개발되었습니다. VMWare.vim.dll을 사용하여 VM을 복제 한 후 작업을 대기하는 방법은 무엇입니까?

나는 나를 도와 (VMware.Vim 사용) jeffpaton 게시물 (당신 덕분에, 제프) https://communities.vmware.com/thread/434579을 따랐다.

하지만 지금은이 주제에 동결. VM을 복제 한 후 작업을 대기하는 방법을 모르겠습니다. 내 웹 사이트는 vmware.vim을 사용하여 Vsphere Esx로 vsphere 명령을 실행합니다. vpshere가 다른 지침을 시작할 작업을 마친 때를 알아야합니다.

나는 PropertyCollector을 사용하려고하지만 난 그것을 사용하는 방법을 알고하지 않습니다

내가이 게시물에 빨간색하지만 성공하지 :

여기

이 시도 내 코드의 일부이다하지만 난 차단하고있다. 나는 jeffpaton 함수를 사용한다.

using VMware.Vim; 
... 
VimClient client; 
string serverUrl = "..." 
client.Connect("https://" + serverUrl + "/sdk"); 
client.Login(userLogin, userPassword); 
... 
ManagedObjectReference cloneTask_MoRef = null; 

//1 waiting the cloning task 
cloneTask_MoRef = sourceVm.cloneVM_Task(sourceVm.Parent, "cloneName", mySpec); 

if (cloneTask_MoRef == null) { 
//error 
}else 
{ 
    PropertyCollector pc = new PropertyCollector(client, cloneTask_MoRef); 

    PropertyFilterSpec[] pfs = null; 
    RetrieveOptions ro = new RetrieveOptions(); 
    RetrieveResult rResult = new RetrieveResult(); 


    //PropertySpec 
    //pc.CreateFilter(pfs, true); 
    //rResult = pc.RetrievePropertiesEx(pfs,ro); 
    // 

    //2 PowerOn the CloneVM              
    cloneVM = this.vimClientTools.getVirtualMachines(selectedDC, cloneName)[0]; 

    //3 waiting the powerOn Task... 

     //What could i do to know if the task is over or in progress ? :-(

도움이 필요합니다. 누군가가 제안 시작 ... 모든

감사가있는 경우.

답변

0

이 너무 늦었 아마도,하지만 여기에 표시됩니다.

VimClient는 WaitForTask 수단을 갖는다

client.WaitForTask(cloneTask_MoRef); 

또는 작업을 가져 와서 진행 상황을 볼 수 있습니다.

var task = (Task) client.GetView(cloneTask_MoRef, null); 

while (task.Info.State != TaskInfoState.success) 
{ 
    Thread.Sleep(5000); 
    task.UpdateViewData(); 
    if (task.Info.State == TaskInfoState.error) 
     throw new Exception($"The clone failed: {task.Info.Error.LocalizedMessage}"); 

    Console.WriteLine(task.Info.Progress); 
}