use of org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters 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;
}
Aggregations