Search in sources :

Example 1 with CreateGlusterVolumeSnapshotParameters

use of org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters 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)

Example 2 with CreateGlusterVolumeSnapshotParameters

use of org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters 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)

Aggregations

CreateGlusterVolumeSnapshotParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters)2 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)2 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 GlusterVolumeSnapshotSchedule (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule)1 Guid (org.ovirt.engine.core.compat.Guid)1 OnTimerMethodAnnotation (org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)1