use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotListModel method deleteSnapshot.
private void deleteSnapshot() {
if (getSelectedItems() == null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
List<GlusterVolumeSnapshotEntity> snapshots = getSelectedItems();
StringBuilder snapshotNames = new StringBuilder();
for (GlusterVolumeSnapshotEntity snapshot : snapshots) {
snapshotNames.append(snapshot.getSnapshotName());
// $NON-NLS-1$
snapshotNames.append("\n");
}
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getMessages().confirmRemoveSnapshot(getEntity().getName()));
model.setHelpTag(HelpTag.volume_delete_snapshot_confirmation);
// $NON-NLS-1$
model.setHashName("volume_delete_snapshot_confirmation");
model.setMessage(ConstantsManager.getInstance().getMessages().confirmVolumeSnapshotDeleteMessage(snapshotNames.toString()));
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("onDeleteSnapshot", this);
model.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("cancelConfirmation", this);
model.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class SubTabGlusterVolumeSnapshotView method initTable.
void initTable() {
getTable().enableColumnResizing();
GlusterVolumeSnapshotStatusColumn snapshotStatusColumn = new GlusterVolumeSnapshotStatusColumn();
snapshotStatusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(snapshotStatusColumn, constants.empty(), "30px");
AbstractTextColumn<GlusterVolumeSnapshotEntity> snapshotNameColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {
@Override
public String getValue(GlusterVolumeSnapshotEntity snapshot) {
return snapshot.getSnapshotName();
}
};
snapshotNameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(snapshotNameColumn, constants.volumeSnapshotName(), "300px");
AbstractTextColumn<GlusterVolumeSnapshotEntity> descriptionColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {
@Override
public String getValue(GlusterVolumeSnapshotEntity snapshot) {
return snapshot.getDescription();
}
};
descriptionColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.volumeSnapshotDescription(), "400px");
AbstractTextColumn<GlusterVolumeSnapshotEntity> creationTimeColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {
@Override
public String getValue(GlusterVolumeSnapshotEntity snapshot) {
// $NON-NLS-1$
DateTimeFormat df = DateTimeFormat.getFormat("yyyy-MM-dd, HH:mm:ss");
return df.format(snapshot.getCreatedAt());
}
};
creationTimeColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(creationTimeColumn, constants.volumeSnapshotCreationTime(), "400px");
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterSnapshotSyncJob method refreshSnapshotsInCluster.
private void refreshSnapshotsInCluster(Cluster cluster) {
if (!supportsGlusterSnapshotFeature(cluster)) {
return;
}
final VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
if (upServer == null) {
log.info("No UP server found in cluster '{}' for snapshot monitoring", cluster.getName());
return;
}
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeSnapshotInfo, new GlusterVolumeSnapshotVDSParameters(upServer.getId(), cluster.getId(), null));
if (returnValue.getSucceeded()) {
addOrUpdateSnapshots(cluster.getId(), (ArrayList<GlusterVolumeSnapshotEntity>) returnValue.getReturnValue());
// check if the snapshot soft limit reached for a volume and alert
List<GlusterVolumeEntity> volumes = volumeDao.getByClusterId(cluster.getId());
for (final GlusterVolumeEntity volume : volumes) {
// check if the snapshot soft limit reached for the volume and alert
glusterUtil.alertVolumeSnapshotLimitsReached(volume);
// Check and remove soft limit alert for the volume.
// It might have fallen below the soft limit as part of deletions of snapshots
glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(volume);
}
} else {
log.error("VDS Error {}", returnValue.getVdsError().getMessage());
log.debug("VDS Error {}", returnValue.getVdsError());
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterSnapshotSyncJob method addOrUpdateSnapshots.
private void addOrUpdateSnapshots(Guid clusterId, List<GlusterVolumeSnapshotEntity> fetchedSnapshots) {
Map<Guid, GlusterVolumeSnapshotEntity> fetchedSnapshotsMap = new HashMap<>();
for (GlusterVolumeSnapshotEntity fetchedSnapshot : fetchedSnapshots) {
fetchedSnapshotsMap.put(fetchedSnapshot.getId(), fetchedSnapshot);
}
Cluster cluster = clusterDao.get(clusterId);
List<GlusterVolumeSnapshotEntity> existingSnapshots = volumeSnapshotDao.getAllByClusterId(clusterId);
Map<Guid, GlusterVolumeSnapshotEntity> existingSnapshotsMap = new HashMap<>();
for (GlusterVolumeSnapshotEntity existingSnapshot : existingSnapshots) {
existingSnapshotsMap.put(existingSnapshot.getId(), existingSnapshot);
}
List<GlusterVolumeSnapshotEntity> updatedSnapshots = new ArrayList<>();
List<GlusterVolumeSnapshotEntity> newlyAddedSnapshots = new ArrayList<>();
List<GlusterVolumeSnapshotEntity> deletedSnapshots = new ArrayList<>();
for (final GlusterVolumeSnapshotEntity fetchedSnapshot : fetchedSnapshots) {
GlusterVolumeSnapshotEntity correspondingExistingSnapshot = existingSnapshotsMap.get(fetchedSnapshot.getId());
if (correspondingExistingSnapshot == null) {
final GlusterVolumeEntity volume = volumeDao.getById(fetchedSnapshot.getVolumeId());
newlyAddedSnapshots.add(fetchedSnapshot);
log.debug("Detected new gluster volume snapshot '{}' for volume '{}' on cluster: '{}'", fetchedSnapshot.getSnapshotName(), volume.getName(), cluster.getName());
Map<String, String> customValues = new HashMap<>();
customValues.put("snapName", fetchedSnapshot.getSnapshotName());
customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
logUtil.logAuditMessage(clusterId, volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DETECTED_NEW, customValues);
} else if (correspondingExistingSnapshot.getStatus() != fetchedSnapshot.getStatus()) {
correspondingExistingSnapshot.setStatus(fetchedSnapshot.getStatus());
updatedSnapshots.add(correspondingExistingSnapshot);
}
}
for (final GlusterVolumeSnapshotEntity existingSnapshot : existingSnapshots) {
GlusterVolumeSnapshotEntity correspondingFetchedSnapshot = fetchedSnapshotsMap.get(existingSnapshot.getId());
if (correspondingFetchedSnapshot == null) {
final GlusterVolumeEntity volume = volumeDao.getById(existingSnapshot.getVolumeId());
deletedSnapshots.add(existingSnapshot);
log.debug("Gluster volume snapshot '{}' detected removed for volume '{}' on cluster: '{}'", existingSnapshot.getSnapshotName(), volume.getName(), cluster.getName());
Map<String, String> customValues = new HashMap<>();
customValues.put("snapName", existingSnapshot.getSnapshotName());
customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
logUtil.logAuditMessage(clusterId, volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETED_FROM_CLI, customValues);
}
}
// update snapshot details
try (EngineLock lock = acquireVolumeSnapshotLock(clusterId)) {
saveNewSnapshots(newlyAddedSnapshots);
updateSnapshots(updatedSnapshots);
deleteSnapshots(deletedSnapshots);
} catch (Exception e) {
log.error("Exception ocuured while adding/updating snapshots from CLI - '{}'", e.getMessage());
log.debug("Exception", e);
throw new EngineException(EngineError.GlusterSnapshotInfoFailedException, e.getLocalizedMessage());
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotDaoTest method testUpdateSnapshotStatusByName.
@Test
public void testUpdateSnapshotStatusByName() {
dao.updateSnapshotStatusByName(existingSnapshot.getVolumeId(), existingSnapshot.getSnapshotName(), GlusterSnapshotStatus.DEACTIVATED);
GlusterVolumeSnapshotEntity snapshot = dao.getById(existingSnapshot.getSnapshotId());
assertNotNull(snapshot);
assertFalse(snapshot.equals(existingSnapshot));
existingSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
assertEquals(existingSnapshot, snapshot);
}
Aggregations