use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.WaitForValues in project photon-model by vmware.
the class VimUtils method waitTaskEnd.
public static TaskInfo waitTaskEnd(Connection connection, ManagedObjectReference task) throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
WaitForValues waitForValues = new WaitForValues(connection);
Object[] info = waitForValues.wait(task, new String[] { VimPath.task_info }, new String[] { VimPath.task_info_state }, new Object[][] { new Object[] { TaskInfoState.SUCCESS, TaskInfoState.ERROR } });
return (TaskInfo) info[0];
}
use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.WaitForValues in project photon-model by vmware.
the class PowerStateClient method softPowerOff.
private void softPowerOff(ManagedObjectReference vm, long politenessDeadlineMicros) throws Exception {
try {
getVimPort().shutdownGuest(vm);
} catch (ToolsUnavailableFaultMsg e) {
// no vmtoools present, try harder
hardPowerOff(vm);
return;
}
// wait for guest to shutdown
WaitForValues wait = new WaitForValues(this.connection);
int timeout = (int) TimeUnit.MICROSECONDS.toSeconds(politenessDeadlineMicros - Utils.getNowMicrosUtc());
if (timeout <= 0) {
// maybe try anyway?
return;
}
Object[] currentPowerState = wait.wait(vm, new String[] { VimPath.vm_runtime_powerState }, new String[] { VimPath.vm_runtime_powerState }, new Object[][] { new Object[] { VirtualMachinePowerState.POWERED_OFF } }, timeout);
if (currentPowerState == null || currentPowerState[0] != VirtualMachinePowerState.POWERED_OFF) {
// vm not shutdown on time
hardPowerOff(vm);
}
}
Aggregations