Search in sources :

Example 71 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class RestoreGlusterVolumeSnapshotCommand method resumeGeoRepSessions.

private boolean resumeGeoRepSessions(List<GlusterGeoRepSession> geoRepSessions) {
    for (GlusterGeoRepSession session : geoRepSessions) {
        GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
        if (slaveVolume == null) {
            // continue with other sessions and try to pause
            continue;
        }
        try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
            ActionReturnValue retVal = runInternalAction(ActionType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
            if (!retVal.getSucceeded()) {
                handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, retVal.getExecuteFailedMessages().toString());
                setSucceeded(false);
                return false;
            }
        }
    }
    return true;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock)

Example 72 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class RestoreGlusterVolumeSnapshotCommand method restoreVolumeToSnapshot.

private boolean restoreVolumeToSnapshot(Guid upServerId, GlusterVolumeEntity volume, String snapshotName) {
    if (volume != null) {
        VDSReturnValue retVal = runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(upServerId, volume.getName(), snapshotName));
        if (!retVal.getSucceeded()) {
            handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage());
            setSucceeded(false);
            return false;
        } else {
            glusterVolumeSnapshotDao.removeByName(volume.getId(), snapshotName);
            // Sync the new bricks of the volume immediately
            VDS upServer = glusterUtil.getRandomUpServer(volume.getClusterId());
            VDSReturnValue volDetailsRetVal = runVdsCommand(VDSCommandType.GetGlusterVolumeInfo, new GlusterVolumeInfoVDSParameters(upServer.getId(), volume.getClusterId(), volume.getName()));
            GlusterVolumeEntity fetchedVolume = ((Map<Guid, GlusterVolumeEntity>) volDetailsRetVal.getReturnValue()).get(volume.getId());
            List<GlusterBrickEntity> fetchedBricks = fetchedVolume.getBricks();
            if (fetchedBricks != null) {
                glusterBrickDao.removeAllInBatch(volume.getBricks());
                for (GlusterBrickEntity fetchdBrick : fetchedVolume.getBricks()) {
                    if (fetchdBrick.getServerId() != null) {
                        fetchdBrick.setStatus(GlusterStatus.UP);
                        glusterBrickDao.save(fetchdBrick);
                    } else {
                        log.warn("Invalid server details for brick " + fetchdBrick.getName() + ". Not adding now.");
                    }
                }
            }
        }
    }
    return true;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeInfoVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) Map(java.util.Map) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 73 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class ScheduleGlusterVolumeSnapshotCommandBase method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    GlusterVolumeEntity volume = getGlusterVolume();
    if (volume != null && volume.getStatus() == GlusterStatus.DOWN) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN);
    }
    if (!glusterUtil.isVolumeThinlyProvisioned(volume)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED);
    }
    // Validate the scheduling dates (start and end by dates)
    Date convertedStartDate = glusterUtil.convertDate(schedule.getStartDate(), schedule.getTimeZone());
    Date convertedEndByDate = glusterUtil.convertDate(schedule.getEndByDate(), schedule.getTimeZone());
    if (schedule.getRecurrence() != null && schedule.getRecurrence() != GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN && schedule.getEndByDate() != null && convertedStartDate != null && convertedEndByDate.compareTo(convertedStartDate) <= 0) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE);
    }
    return true;
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Date(java.util.Date)

Example 74 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class GeorepEventSubscriber method processEvent.

@Override
public void processEvent(GlusterEvent event) {
    if (event == null) {
        log.debug("No event to process!");
        return;
    }
    GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(Guid.createGuidFromString(event.getNodeId()));
    if (glusterServer == null) {
        log.debug("Could not determine gluster server from event '{}'", event);
        return;
    }
    VdsStatic host = vdsStaticDao.get(glusterServer.getId());
    if (host == null) {
        log.debug("No host corresponding to gluster server in '{}'", event);
        return;
    }
    if (event.getEvent().equalsIgnoreCase(EVENT_GEOREP_CHECKPOINT_COMPLETED)) {
        GlusterVolumeEntity masterVol = glusterVolumeDao.getByName(host.getClusterId(), (String) event.getMessage().get(MASTER_VOLUME));
        if (masterVol == null) {
            log.debug("Could not determine master volume from event '{}'", event);
            return;
        }
        GlusterGeoRepSession session = geoRepDao.getGeoRepSession(masterVol.getId(), (String) event.getMessage().get(SLAVE_HOST), (String) event.getMessage().get(SLAVE_VOLUME));
        // hence forcing sync for now.
        if (session != null) {
            log.debug("received event for session '{}'", session.getSessionKey());
        }
        geoRepSyncJob.refreshGeoRepDataForVolume(masterVol);
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 75 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class StopRebalanceGlusterVolumeCommandTest method getvolumeWithoutRebalanceTask.

private Object getvolumeWithoutRebalanceTask(Guid volumeId) {
    GlusterVolumeEntity volume = getVolumeWithRebalanceTask(volumeId);
    volume.getAsyncTask().setType(null);
    return volume;
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Aggregations

GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)220 ArrayList (java.util.ArrayList)57 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)49 Test (org.junit.Test)47 Guid (org.ovirt.engine.core.compat.Guid)30 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)30 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)26 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)20 VDS (org.ovirt.engine.core.common.businessentities.VDS)19 HashMap (java.util.HashMap)16 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)16 List (java.util.List)15 Map (java.util.Map)15 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)15 ActionType (org.ovirt.engine.core.common.action.ActionType)13 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)13 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)13 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)13 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)12 GlusterTaskType (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType)12