Search in sources :

Example 1 with SetVmStatusVDSCommandParameters

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);
    }
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) VM(org.ovirt.engine.core.common.businessentities.VM) SetVmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Example 2 with SetVmStatusVDSCommandParameters

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);
}
Also used : SetVmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters)

Example 3 with SetVmStatusVDSCommandParameters

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);
}
Also used : ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) VM(org.ovirt.engine.core.common.businessentities.VM) SetVmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters) VmsComparer(org.ovirt.engine.core.common.businessentities.comparators.VmsComparer) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) UpdateVdsVMsClearedVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UpdateVdsVMsClearedVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

SetVmStatusVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters)3 ArrayList (java.util.ArrayList)2 ProcessDownVmParameters (org.ovirt.engine.core.common.action.ProcessDownVmParameters)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 Guid (org.ovirt.engine.core.compat.Guid)2 VmsComparer (org.ovirt.engine.core.common.businessentities.comparators.VmsComparer)1 UpdateVdsVMsClearedVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.UpdateVdsVMsClearedVDSCommandParameters)1 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)1 AuditLogableBase (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase)1