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