Search in sources :

Example 21 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotDaoTest method testUpdateSnapshotStatus.

@Test
public void testUpdateSnapshotStatus() {
    dao.updateSnapshotStatus(existingSnapshot.getSnapshotId(), GlusterSnapshotStatus.DEACTIVATED);
    GlusterVolumeSnapshotEntity snapshot = dao.getById(existingSnapshot.getSnapshotId());
    assertNotNull(snapshot);
    assertFalse(snapshot.equals(existingSnapshot));
    existingSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
    assertEquals(existingSnapshot, snapshot);
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) Test(org.junit.Test)

Example 22 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotListModel method onDeleteSnapshot.

private void onDeleteSnapshot() {
    if (getConfirmWindow() == null) {
        return;
    }
    final ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
    List<ActionParametersBase> paramsList = new ArrayList<>();
    for (GlusterVolumeSnapshotEntity snapshot : getSelectedItems()) {
        GlusterVolumeSnapshotActionParameters param = new GlusterVolumeSnapshotActionParameters(getEntity().getId(), snapshot.getSnapshotName(), true);
        paramsList.add(param);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.DeleteGlusterVolumeSnapshot, paramsList, result -> {
        model.stopProgress();
        setConfirmWindow(null);
    }, model);
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeSnapshotActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 23 with GlusterVolumeSnapshotEntity

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

the class CreateGlusterVolumeSnapshotCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterVolumeEntity volume = getGlusterVolume();
    // Pause geo-rep sessions and create snapshot for slave volumes
    Boolean tranRetVal = TransactionSupport.executeInNewTransaction(() -> pauseAndCreateSnapshotForGeoRepSessions());
    if (!tranRetVal) {
        return;
    }
    // Create snapshot for the master volume
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(upServer.getId(), volume.getName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
    setSucceeded(retVal.getSucceeded());
    if (!retVal.getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, retVal.getVdsError().getMessage());
    } else {
        GlusterVolumeSnapshotEntity createdSnapshot = (GlusterVolumeSnapshotEntity) retVal.getReturnValue();
        createdSnapshot.setClusterId(snapshot.getClusterId());
        createdSnapshot.setVolumeId(snapshot.getVolumeId());
        createdSnapshot.setDescription(snapshot.getDescription());
        createdSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
        glusterVolumeSnapshotDao.save(createdSnapshot);
        addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, createdSnapshot.getSnapshotName());
        // check if the snapshot soft limit reached now for the volume and alert
        glusterUtil.alertVolumeSnapshotLimitsReached(getGlusterVolume());
    }
    // Resume the snapshot paused sessions by engine
    for (GlusterGeoRepSession session : enginePausedSessions) {
        if (session.getStatus() == GeoRepSessionStatus.PAUSED) {
            try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
                ActionReturnValue sessionResumeRetVal = runInternalAction(ActionType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(volume.getId(), session.getId()));
                if (!sessionResumeRetVal.getSucceeded()) {
                    handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, sessionResumeRetVal.getExecuteFailedMessages());
                    setSucceeded(false);
                    return;
                }
            }
        }
    }
}
Also used : CreateGlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) 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) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 24 with GlusterVolumeSnapshotEntity

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

the class GlusterSnapshotScheduleJob method onTimer.

@OnTimerMethodAnnotation("onTimer")
public void onTimer(String serverId, String volumeId, String snapshotNamePrefix, String description, boolean force) {
    final GlusterVolumeEntity volume = glusterVolumeDao.getById(new Guid(volumeId));
    if (volume == null) {
        log.error("Error while creating volume snapshot. Volume is null.");
        return;
    }
    final GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
    snapshot.setClusterId(volume.getClusterId());
    snapshot.setVolumeId(volume.getId());
    snapshot.setSnapshotName(snapshotNamePrefix);
    snapshot.setDescription(description);
    ActionReturnValue returnValue = backend.runInternalAction(ActionType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotParameters(snapshot, force));
    if (!returnValue.getSucceeded()) {
        log.error("Error while creating snapshot for volume '{}': {}", volume.getName(), returnValue.getExecuteFailedMessages().toString());
        Map<String, String> customValues = new HashMap<>();
        customValues.put(GlusterConstants.VOLUME_SNAPSHOT_NAME, snapshot.getSnapshotName());
        customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
        logUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, customValues);
    }
    // Check if next schedule available, and if not delete the scheduling details from DB
    GlusterVolumeSnapshotSchedule schedule = glusterVolumeSnapshotScheduleDao.getByVolumeId(volume.getId());
    Date endDate = glusterUtil.convertDate(schedule.getEndByDate(), schedule.getTimeZone());
    if (endDate != null && endDate.before(new Date())) {
        glusterVolumeSnapshotScheduleDao.removeByVolumeId(volume.getId());
        logUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_SCHEDULE_DELETED, Collections.singletonMap(GlusterConstants.VOLUME_NAME, volume.getName()));
    }
}
Also used : GlusterVolumeSnapshotSchedule(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule) CreateGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HashMap(java.util.HashMap) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) Guid(org.ovirt.engine.core.compat.Guid) Date(java.util.Date) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 25 with GlusterVolumeSnapshotEntity

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

the class GlusterSnapshotSyncJob method deleteSnapshots.

private void deleteSnapshots(List<GlusterVolumeSnapshotEntity> snaphosts) {
    List<Guid> deletedIds = new ArrayList<>();
    for (GlusterVolumeSnapshotEntity snapshot : snaphosts) {
        deletedIds.add(snapshot.getId());
    }
    volumeSnapshotDao.removeAll(deletedIds);
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

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