Search in sources :

Example 1 with GlusterVolumeSnapshotEntity

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

the class CreateGlusterVolumeSnapshotCommand method pauseAndCreateSnapshotForGeoRepSessions.

private boolean pauseAndCreateSnapshotForGeoRepSessions() {
    if (georepSessions != null && georepSessions.size() > 0) {
        for (GlusterGeoRepSession session : georepSessions) {
            final GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
            if (slaveVolume == null) {
                // Continue to other geo-rep sessions and pause them for snapshot purpose
                continue;
            }
            VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
            if (slaveUpServer == null) {
                handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, "No up server found in slave cluster of geo-rep session");
                setSucceeded(false);
                return false;
            }
            // Pause the geo-rep session if required
            if (!(session.getStatus() == GeoRepSessionStatus.CREATED || session.getStatus() == GeoRepSessionStatus.PAUSED || session.getStatus() == GeoRepSessionStatus.STOPPED)) {
                ActionReturnValue sessionPauseRetVal = null;
                try (EngineLock lock = acquireEngineLock(slaveVolume.getId(), LockingGroup.GLUSTER_SNAPSHOT)) {
                    sessionPauseRetVal = runInternalAction(ActionType.PauseGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
                }
                if (sessionPauseRetVal != null && !sessionPauseRetVal.getSucceeded()) {
                    handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED, sessionPauseRetVal.getExecuteFailedMessages());
                    setSucceeded(false);
                    return false;
                }
                session.setStatus(GeoRepSessionStatus.PAUSED);
                enginePausedSessions.add(session);
            }
            // Create snapshot for slave volume
            VDSReturnValue snapCreationRetVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(slaveUpServer.getId(), session.getSlaveVolumeName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
            if (!snapCreationRetVal.getSucceeded()) {
                handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, snapCreationRetVal.getVdsError().getMessage());
                setSucceeded(false);
                return false;
            } else {
                // Persist the snapshot details
                GlusterVolumeSnapshotEntity slaveVolumeSnapshot = (GlusterVolumeSnapshotEntity) snapCreationRetVal.getReturnValue();
                slaveVolumeSnapshot.setClusterId(slaveVolume.getClusterId());
                slaveVolumeSnapshot.setVolumeId(slaveVolume.getId());
                slaveVolumeSnapshot.setDescription(snapshot.getDescription());
                slaveVolumeSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
                glusterVolumeSnapshotDao.save(slaveVolumeSnapshot);
                // check if the snapshot soft limit reached now for the volume and alert
                glusterUtil.alertVolumeSnapshotLimitsReached(slaveVolume);
            }
        }
    }
    return true;
}
Also used : CreateGlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) 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) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with GlusterVolumeSnapshotEntity

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

the class DeleteAllGlusterVolumeSnapshotsCommand method deleteAllGlusterVolumeSnapshots.

private boolean deleteAllGlusterVolumeSnapshots(Guid serverId, String volumeName, List<GlusterVolumeSnapshotEntity> snapshotsList) {
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.DeleteAllGlusterVolumeSnapshots, new GlusterVolumeVDSParameters(serverId, volumeName));
    setSucceeded(retVal.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED, retVal.getVdsError().getMessage());
    } else {
        List<Guid> guids = new ArrayList<>();
        for (GlusterVolumeSnapshotEntity snapshot : snapshotsList) {
            guids.add(snapshot.getId());
        }
        glusterVolumeSnapshotDao.removeAll(guids);
    }
    return true;
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) GlusterVolumeVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with GlusterVolumeSnapshotEntity

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

the class DeleteAllGlusterVolumeSnapshotsCommand method executeCommand.

@Override
public void executeCommand() {
    if (georepSessions != null) {
        for (GlusterGeoRepSession session : georepSessions) {
            GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
            if (slaveVolume == null) {
                // continue with other sessions and try to pause
                continue;
            }
            VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
            if (slaveUpServer == null) {
                handleVdsError(AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED, EngineError.NoUpServerFoundInRemoteCluster.name());
                setSucceeded(false);
                return;
            }
            List<GlusterVolumeSnapshotEntity> slaveVolumeSnapshots = glusterVolumeSnapshotDao.getAllByVolumeId(slaveVolume.getId());
            try (EngineLock lock = acquireEngineLock(session.getSlaveVolumeId(), LockingGroup.GLUSTER_SNAPSHOT)) {
                if (!deleteAllGlusterVolumeSnapshots(slaveUpServer.getId(), slaveVolume.getName(), slaveVolumeSnapshots)) {
                    return;
                }
                // Check and remove soft limit alert for the volume
                glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(slaveVolume);
            }
        }
    }
    deleteAllGlusterVolumeSnapshots(getUpServer().getId(), getGlusterVolumeName(), snapshots);
    // Check and remove soft limit alert for the volume
    glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(getGlusterVolume());
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock)

Example 4 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotCreateReturn method prepareSnapshtoDetail.

private GlusterVolumeSnapshotEntity prepareSnapshtoDetail(Map<String, Object> map) {
    GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
    snapshot.setSnapshotId(Guid.createGuidFromString((String) map.get(UUID)));
    snapshot.setSnapshotName((String) map.get(NAME));
    snapshot.setCreatedAt(new Date());
    return snapshot;
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) Date(java.util.Date)

Example 5 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotListModel method createNewSnapshot.

private void createNewSnapshot(final GlusterVolumeSnapshotModel snapshotModel) {
    GlusterVolumeEntity volumeEntity = getEntity();
    final GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
    snapshot.setClusterId(volumeEntity.getClusterId());
    snapshot.setSnapshotName(snapshotModel.getSnapshotName().getEntity());
    snapshot.setVolumeId(volumeEntity.getId());
    snapshot.setDescription(snapshotModel.getDescription().getEntity());
    CreateGlusterVolumeSnapshotParameters parameter = new CreateGlusterVolumeSnapshotParameters(snapshot, false);
    snapshotModel.startProgress();
    Frontend.getInstance().runAction(ActionType.CreateGlusterVolumeSnapshot, parameter, result -> {
        GlusterVolumeSnapshotListModel localModel = (GlusterVolumeSnapshotListModel) result.getState();
        snapshotModel.stopProgress();
        localModel.postSnapshotAction(result.getReturnValue());
    }, this);
}
Also used : CreateGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)

Aggregations

GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)25 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)12 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 Guid (org.ovirt.engine.core.compat.Guid)6 Date (java.util.Date)5 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)3 HashMap (java.util.HashMap)2 CreateGlusterVolumeSnapshotParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters)2 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Map (java.util.Map)1