/** * This method will wait for VM Tools to be running. For example, the machine might * still be booting and thus VM Tools would not be running. * @param vm * @throws RemoteException * @throws InterruptedException */ public void waitForVmtools(VirtualMachine vm) throws RemoteException, InterruptedException { long pollInterval = 3000L; long timeoutInterval = 5L * 60L * 1000L; long start = System.currentTimeMillis(); VirtualMachineToolsStatus toolsStatus = vm.getGuest().getToolsStatus(); while (toolsStatus != VirtualMachineToolsStatus.toolsOk && toolsStatus != VirtualMachineToolsStatus.toolsOld) { if (System.currentTimeMillis() - start > timeoutInterval) { throw new RemoteException("Timeout waiting for vmtools"); } Thread.sleep(pollInterval); toolsStatus = vm.getGuest().getToolsStatus(); } }
VirtualMachineToolsStatus vmToolsStatus = guestInfo.getToolsStatus(); VirtualMachineRuntimeInfo vmri = vm.getRuntime(); VirtualMachinePowerState powerStatus = vmri.getPowerState();