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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations