Search in sources :

Example 31 with ActionType

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

the class GlusterTasksSyncJob method createJobToMonitor.

private void createJobToMonitor(Cluster cluster, GlusterAsyncTask task) {
    if (!isTaskToBeMonitored(task)) {
        // there's no need to monitor jobs that are failed or completed
        return;
    }
    StepEnum step = task.getType().getStep();
    ActionType actionType;
    switch(step) {
        case REBALANCING_VOLUME:
            actionType = ActionType.StartRebalanceGlusterVolume;
            break;
        case REMOVING_BRICKS:
            actionType = ActionType.StartRemoveGlusterVolumeBricks;
            break;
        default:
            actionType = ActionType.Unknown;
    }
    String volumeName = task.getTaskParameters().getVolumeName();
    GlusterVolumeEntity vol = volumeDao.getByName(cluster.getId(), volumeName);
    if (vol == null) {
        log.info("Volume '{}' does not exist yet for task detected from CLI '{}', not adding to engine", volumeName, task);
        return;
    }
    Guid jobId = addJob(cluster, task, actionType, vol);
    Guid execStepId = addExecutingStep(jobId);
    Guid asyncStepId = addAsyncTaskStep(cluster, task, step, execStepId);
    Step asyncStep = stepDao.get(asyncStepId);
    executionHandler.updateStepExternalId(asyncStep, task.getTaskId(), ExternalSystemType.GLUSTER);
    updateVolumeBricksAndLock(cluster, task, vol);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) StepEnum(org.ovirt.engine.core.common.job.StepEnum) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step)

Example 32 with ActionType

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

the class CommandBase method withRootCommandInfo.

protected <P extends ActionParametersBase> P withRootCommandInfo(P params, ActionType actionType) {
    ActionType parentCommand = isExecutedAsChildCommand() ? getParameters().getParentCommand() : actionType;
    params.setParentParameters(getParametersForTask(parentCommand, getParameters()));
    params.setParentCommand(parentCommand);
    return params;
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType)

Example 33 with ActionType

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

the class CoCoAsyncTaskHelper method endAction.

public ActionReturnValue endAction(SPMTask task) {
    AsyncTask dbAsyncTask = task.getParameters().getDbAsyncTask();
    ActionType actionType = getEndActionType(dbAsyncTask);
    ActionParametersBase parameters = dbAsyncTask.getActionParameters();
    CommandBase<?> command = CommandHelper.buildCommand(actionType, parameters, coco.get().retrieveCommandContext(dbAsyncTask.getRootCommandId()).getExecutionContext(), coco.get().getCommandStatus(dbAsyncTask.getCommandId()));
    return new DecoratedCommand<>(command).endAction();
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 34 with ActionType

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

the class CommandAsyncTask method handleEndActionRuntimeException.

private void handleEndActionRuntimeException(CommandMultiAsyncTasks commandInfo, AsyncTask dbAsyncTask) {
    try {
        ActionType actionType = getParameters().getDbAsyncTask().getActionType();
        log.info("CommandAsyncTask::HandleEndActionResult: endAction for action type '{}' threw an" + " unrecoverable RuntimeException the task will be cleared.", actionType);
        commandInfo.clearTaskByVdsmTaskId(dbAsyncTask.getVdsmTaskId());
        removeTaskFromDB();
        if (commandInfo.getAllCleared()) {
            log.info("CommandAsyncTask::HandleEndActionRuntimeException: Removing CommandMultiAsyncTasks" + " object for entity '{}'", commandInfo.getCommandId());
            synchronized (_lockObject) {
                _multiTasksByCommandIds.remove(commandInfo.getCommandId());
            }
        }
    } catch (RuntimeException ex) {
        log.error("CommandAsyncTask::HandleEndActionResult [within thread]: an exception has been thrown", ex);
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType)

Example 35 with ActionType

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

the class MoveDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    List<DiskVmElement> diskVmElements = diskVmElementDao.getAllDiskVmElementsByDiskId(getParameters().getImageGroupID());
    ActionType actionType = getMoveActionType(diskVmElements);
    if (actionType == ActionType.MoveOrCopyDisk) {
        MoveDiskParameters moveDiskParameters = getParameters();
        // This is required to make MoveDiskCommand and MoveOrCopyDiskCommand have
        // different a commandId. Having the same commandId will make CommandsCache
        // return the wrong command and lead to unexpected results
        moveDiskParameters.setCommandId(null);
        setReturnValue(runInternalAction(actionType, moveDiskParameters, ExecutionHandler.createInternalJobContext(getContext(), getLock())));
    } else {
        Guid vmId = diskVmElements.get(0).getVmId();
        engineLock = lockVmWithWait(vmId);
        setReturnValue(runInternalAction(actionType, createLiveMigrateDiskParameters(getParameters(), vmId), ExecutionHandler.createInternalJobContext(getContext(), engineLock)));
    }
    setSucceeded(true);
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ActionType (org.ovirt.engine.core.common.action.ActionType)58 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)37 ArrayList (java.util.ArrayList)31 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)24 Test (org.junit.Test)23 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)16 Guid (org.ovirt.engine.core.compat.Guid)15 List (java.util.List)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)11 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)10 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)10 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)9 Arrays (java.util.Arrays)7 HashSet (java.util.HashSet)7 Set (java.util.Set)7