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.

import com.hyper9.uvapi.types.virt.resources.ComputeResourceListBean;
import com.hyper9.uvapi.types.virt.resources.entities.VirtualMachineBean;
import com.hyper9.uvapi.types.virt.TaskBean;


// Get a reference to the first VM in the list.
VirtualMachineBean vm = hvms.get(0);

// Send the VM a hard stop and get a reference to the task this
// function returns.
TaskBean task = vm.sendPowerOp("stop.hard");

// Wait until the task completes before continuing.
while (task.getProgress() < 100)

// Print out the results of the task.