use of org.ovirt.engine.core.bll.context.CommandContext 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.context.CommandContext 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.context.CommandContext 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.context.CommandContext in project ovirt-engine by oVirt.
the class RemoveVmPoolCommand method createRemoveVmStepContext.
private CommandContext createRemoveVmStepContext(VM vm) {
CommandContext commandCtx = null;
try {
Map<String, String> values = Collections.singletonMap(VdcObjectType.VM.name().toLowerCase(), vm.getName());
Step removeVmStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.REMOVING_VM, ExecutionMessageDirector.resolveStepMessage(StepEnum.REMOVING_VM, values));
ExecutionContext ctx = new ExecutionContext();
ctx.setStep(removeVmStep);
ctx.setMonitored(true);
Map<String, Pair<String, String>> locks = new HashMap<>();
addVmLocks(vm, locks);
EngineLock engineLock = new EngineLock(locks, null);
commandCtx = cloneContext().withoutCompensationContext().withExecutionContext(ctx).withLock(engineLock);
} catch (RuntimeException e) {
log.error("Failed to create command context of removing VM '{}' that was in Pool '{}': {}", vm.getName(), getVmPoolName(), e.getMessage());
log.debug("Exception", e);
}
return commandCtx;
}
use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class CommonVmPoolCommand method createAddVmStepContext.
private CommandContext createAddVmStepContext(String currentVmName) {
CommandContext commandCtx = null;
try {
Map<String, String> values = new HashMap<>();
values.put(VdcObjectType.VM.name().toLowerCase(), currentVmName);
Step addVmStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.ADD_VM_TO_POOL, ExecutionMessageDirector.resolveStepMessage(StepEnum.ADD_VM_TO_POOL, values));
ExecutionContext ctx = new ExecutionContext();
ctx.setStep(addVmStep);
ctx.setMonitored(true);
commandCtx = cloneContextAndDetachFromParent().withExecutionContext(ctx);
} catch (RuntimeException e) {
log.error("Failed to create command context of adding VM '{}' to Pool '{}': {}", currentVmName, getParameters().getVmPool().getName(), e.getMessage());
log.debug("Exception", e);
}
return commandCtx;
}
Aggregations