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);
}
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);
}
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;
}
}
}
}
}
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()));
}
}
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);
}
Aggregations