Hi ,
i need to know when actually a task is completed using VI API whether it is a success or failure ..........for example if i use shutdownguest method on a vm to shut down the guest the method returns immediately invoking the task...but can someone help me with the code to know whethet the system has shut down completely?
Thanks in advance
Regards,
Padmini
You can poll the Task managed object for its info.state. If it's done successfully, it is Enum success.
You are right the method is async call so you have to block your thread by yourself. If you use VI Java API, it's as simple as:
Task task = vm. shutdownGuest();
if(task.waitForme==Task.SUCCESS)
{...}
else
{...}
Steve JIN, VMware Engineering
Hi,
the shutdowguest method doesnt return anything...how can i get a task refernce for that? please help me
Thanks in advance
Regards,
Padmini
Hi,
According to VI SDK API reference vm.ShutdownGuest method just send shutdown command to guest operating system and returns immediately. It does not wait for the guest operating system to complete the operation.
The easiest way to check if operation is completed is to loop and wait vm.runtime.powerstate to change to poweredOff.
You can also check if guest has a pending shutdown command examining vm.guest.guestState == "shuttingdown"
Regards,
Yasen
Hi. The problem with that is vm.shutdownGuest() is of type void :
VMpowerOps.java:117: incompatible types
found : void
required: com.vmware.vim25.mo.Task
Task task = vm.shutdownGuest();
Is there any solution for this problem. I am also facing the same problem.