Search in sources :

Example 1 with StopVmParameters

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

the class ShutdownVmCommand method perform.

@Override
protected void perform() {
    log.info("Entered (VM '{}').", getVm().getName());
    vmHandler.updateVmGuestAgentVersion(getVm());
    if (canShutdownVm()) {
        // shutting down desktop and waiting for it in a separate thread to
        // become 'down':
        log.info("Sending shutdown command for VM '{}'.", getVmName());
        int secondsToWait = getParameters().getWaitBeforeShutdown() ? Config.<Integer>getValue(ConfigValues.VmGracefulShutdownTimeout) : 0;
        // sending a shutdown command to the VM:
        setActionReturnValue(runVdsCommand(VDSCommandType.DestroyVm, new DestroyVmVDSCommandParameters(getVdsId(), getVmId(), getParameters().getStopReason(), true, secondsToWait)).getReturnValue());
    } else {
        // cannot shutdown -> send a StopVm command instead ('destroy'):
        // don't log -> log will appear for the StopVmCommand we are about to run:
        setCommandShouldBeLogged(false);
        log.info("Cannot shutdown VM '{}', status is not up. Stopping instead.", getVmName());
        StopVmParameters stopVmParams = new StopVmParameters(getVmId(), StopVmTypeEnum.CANNOT_SHUTDOWN);
        stopVmParams.setStopReason(getParameters().getStopReason());
        // stopVmParams.ParametersCurrentUser = CurrentUser;
        stopVmParams.setSessionId(getParameters().getSessionId());
        runInternalAction(ActionType.StopVm, stopVmParams);
    }
    setSucceeded(true);
}
Also used : StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters) DestroyVmVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters)

Example 2 with StopVmParameters

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

the class RemoveVmPoolCommand method stopVms.

private void stopVms() {
    allVmsDown = true;
    for (VM vm : getCachedVmsInPool()) {
        if (!vm.isDown()) {
            commandCoordinatorUtil.executeAsyncCommand(ActionType.StopVm, withRootCommandInfo(new StopVmParameters(vm.getId(), StopVmTypeEnum.NORMAL)), cloneContextAndDetachFromParent());
            allVmsDown = false;
        } else {
            removeVm(vm);
        }
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters)

Example 3 with StopVmParameters

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

the class VmListModel method onStop.

private void onStop() {
    final ConfirmationModel model = (ConfirmationModel) getWindow();
    onPowerAction(ActionType.StopVm, vm -> new StopVmParameters(vm.getId(), StopVmTypeEnum.NORMAL, model.getReason().getEntity()));
}
Also used : StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Aggregations

StopVmParameters (org.ovirt.engine.core.common.action.StopVmParameters)3 VM (org.ovirt.engine.core.common.businessentities.VM)1 DestroyVmVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1