Search in sources :

Example 71 with ActionReturnValue

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

the class Backend method evaluateCorrelationId.

protected ActionReturnValue evaluateCorrelationId(CommandBase<?> commandBase) {
    ActionParametersBase cmdParams = commandBase.getParameters();
    if (cmdParams.getCorrelationId() == null && cmdParams.getParentParameters() != null) {
        cmdParams.setCorrelationId(cmdParams.getParentParameters().getCorrelationId());
    }
    // Evaluate and set the correlationId on the parameters, fails on invalid correlation id
    ActionReturnValue returnValue = ExecutionHandler.evaluateCorrelationId(cmdParams);
    if (returnValue != null) {
        log.warn("Validation of action '{}' failed. Reasons: {}", commandBase.getActionType(), StringUtils.join(returnValue.getValidationMessages(), ','));
    }
    // Set the correlation-id on the command
    commandBase.setCorrelationId(cmdParams.getCorrelationId());
    return returnValue;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 72 with ActionReturnValue

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

the class RunVmCommand method createStatelessSnapshot.

private void createStatelessSnapshot() {
    warnIfNotAllDisksPermitSnapshots();
    log.info("Creating stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
    CreateSnapshotForVmParameters createAllSnapshotsFromVmParameters = buildCreateSnapshotParameters();
    ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshotForVm, createAllSnapshotsFromVmParameters, createContextForStatelessSnapshotCreation());
    // setting lock to null in order not to release lock twice
    setLock(null);
    setSucceeded(actionReturnValue.getSucceeded());
    if (!actionReturnValue.getSucceeded()) {
        if (areDisksLocked(actionReturnValue)) {
            throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
        }
        getReturnValue().setFault(actionReturnValue.getFault());
        log.error("Failed to create stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 73 with ActionReturnValue

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

the class RunVmCommand method endWithFailure.

@Override
protected void endWithFailure() {
    if (shouldEndSnapshotCreation()) {
        ActionReturnValue actionReturnValue = backend.endAction(ActionType.CreateSnapshotForVm, getParameters().getImagesParameters().get(0), cloneContext().withoutExecutionContext().withoutLock());
        setSucceeded(actionReturnValue.getSucceeded());
    // we are not running the VM, of course,
    // since we couldn't create a snapshot.
    } else {
        super.endWithFailure();
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 74 with ActionReturnValue

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

the class UpdateVmCommand method hotPlugMemoryDevice.

private void hotPlugMemoryDevice(int currentMemoryMb, int newAmountOfMemoryMb) {
    HotSetAmountOfMemoryParameters params = new HotSetAmountOfMemoryParameters(newVmStatic, currentMemoryMb < newAmountOfMemoryMb ? PlugAction.PLUG : PlugAction.UNPLUG, // We always use node 0, auto-numa should handle the allocation
    0, newAmountOfMemoryMb - currentMemoryMb);
    ActionReturnValue setAmountOfMemoryResult = runInternalAction(ActionType.HotSetAmountOfMemory, params, cloneContextAndDetachFromParent());
    // into the OVF store and automatically used during the next HE VM start
    if (!getVm().isHostedEngine()) {
        newVmStatic.setMemSizeMb(setAmountOfMemoryResult.getSucceeded() ? newAmountOfMemoryMb : currentMemoryMb);
    }
    logHotSetActionEvent(setAmountOfMemoryResult, AuditLogType.FAILED_HOT_SET_MEMORY);
}
Also used : HotSetAmountOfMemoryParameters(org.ovirt.engine.core.common.action.HotSetAmountOfMemoryParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 75 with ActionReturnValue

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

the class UpdateVmCommand method updateRngDevice.

private void updateRngDevice() {
    if (!getParameters().isUpdateRngDevice()) {
        return;
    }
    QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId()));
    List<VmRngDevice> rngDevs = query.getReturnValue();
    ActionReturnValue rngCommandResult = null;
    if (rngDevs.isEmpty()) {
        if (getParameters().getRngDevice() != null) {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
        }
    } else {
        if (getParameters().getRngDevice() == null) {
            RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true);
            rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
        } else {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
            rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
        }
    }
    if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
        log.error("Updating RNG device of VM {} ({}) failed. Old RNG device = {}. New RNG device = {}.", getVm().getName(), getVm().getId(), rngDevs.isEmpty() ? null : rngDevs.get(0), getParameters().getRngDevice());
    }
}
Also used : RngDeviceParameters(org.ovirt.engine.core.common.action.RngDeviceParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

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