Search in sources :

Example 81 with ActionReturnValue

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

the class RemoveVmTemplateCommand method removeVmTemplateImages.

protected boolean removeVmTemplateImages() {
    getParameters().setEntityInfo(getParameters().getEntityInfo());
    getParameters().setParentCommand(getActionType());
    getParameters().setParentParameters(getParameters());
    ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveAllVmTemplateImageTemplates, getParameters());
    if (!actionReturnValue.getSucceeded()) {
        setSucceeded(false);
        getReturnValue().setFault(actionReturnValue.getFault());
        return false;
    }
    getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
    return true;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 82 with ActionReturnValue

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

the class RestoreStatelessVmCommand method detachDisksNotPartOfStatelessSnapshot.

private boolean detachDisksNotPartOfStatelessSnapshot(List<DiskImage> statelessDiskSnapshots) {
    Guid activeVmSnapshotId = getVmSnapshotIdForType(SnapshotType.ACTIVE);
    List<DiskImage> activeDiskSnapshots = getDiskSnapshotsForVmSnapshot(activeVmSnapshotId);
    Set<Guid> disksWithStatelessSnapshot = statelessDiskSnapshots.stream().map(DiskImage::getId).collect(Collectors.toSet());
    for (DiskImage activeDiskSnapshot : activeDiskSnapshots) {
        if (!disksWithStatelessSnapshot.contains(activeDiskSnapshot.getId())) {
            ActionReturnValue returnValue = runInternalAction(ActionType.DetachDiskFromVm, buildDetachDetachVmDiskParameters(activeDiskSnapshot));
            if (!returnValue.getSucceeded()) {
                log.error("Could not restore stateless VM  {} due to a failure to detach Disk {}", getVmId(), activeDiskSnapshot.getId());
                return false;
            }
        }
    }
    return true;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 83 with ActionReturnValue

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

the class PrevalidatingMultipleActionsRunner method initCommandsAndReturnValues.

private void initCommandsAndReturnValues(List<ActionReturnValue> returnValues) {
    ActionReturnValue returnValue;
    for (ActionParametersBase parameter : getParameters()) {
        parameter.setMultipleAction(true);
        returnValue = ExecutionHandler.evaluateCorrelationId(parameter);
        if (returnValue == null) {
            getCommands().add(commandFactory.createWrappedCommand(commandContext, actionType, parameter, isInternal));
        } else {
            returnValues.add(returnValue);
        }
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 84 with ActionReturnValue

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

the class ProcessDownVmCommand method applyNextRunConfiguration.

/**
 * Update VM configuration with NEXT_RUN configuration, if exists.
 */
private void applyNextRunConfiguration() {
    // Remove snpashot first, in case other update is in progress, it will block this one with exclusive lock
    // and any newer update should be preffered to this one.
    Snapshot runSnap = snapshotDao.get(getVmId(), SnapshotType.NEXT_RUN);
    if (runSnap != null && getVm().getStatus() != VMStatus.Suspended) {
        log.debug("Attempt to apply NEXT_RUN snapshot for VM '{}'", getVmId());
        EngineLock updateVmLock = createUpdateVmLock();
        if (lockManager.acquireLock(updateVmLock).getFirst()) {
            snapshotDao.remove(runSnap.getId());
            Date originalCreationDate = getVm().getVmCreationDate();
            snapshotsManager.updateVmFromConfiguration(getVm(), runSnap.getVmConfiguration());
            // override creation date because the value in the config is the creation date of the config, not the vm
            getVm().setVmCreationDate(originalCreationDate);
            ActionReturnValue result = runInternalAction(ActionType.UpdateVm, createUpdateVmParameters(), ExecutionHandler.createInternalJobContext(updateVmLock));
            if (result.getActionReturnValue() != null && result.getActionReturnValue().equals(ActionType.UpdateVmVersion)) {
                // Template-version changed
                templateVersionChanged = true;
            }
        } else {
            log.warn("Could not acquire lock for UpdateVmCommand to apply Next Run Config of VM '{}'", getVmId());
        }
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) Date(java.util.Date)

Example 85 with ActionReturnValue

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

the class RebootVmCommand method perform.

@Override
protected void perform() {
    if (isColdReboot()) {
        ActionReturnValue returnValue = runInternalAction(ActionType.ShutdownVm, new ShutdownVmParameters(getVmId(), false));
        setReturnValue(returnValue);
        setSucceeded(returnValue.getSucceeded());
        if (getSucceeded()) {
            resourceManager.getVmManager(getVmId()).setColdReboot(true);
        }
    } else {
        final VDSReturnValue returnValue = runVdsCommand(VDSCommandType.RebootVm, new VdsAndVmIDVDSParametersBase(getVdsId(), getVmId()));
        setActionReturnValue(returnValue.getReturnValue());
        setSucceeded(returnValue.getSucceeded());
    }
}
Also used : VdsAndVmIDVDSParametersBase(org.ovirt.engine.core.common.vdscommands.VdsAndVmIDVDSParametersBase) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ShutdownVmParameters(org.ovirt.engine.core.common.action.ShutdownVmParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)293 ArrayList (java.util.ArrayList)57 Guid (org.ovirt.engine.core.compat.Guid)55 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)50 Test (org.junit.Test)37 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)27 ActionType (org.ovirt.engine.core.common.action.ActionType)26 EngineException (org.ovirt.engine.core.common.errors.EngineException)25 VDS (org.ovirt.engine.core.common.businessentities.VDS)23 HashSet (java.util.HashSet)16 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 ExecutionException (java.util.concurrent.ExecutionException)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)13 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)12 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)12 List (java.util.List)11 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11