use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class Backend method evaluateCorrelationId.
protected ActionReturnValue evaluateCorrelationId(CommandBase<?> commandBase) {
ActionParametersBase cmdParams = commandBase.getParameters();
if (cmdParams.getCorrelationId() == null && cmdParams.getParentParameters() != null) {
cmdParams.setCorrelationId(cmdParams.getParentParameters().getCorrelationId());
}
// Evaluate and set the correlationId on the parameters, fails on invalid correlation id
ActionReturnValue returnValue = ExecutionHandler.evaluateCorrelationId(cmdParams);
if (returnValue != null) {
log.warn("Validation of action '{}' failed. Reasons: {}", commandBase.getActionType(), StringUtils.join(returnValue.getValidationMessages(), ','));
}
// Set the correlation-id on the command
commandBase.setCorrelationId(cmdParams.getCorrelationId());
return returnValue;
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class RunVmCommand method createStatelessSnapshot.
private void createStatelessSnapshot() {
warnIfNotAllDisksPermitSnapshots();
log.info("Creating stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
CreateSnapshotForVmParameters createAllSnapshotsFromVmParameters = buildCreateSnapshotParameters();
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshotForVm, createAllSnapshotsFromVmParameters, createContextForStatelessSnapshotCreation());
// setting lock to null in order not to release lock twice
setLock(null);
setSucceeded(actionReturnValue.getSucceeded());
if (!actionReturnValue.getSucceeded()) {
if (areDisksLocked(actionReturnValue)) {
throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
}
getReturnValue().setFault(actionReturnValue.getFault());
log.error("Failed to create stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
}
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class RunVmCommand method endWithFailure.
@Override
protected void endWithFailure() {
if (shouldEndSnapshotCreation()) {
ActionReturnValue actionReturnValue = backend.endAction(ActionType.CreateSnapshotForVm, getParameters().getImagesParameters().get(0), cloneContext().withoutExecutionContext().withoutLock());
setSucceeded(actionReturnValue.getSucceeded());
// we are not running the VM, of course,
// since we couldn't create a snapshot.
} else {
super.endWithFailure();
}
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class UpdateVmCommand method hotPlugMemoryDevice.
private void hotPlugMemoryDevice(int currentMemoryMb, int newAmountOfMemoryMb) {
HotSetAmountOfMemoryParameters params = new HotSetAmountOfMemoryParameters(newVmStatic, currentMemoryMb < newAmountOfMemoryMb ? PlugAction.PLUG : PlugAction.UNPLUG, // We always use node 0, auto-numa should handle the allocation
0, newAmountOfMemoryMb - currentMemoryMb);
ActionReturnValue setAmountOfMemoryResult = runInternalAction(ActionType.HotSetAmountOfMemory, params, cloneContextAndDetachFromParent());
// into the OVF store and automatically used during the next HE VM start
if (!getVm().isHostedEngine()) {
newVmStatic.setMemSizeMb(setAmountOfMemoryResult.getSucceeded() ? newAmountOfMemoryMb : currentMemoryMb);
}
logHotSetActionEvent(setAmountOfMemoryResult, AuditLogType.FAILED_HOT_SET_MEMORY);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class UpdateVmCommand method updateRngDevice.
private void updateRngDevice() {
if (!getParameters().isUpdateRngDevice()) {
return;
}
QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId()));
List<VmRngDevice> rngDevs = query.getReturnValue();
ActionReturnValue rngCommandResult = null;
if (rngDevs.isEmpty()) {
if (getParameters().getRngDevice() != null) {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
}
} else {
if (getParameters().getRngDevice() == null) {
RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true);
rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
} else {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
}
}
if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
log.error("Updating RNG device of VM {} ({}) failed. Old RNG device = {}. New RNG device = {}.", getVm().getName(), getVm().getId(), rngDevs.isEmpty() ? null : rngDevs.get(0), getParameters().getRngDevice());
}
}
Aggregations