use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class RestoreGlusterVolumeSnapshotCommand method restoreVolumeToSnapshot.
private boolean restoreVolumeToSnapshot(Guid upServerId, GlusterVolumeEntity volume, String snapshotName) {
if (volume != null) {
VDSReturnValue retVal = runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(upServerId, volume.getName(), snapshotName));
if (!retVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage());
setSucceeded(false);
return false;
} else {
glusterVolumeSnapshotDao.removeByName(volume.getId(), snapshotName);
// Sync the new bricks of the volume immediately
VDS upServer = glusterUtil.getRandomUpServer(volume.getClusterId());
VDSReturnValue volDetailsRetVal = runVdsCommand(VDSCommandType.GetGlusterVolumeInfo, new GlusterVolumeInfoVDSParameters(upServer.getId(), volume.getClusterId(), volume.getName()));
GlusterVolumeEntity fetchedVolume = ((Map<Guid, GlusterVolumeEntity>) volDetailsRetVal.getReturnValue()).get(volume.getId());
List<GlusterBrickEntity> fetchedBricks = fetchedVolume.getBricks();
if (fetchedBricks != null) {
glusterBrickDao.removeAllInBatch(volume.getBricks());
for (GlusterBrickEntity fetchdBrick : fetchedVolume.getBricks()) {
if (fetchdBrick.getServerId() != null) {
fetchdBrick.setStatus(GlusterStatus.UP);
glusterBrickDao.save(fetchdBrick);
} else {
log.warn("Invalid server details for brick " + fetchdBrick.getName() + ". Not adding now.");
}
}
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VdsEventListener method moveBricksToUnknown.
private void moveBricksToUnknown(final VDS vds) {
List<GlusterBrickEntity> brickEntities = glusterBrickDao.getGlusterVolumeBricksByServerId(vds.getId());
for (GlusterBrickEntity brick : brickEntities) {
if (brick.getStatus() == GlusterStatus.UP) {
brick.setStatus(GlusterStatus.UNKNOWN);
}
}
glusterBrickDao.updateBrickStatuses(brickEntities);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class StopRebalanceGlusterVolumeCommandTest method getBricks.
private List<GlusterBrickEntity> getBricks(Guid volumeId, int n) {
List<GlusterBrickEntity> bricks = new ArrayList<>();
GlusterBrickEntity brick;
for (Integer i = 0; i < n; i++) {
brick = new GlusterBrickEntity();
brick.setVolumeId(volumeId);
brick.setBrickDirectory("/tmp/test-vol" + i.toString());
brick.setStatus(GlusterStatus.UP);
bricks.add(brick);
}
return bricks;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterVolumeDaoTest method insertTestVolume.
private GlusterVolumeEntity insertTestVolume() {
Guid volumeId = Guid.newGuid();
GlusterVolumeEntity volume = new GlusterVolumeEntity();
volume.setName(NEW_VOL_NAME);
volume.setClusterId(CLUSTER_ID);
volume.setId(volumeId);
volume.setVolumeType(GlusterVolumeType.DISTRIBUTE);
volume.addTransportType(TransportType.TCP);
volume.setReplicaCount(0);
volume.setStripeCount(0);
volume.setStatus(GlusterStatus.UP);
volume.setOption("auth.allow", "*");
volume.addAccessProtocol(AccessProtocol.GLUSTER);
volume.addAccessProtocol(AccessProtocol.NFS);
GlusterBrickEntity brick = new GlusterBrickEntity();
brick.setVolumeId(volumeId);
brick.setServerId(server.getId());
brick.setServerName(server.getHostName());
brick.setBrickDirectory("/export/testVol1");
brick.setStatus(GlusterStatus.UP);
brick.setBrickOrder(0);
volume.addBrick(brick);
volume.setSnapshotsCount(0);
volume.setSnapMaxLimit(0);
dao.save(volume);
return volume;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GetGlusterVolumeRemoveBricksStatusQueryTest method getBricks.
private List<GlusterBrickEntity> getBricks() {
GlusterBrickEntity brick1 = new GlusterBrickEntity();
brick1.setId(Guid.newGuid());
brick1.setServerId(SERVER_ID);
brick1.setVolumeId(VOLUME_ID);
GlusterBrickEntity brick2 = new GlusterBrickEntity();
brick2.setId(Guid.newGuid());
brick2.setServerId(SERVER_ID);
brick2.setVolumeId(VOLUME_ID);
List<GlusterBrickEntity> bricksList = new ArrayList<>();
bricksList.add(brick1);
bricksList.add(brick2);
return bricksList;
}
Aggregations