Search in sources :

Example 1 with ProcessDownVmParameters

use of org.ovirt.engine.core.common.action.ProcessDownVmParameters 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 ProcessDownVmParameters

use of org.ovirt.engine.core.common.action.ProcessDownVmParameters in project ovirt-engine by oVirt.

the class VdsEventListener method processOnVmStopInternal.

private void processOnVmStopInternal(final Collection<Guid> vmIds, final Guid hostId) {
    for (Guid vmId : vmIds) {
        backend.runInternalAction(ActionType.ProcessDownVm, new ProcessDownVmParameters(vmId, true));
    }
    HostDeviceManager hostDeviceManager = Injector.get(HostDeviceManager.class);
    hostDeviceManager.refreshHostIfAnyVmHasHostDevices(vmIds, hostId);
}
Also used : ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) Guid(org.ovirt.engine.core.compat.Guid) HostDeviceManager(org.ovirt.engine.core.bll.hostdev.HostDeviceManager)

Example 3 with ProcessDownVmParameters

use of org.ovirt.engine.core.common.action.ProcessDownVmParameters in project ovirt-engine by oVirt.

the class RunVmCommand method removeStatlessSnapshot.

private void removeStatlessSnapshot() {
    runInternalAction(ActionType.ProcessDownVm, new ProcessDownVmParameters(getVm().getId(), true), ExecutionHandler.createDefaultContextForTasks(getContext(), getLock()));
    // setting lock to null in order not to release lock twice
    setLock(null);
    setSucceeded(true);
}
Also used : ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters)

Example 4 with ProcessDownVmParameters

use of org.ovirt.engine.core.common.action.ProcessDownVmParameters 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

ProcessDownVmParameters (org.ovirt.engine.core.common.action.ProcessDownVmParameters)4 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 SetVmStatusVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 HostDeviceManager (org.ovirt.engine.core.bll.hostdev.HostDeviceManager)1 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