use of org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters in project ovirt-engine by oVirt.
the class RestartVdsVmsOperation method restartVms.
/**
* Changes status of specified VMs to Down and starts HA VMs on another hosts
*
* @param vms list of VM to stopped/restarted
*/
public void restartVms(List<VM> vms) {
List<Guid> autoStartVmIdsToRerun = new ArrayList<>();
// restart all running vms of a failed vds.
for (VM vm : vms) {
destroyVmOnDestination(vm);
VDSReturnValue returnValue = Backend.getInstance().getResourceManager().runVdsCommand(VDSCommandType.SetVmStatus, new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down, VmExitStatus.Error));
// Write that this VM was shut down by host reboot or manual fence
if (returnValue != null && returnValue.getSucceeded()) {
Injector.get(AuditLogDirector.class).log(Injector.injectMembers(new AuditLogableBase(vds.getId(), vm.getId())), AuditLogType.VM_WAS_SET_DOWN_DUE_TO_HOST_REBOOT_OR_MANUAL_FENCE);
}
Backend.getInstance().runInternalAction(ActionType.ProcessDownVm, new ProcessDownVmParameters(vm.getId(), true), ExecutionHandler.createDefaultContextForTasks(commandContext));
// Handle highly available VMs
if (vm.isAutoStartup()) {
autoStartVmIdsToRerun.add(vm.getId());
}
}
if (!autoStartVmIdsToRerun.isEmpty()) {
Injector.get(HaAutoStartVmsRunner.class).addVmsToRun(autoStartVmIdsToRerun);
}
}
use of org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters in project ovirt-engine by oVirt.
the class VmHandler method unLockVm.
public void unLockVm(VM vm) {
vdsBrokerFrontend.runVdsCommand(VDSCommandType.SetVmStatus, new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down));
vm.setStatus(VMStatus.Down);
}
use of org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters in project ovirt-engine by oVirt.
the class ClearNonResponsiveVdsVmsCommand method executeCommand.
@Override
protected void executeCommand() {
List<VM> vms = vmDao.getAllRunningForVds(getVdsId());
Collections.sort(vms, Collections.reverseOrder(new VmsComparer()));
List<Guid> autoStartVmIdsToRerun = new ArrayList<>();
for (VM vm : vms) {
if (vm.isAutoStartup()) {
autoStartVmIdsToRerun.add(vm.getId());
}
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetVmStatus, new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down, VmExitStatus.Error));
// Write that this VM was shut down by host reboot or manual fence
if (returnValue != null && returnValue.getSucceeded()) {
logSettingVmToDown(vm);
}
runInternalActionWithTasksContext(ActionType.ProcessDownVm, new ProcessDownVmParameters(vm.getId(), true));
}
runVdsCommand(VDSCommandType.UpdateVdsVMsCleared, new UpdateVdsVMsClearedVDSCommandParameters(getVdsId()));
if (!autoStartVmIdsToRerun.isEmpty()) {
haAutoStartVmsRunner.addVmsToRun(autoStartVmIdsToRerun);
}
setSucceeded(true);
}
Aggregations