Search in sources :

Example 21 with ExecutionContext

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

the class RunVmCommand method endExecutionMonitoring.

@Override
protected void endExecutionMonitoring() {
    if (getVm().isRunAndPause() && vmDynamicDao.get(getVmId()).getStatus() == VMStatus.Paused) {
        final ExecutionContext executionContext = getExecutionContext();
        executionContext.setShouldEndJob(true);
        executionHandler.endJob(executionContext, true);
    } else {
        super.endExecutionMonitoring();
    }
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext)

Example 22 with ExecutionContext

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

the class RunVmCommandBase method reportCompleted.

@Override
public void reportCompleted() {
    try {
        // decrease pending resources if they were not decreased already
        decreasePendingVm();
        // end the execution job if needed
        ExecutionContext executionContext = getExecutionContext();
        if (executionContext != null && executionContext.isMonitored() && !executionContext.isCompleted()) {
            endExecutionMonitoring();
        }
    } finally {
        freeLock();
    }
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext)

Example 23 with ExecutionContext

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

the class RunVmOnceCommand method endExecutionMonitoring.

@Override
protected void endExecutionMonitoring() {
    ExecutionContext executionContext = getExecutionContext();
    executionContext.setShouldEndJob(true);
    boolean runAndPausedSucceeded = Boolean.TRUE.equals(getParameters().getRunAndPause()) && vmDynamicDao.get(getVmId()).getStatus() == VMStatus.Paused;
    executionHandler.endJob(executionContext, runAndPausedSucceeded);
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext)

Example 24 with ExecutionContext

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

the class MaintenanceVdsCommand method createMigrateVmContext.

protected CommandContext createMigrateVmContext(ExecutionContext parentContext, VM vm) {
    ExecutionContext ctx = new ExecutionContext();
    try {
        Map<String, String> values = new HashMap<>();
        values.put(VdcObjectType.VM.name().toLowerCase(), vm.getName());
        values.put(VdcObjectType.VDS.name().toLowerCase(), vm.getRunOnVdsName());
        Step step = executionHandler.addSubStep(getExecutionContext(), parentContext.getJob().getStep(StepEnum.EXECUTING), StepEnum.MIGRATE_VM, ExecutionMessageDirector.resolveStepMessage(StepEnum.MIGRATE_VM, values));
        ctx.setJob(parentContext.getJob());
        ctx.setStep(step);
        ctx.setMonitored(true);
    } catch (RuntimeException e) {
        log.error("Failed to create ExecutionContext for MigrateVmCommand", e);
    }
    return cloneContextAndDetachFromParent().withExecutionContext(ctx);
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) HashMap(java.util.HashMap) Step(org.ovirt.engine.core.common.job.Step)

Example 25 with ExecutionContext

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

the class AddUnmanagedVmsCommand method createAddExternalVmContext.

protected CommandContext createAddExternalVmContext(VmStatic vmStatic) {
    ExecutionContext ctx = new ExecutionContext();
    try {
        Step step = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.ADD_VM, ExecutionMessageDirector.resolveStepMessage(StepEnum.ADD_VM, Collections.singletonMap(VdcObjectType.VM.name().toLowerCase(), vmStatic.getName())));
        ctx.setJob(getExecutionContext().getJob());
        ctx.setStep(step);
        ctx.setMonitored(true);
    } catch (RuntimeException e) {
        log.error("Failed to create ExecutionContext for AddVmFromScratch", e);
    }
    return cloneContextAndDetachFromParent().withExecutionContext(ctx);
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) Step(org.ovirt.engine.core.common.job.Step)

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