Search in sources :

Example 1 with ExecutionContext

use of org.ovirt.engine.core.bll.job.ExecutionContext in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderCommand method createConversionStepContext.

protected CommandContext createConversionStepContext(StepEnum step) {
    CommandContext commandCtx = null;
    try {
        Map<String, String> values = Collections.singletonMap(VdcObjectType.VM.name().toLowerCase(), getVmName());
        Step conversionStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), step, ExecutionMessageDirector.resolveStepMessage(step, values));
        ExecutionContext ctx = new ExecutionContext();
        ctx.setStep(conversionStep);
        ctx.setMonitored(true);
        commandCtx = cloneContext().withoutCompensationContext().withExecutionContext(ctx).withoutLock();
    } catch (RuntimeException e) {
        log.error("Failed to create command context of converting VM '{}': {}", getVmName(), e.getMessage());
        log.debug("Exception", e);
    }
    return commandCtx;
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) Step(org.ovirt.engine.core.common.job.Step)

Example 2 with ExecutionContext

use of org.ovirt.engine.core.bll.job.ExecutionContext in project ovirt-engine by oVirt.

the class GlusterAsyncCommandBase method endStepJob.

protected void endStepJob(JobExecutionStatus status, Map<String, String> stepMessageMap, boolean exitStatus) {
    GlusterAsyncTask asyncTask = getGlusterVolume().getAsyncTask();
    // Gluster Task will be associated with only one step ( REBALANCING_VOLUME or REMOVING_BRICK)
    Step step = stepDao.getStepsByExternalId(asyncTask.getTaskId()).get(0);
    step.setStatus(status);
    step.setEndTime(new Date());
    step.setDescription(ExecutionMessageDirector.resolveStepMessage(getStepType(), stepMessageMap));
    jobRepository.updateStep(step);
    ExecutionContext finalContext = executionHandler.createFinalizingContext(step.getId());
    executionHandler.endTaskStepAndJob(finalContext, exitStatus);
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Step(org.ovirt.engine.core.common.job.Step) Date(java.util.Date)

Example 3 with ExecutionContext

use of org.ovirt.engine.core.bll.job.ExecutionContext in project ovirt-engine by oVirt.

the class VdsNotRespondingTreatmentCommand method setStoragePoolNonOperational.

private void setStoragePoolNonOperational() {
    log.info("Fence failed on vds '{}' which is spm of pool '{}' - moving pool to non operational", getVds().getName(), getVds().getStoragePoolId());
    CommandContext commandContext = getContext().clone();
    // CommandContext clone is 'shallow' and does not clone the internal ExecutionContext.
    // So ExecutionContext is cloned here manually to prevent a bug (BZ1145099).
    commandContext.withExecutionContext(new ExecutionContext(commandContext.getExecutionContext()));
    runInternalAction(ActionType.SetStoragePoolStatus, new SetStoragePoolStatusParameters(getVds().getStoragePoolId(), StoragePoolStatus.NotOperational, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_NO_HOST_FOR_SPM), commandContext);
}
Also used : SetStoragePoolStatusParameters(org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) CommandContext(org.ovirt.engine.core.bll.context.CommandContext)

Example 4 with ExecutionContext

use of org.ovirt.engine.core.bll.job.ExecutionContext in project ovirt-engine by oVirt.

the class LiveMigrateDiskCommand method createStepsContext.

private CommandContext createStepsContext(StepEnum step) {
    Step addedStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), step, ExecutionMessageDirector.resolveStepMessage(step, Collections.emptyMap()));
    ExecutionContext ctx = new ExecutionContext();
    ctx.setStep(addedStep);
    ctx.setMonitored(true);
    CommandContext commandCtx = ExecutionHandler.createDefaultContextForTasks(getContext(), null).withExecutionContext(ctx);
    return commandCtx;
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) Step(org.ovirt.engine.core.common.job.Step)

Example 5 with ExecutionContext

use of org.ovirt.engine.core.bll.job.ExecutionContext in project ovirt-engine by oVirt.

the class EndExternalJobCommand method executeCommand.

@Override
protected void executeCommand() {
    ExecutionContext context = new ExecutionContext();
    context.setMonitored(true);
    context.setExecutionMethod(ExecutionMethod.AsJob);
    context.setJob(job);
    executionHandler.endJob(context, getParameters().getStatus());
    if (getParameters().isForce()) {
        // mark job as auto-cleared
        job.setAutoCleared(true);
        jobDao.update(job);
        // Set all job steps and sub steps that were not completed as ABORTED
        jobRepository.closeCompletedJobSteps(job.getId(), JobExecutionStatus.ABORTED);
    }
    setSucceeded(true);
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext)

Aggregations

ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)27 Step (org.ovirt.engine.core.common.job.Step)14 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)9 HashMap (java.util.HashMap)4 EngineContext (org.ovirt.engine.core.bll.context.EngineContext)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CommandMultiAsyncTasks (org.ovirt.engine.core.bll.CommandMultiAsyncTasks)1 HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)1 SetStoragePoolStatusParameters (org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters)1 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)1 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)1 InstallVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters)1 EndedTaskInfo (org.ovirt.engine.core.common.asynctasks.EndedTaskInfo)1 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)1 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)1