use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotScheduleDaoTest method testGetByVolumeId.
@Test
public void testGetByVolumeId() {
GlusterVolumeSnapshotSchedule schedule = dao.getByVolumeId(VOLUME_ID_1);
assertNotNull(schedule);
assertEquals(schedule, existingSchedule);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotScheduleDaoTest method insertSnapshotSchedule.
private GlusterVolumeSnapshotSchedule insertSnapshotSchedule() {
GlusterVolumeSnapshotSchedule schedule = new GlusterVolumeSnapshotSchedule();
schedule.setClusterId(CLUSTER_ID);
schedule.setVolumeId(VOLUME_ID_2);
schedule.setJobId("test_job_id");
schedule.setSnapshotNamePrefix("prefix");
schedule.setSnapshotDescription("desc");
schedule.setInterval(0);
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.DAILY);
schedule.setTimeZone("Asia/Calcutta");
schedule.setExecutionTime(new Time(10, 30, 0));
schedule.setEndByDate(null);
dao.save(schedule);
return schedule;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotScheduleDaoTest method testSaveAndGetByVolumeId.
@Test
public void testSaveAndGetByVolumeId() {
GlusterVolumeSnapshotSchedule schedule = dao.getByVolumeId(VOLUME_ID_2);
assertNull(schedule);
newSchedule = insertSnapshotSchedule();
schedule = dao.getByVolumeId(VOLUME_ID_2);
assertNotNull(schedule);
assertEquals(schedule, newSchedule);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule 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()));
}
}
Aggregations