Search in sources :

Example 1 with DestroyVmVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters in project ovirt-engine by oVirt.

the class RestartVdsVmsOperation method destroyVmOnDestination.

/**
 * Destroys VM migration to another host
 * @param vm vm migrated to another host
 */
protected void destroyVmOnDestination(VM vm) {
    if (vm.getStatus() == VMStatus.MigratingFrom) {
        try {
            if (vm.getMigratingToVds() != null) {
                Backend.getInstance().getResourceManager().runVdsCommand(VDSCommandType.DestroyVm, new DestroyVmVDSCommandParameters(new Guid(vm.getMigratingToVds().toString()), vm.getId(), false, 0));
                log.info("Stopped migrating vm '{}' on vds '{}'", vm.getName(), vm.getMigratingToVds());
            }
        } catch (RuntimeException ex) {
            log.info("Could not stop migrating vm '{}' on vds '{}': {}", vm.getName(), vm.getMigratingToVds(), ex.getMessage());
        // intentionally ignored
        }
    }
}
Also used : DestroyVmVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with DestroyVmVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters 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)

Aggregations

DestroyVmVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters)2 StopVmParameters (org.ovirt.engine.core.common.action.StopVmParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1