And of course you can use UVAPI to cause actions to occur on a hypervisor as well. At the moment the only supported actions are to do with virtual machine power states.
The following example demonstrates how to turn off a VM and then monitor the progress of the action. This example uses the VMs retrieved in the example on the tutorial on querying for VMs with Hyper-V.
01.
import
com.hyper9.uvapi.types.virt.resources.ComputeResourceListBean;
02.
import
com.hyper9.uvapi.types.virt.resources.entities.VirtualMachineBean;
03.
import
com.hyper9.uvapi.types.virt.TaskBean;
04.
05.
...
06.
07.
// Get a reference to the first VM in the list.
08.
VirtualMachineBean vm = hvms.get(
0
);
09.
10.
// Send the VM a hard stop and get a reference to the task this
11.
// function returns.
12.
TaskBean task = vm.sendPowerOp(
"stop.hard"
);
13.
14.
// Wait until the task completes before continuing.
15.
while
(task.getProgress() <
100
)
16.
{
17.
Thread.sleep(
500
);
18.
}
19.
20.
// Print out the results of the task.
21.
System.out.println(task.getState());
22.
23.
...