use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class RemoveVmTemplateCommand method removeVmTemplateImages.
protected boolean removeVmTemplateImages() {
getParameters().setEntityInfo(getParameters().getEntityInfo());
getParameters().setParentCommand(getActionType());
getParameters().setParentParameters(getParameters());
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveAllVmTemplateImageTemplates, getParameters());
if (!actionReturnValue.getSucceeded()) {
setSucceeded(false);
getReturnValue().setFault(actionReturnValue.getFault());
return false;
}
getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
return true;
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class RestoreStatelessVmCommand method detachDisksNotPartOfStatelessSnapshot.
private boolean detachDisksNotPartOfStatelessSnapshot(List<DiskImage> statelessDiskSnapshots) {
Guid activeVmSnapshotId = getVmSnapshotIdForType(SnapshotType.ACTIVE);
List<DiskImage> activeDiskSnapshots = getDiskSnapshotsForVmSnapshot(activeVmSnapshotId);
Set<Guid> disksWithStatelessSnapshot = statelessDiskSnapshots.stream().map(DiskImage::getId).collect(Collectors.toSet());
for (DiskImage activeDiskSnapshot : activeDiskSnapshots) {
if (!disksWithStatelessSnapshot.contains(activeDiskSnapshot.getId())) {
ActionReturnValue returnValue = runInternalAction(ActionType.DetachDiskFromVm, buildDetachDetachVmDiskParameters(activeDiskSnapshot));
if (!returnValue.getSucceeded()) {
log.error("Could not restore stateless VM {} due to a failure to detach Disk {}", getVmId(), activeDiskSnapshot.getId());
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class PrevalidatingMultipleActionsRunner method initCommandsAndReturnValues.
private void initCommandsAndReturnValues(List<ActionReturnValue> returnValues) {
ActionReturnValue returnValue;
for (ActionParametersBase parameter : getParameters()) {
parameter.setMultipleAction(true);
returnValue = ExecutionHandler.evaluateCorrelationId(parameter);
if (returnValue == null) {
getCommands().add(commandFactory.createWrappedCommand(commandContext, actionType, parameter, isInternal));
} else {
returnValues.add(returnValue);
}
}
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method applyNextRunConfiguration.
/**
* Update VM configuration with NEXT_RUN configuration, if exists.
*/
private void applyNextRunConfiguration() {
// Remove snpashot first, in case other update is in progress, it will block this one with exclusive lock
// and any newer update should be preffered to this one.
Snapshot runSnap = snapshotDao.get(getVmId(), SnapshotType.NEXT_RUN);
if (runSnap != null && getVm().getStatus() != VMStatus.Suspended) {
log.debug("Attempt to apply NEXT_RUN snapshot for VM '{}'", getVmId());
EngineLock updateVmLock = createUpdateVmLock();
if (lockManager.acquireLock(updateVmLock).getFirst()) {
snapshotDao.remove(runSnap.getId());
Date originalCreationDate = getVm().getVmCreationDate();
snapshotsManager.updateVmFromConfiguration(getVm(), runSnap.getVmConfiguration());
// override creation date because the value in the config is the creation date of the config, not the vm
getVm().setVmCreationDate(originalCreationDate);
ActionReturnValue result = runInternalAction(ActionType.UpdateVm, createUpdateVmParameters(), ExecutionHandler.createInternalJobContext(updateVmLock));
if (result.getActionReturnValue() != null && result.getActionReturnValue().equals(ActionType.UpdateVmVersion)) {
// Template-version changed
templateVersionChanged = true;
}
} else {
log.warn("Could not acquire lock for UpdateVmCommand to apply Next Run Config of VM '{}'", getVmId());
}
}
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class RebootVmCommand method perform.
@Override
protected void perform() {
if (isColdReboot()) {
ActionReturnValue returnValue = runInternalAction(ActionType.ShutdownVm, new ShutdownVmParameters(getVmId(), false));
setReturnValue(returnValue);
setSucceeded(returnValue.getSucceeded());
if (getSucceeded()) {
resourceManager.getVmManager(getVmId()).setColdReboot(true);
}
} else {
final VDSReturnValue returnValue = runVdsCommand(VDSCommandType.RebootVm, new VdsAndVmIDVDSParametersBase(getVdsId(), getVmId()));
setActionReturnValue(returnValue.getReturnValue());
setSucceeded(returnValue.getSucceeded());
}
}
Aggregations