use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotDaoTest method testGetByName.
@Test
public void testGetByName() {
newSnapshot = insertTestSnapshot();
GlusterVolumeSnapshotEntity snapshot = dao.getByName(VOLUME_ID, NEW_SNAPSHOT_NAME);
assertNotNull(snapshot);
assertEquals(newSnapshot, snapshot);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterSnapshotSyncJobTest method getSnapshotDetails.
private List<GlusterVolumeSnapshotEntity> getSnapshotDetails() {
List<GlusterVolumeSnapshotEntity> snapshots = new ArrayList<>();
GlusterVolumeSnapshotEntity snap1 = new GlusterVolumeSnapshotEntity();
snap1.setClusterId(CLUSTER_ID_1);
snap1.setCreatedAt(existingSnapsCreateDate);
snap1.setDescription("");
snap1.setId(existingSnapshotIds[0]);
snap1.setSnapshotName(existingSnapshotNames[0]);
snap1.setStatus(GlusterSnapshotStatus.DEACTIVATED);
snap1.setVolumeId(VOLUME_ID_1);
snapshots.add(snap1);
GlusterVolumeSnapshotEntity snap2 = new GlusterVolumeSnapshotEntity();
snap2.setClusterId(CLUSTER_ID_1);
snap2.setCreatedAt(new Date());
snap2.setDescription("");
snap2.setId(newSnapshotId);
snap2.setSnapshotName(newSnapshotName);
snap2.setStatus(GlusterSnapshotStatus.ACTIVATED);
snap2.setVolumeId(VOLUME_ID_1);
snapshots.add(snap2);
return snapshots;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotInfoReturn method prepareVolumeSnapshotsList.
private List<GlusterVolumeSnapshotEntity> prepareVolumeSnapshotsList(Guid clusterId, Map<String, Object> snapshots) {
List<GlusterVolumeSnapshotEntity> newSnapshotsList = new ArrayList<>();
for (Map.Entry<String, Object> entry : snapshots.entrySet()) {
String volumeName = entry.getKey();
Map<String, Object> snapshotInfo = (Map<String, Object>) entry.getValue();
Object[] volumeSnapshots = (Object[]) snapshotInfo.get(SNAPSHOTS);
GlusterVolumeEntity volumeEntity = getGlusterVolumeDao().getByName(clusterId, volumeName);
for (Object snapshot : volumeSnapshots) {
Map<String, Object> individualSnapshot = (Map<String, Object>) snapshot;
GlusterVolumeSnapshotEntity newSnapshot = new GlusterVolumeSnapshotEntity();
newSnapshot.setClusterId(clusterId);
newSnapshot.setVolumeId(volumeEntity.getId());
newSnapshot.setSnapshotId(Guid.createGuidFromString((String) individualSnapshot.get(SNAPSHOT_ID)));
newSnapshot.setSnapshotName((String) individualSnapshot.get(NAME));
newSnapshot.setDescription((String) individualSnapshot.get(DESCRIPTION));
newSnapshot.setStatus(GlusterSnapshotStatus.from((String) individualSnapshot.get(SNAP_VOLUME_STATUS)));
try {
Map<String, Object> createTimeDetail = (Map<String, Object>) individualSnapshot.get(CREATETIME);
long millis = (Integer) createTimeDetail.get(EPOCH_TIME) * 1000L;
Date createDate = new Date(millis);
// Convert to UTC
DateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
String formattedCreateDate = format.format(createDate);
newSnapshot.setCreatedAt(new Date(formattedCreateDate));
} catch (Exception e) {
log.info("Could not populate creation time for snapshot '{}' of volume '{}' on cluster '{}': {}", snapshotInfo.get(NAME), volumeEntity.getName(), clusterId, e.getMessage());
log.debug("Exception", e);
}
newSnapshotsList.add(newSnapshot);
}
}
return newSnapshotsList;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotDaoTest method testRemoveMultiple.
@Test
public void testRemoveMultiple() {
List<Guid> idsToRemove = new ArrayList<>();
idsToRemove.add(EXISTING_SNAPSHOT_ID);
idsToRemove.add(EXISTING_SNAPSHOT_ID_1);
GlusterVolumeEntity volume = volumeDao.getById(VOLUME_ID);
assertEquals(2, volume.getSnapshotsCount().intValue());
dao.removeAll(idsToRemove);
List<GlusterVolumeSnapshotEntity> snapshots = dao.getAllByVolumeId(VOLUME_ID);
assertTrue(snapshots.isEmpty());
GlusterVolumeEntity volume1 = volumeDao.getById(VOLUME_ID);
assertEquals(0, volume1.getSnapshotsCount().intValue());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotDaoTest method testUpdateAllInBatch.
@Test
public void testUpdateAllInBatch() {
existingSnapshot = dao.getById(EXISTING_SNAPSHOT_ID);
existingSnapshot1 = dao.getById(EXISTING_SNAPSHOT_ID_1);
existingSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
existingSnapshot1.setStatus(GlusterSnapshotStatus.DEACTIVATED);
List<GlusterVolumeSnapshotEntity> snapshots = new ArrayList<>();
snapshots.add(existingSnapshot);
snapshots.add(existingSnapshot1);
dao.updateAllInBatch(snapshots);
GlusterVolumeSnapshotEntity tmpSnapshot = dao.getById(EXISTING_SNAPSHOT_ID);
GlusterVolumeSnapshotEntity tmpSnapshot1 = dao.getById(EXISTING_SNAPSHOT_ID_1);
assertEquals(GlusterSnapshotStatus.DEACTIVATED, tmpSnapshot.getStatus());
assertEquals(GlusterSnapshotStatus.DEACTIVATED, tmpSnapshot1.getStatus());
}
Aggregations