use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterBrickValidator method canStopOrCommitRemoveBrick.
public ValidationResult canStopOrCommitRemoveBrick(GlusterVolumeEntity volumeEntity, List<GlusterBrickEntity> paramBricks) {
GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
if (asyncTask == null || asyncTask.getType() != GlusterTaskType.REMOVE_BRICK) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID_TASK_TYPE);
}
if (paramBricks.isEmpty()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
}
List<GlusterBrickEntity> bricksForTask = getGlusterBrickDao().getGlusterVolumeBricksByTaskId(asyncTask.getTaskId());
if (paramBricks.size() != bricksForTask.size() || !areBricksInTheList(volumeEntity, paramBricks, bricksForTask)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID, String.format("$validBricks [%s]", getValidBrickNames(bricksForTask)));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method updateGlusterAsyncTasks.
@OnTimerMethodAnnotation("gluster_async_task_poll_event")
public void updateGlusterAsyncTasks() {
log.debug("Refreshing gluster tasks list");
List<Cluster> clusters = clusterDao.getAll();
Map<Guid, Set<Guid>> tasksFromClustersMap = new HashMap<>();
for (Cluster cluster : clusters) {
if (!cluster.supportsGlusterService()) {
continue;
}
try {
Map<Guid, GlusterAsyncTask> runningTasks = provider.getTaskListForCluster(cluster.getId());
if (runningTasks != null) {
updateTasksInCluster(cluster, runningTasks);
tasksFromClustersMap.put(cluster.getId(), runningTasks.keySet());
}
} catch (EngineException e) {
log.error("Error updating tasks from CLI", e);
}
}
cleanUpOrphanTasks(tasksFromClustersMap);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method updateTasksInCluster.
private void updateTasksInCluster(final Cluster cluster, final Map<Guid, GlusterAsyncTask> runningTasks) {
for (Entry<Guid, GlusterAsyncTask> entry : runningTasks.entrySet()) {
Guid taskId = entry.getKey();
final GlusterAsyncTask task = entry.getValue();
List<Step> steps = stepDao.getStepsByExternalId(taskId);
if (steps.isEmpty()) {
createJobForTaskFromCLI(cluster, task);
}
glusterTaskUtils.updateSteps(cluster, task, steps);
}
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterTasksService method getTaskListForCluster.
public Map<Guid, GlusterAsyncTask> getTaskListForCluster(Guid id) {
VDS upServer = glusterUtil.getRandomUpServer(id);
if (upServer == null) {
log.info("No up server in cluster");
return null;
}
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterTasksList, new VdsIdVDSCommandParametersBase(upServer.getId()));
if (returnValue.getSucceeded()) {
List<GlusterAsyncTask> tasks = (List<GlusterAsyncTask>) returnValue.getReturnValue();
Map<Guid, GlusterAsyncTask> tasksMap = new HashMap<>();
for (GlusterAsyncTask task : tasks) {
tasksMap.put(task.getTaskId(), task);
}
return tasksMap;
} else {
log.error("Error: {}", returnValue.getVdsError());
throw new EngineException(EngineError.GlusterVolumeStatusAllFailedException, returnValue.getVdsError().getMessage());
}
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class StartRebalanceGlusterVolumeCommand method executeCommand.
@Override
protected void executeCommand() {
startSubStep();
VDSReturnValue taskReturn = runVdsCommand(VDSCommandType.StartRebalanceGlusterVolume, new GlusterVolumeRebalanceVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().isFixLayoutOnly(), getParameters().isForceAction()));
setSucceeded(taskReturn.getSucceeded());
if (!getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_REBALANCE_START_FAILED, taskReturn.getVdsError().getMessage());
return;
}
GlusterAsyncTask glusterTask = (GlusterAsyncTask) taskReturn.getReturnValue();
handleTaskReturn(glusterTask);
updateVolumeWithTaskID(glusterTask);
getReturnValue().setActionReturnValue(glusterTask);
}
Aggregations