Search in sources :

Example 1 with GlusterVolumeInfoVDSParameters

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeInfoVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) Map(java.util.Map) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

Map (java.util.Map)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 GlusterVolumeInfoVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters)1 GlusterVolumeSnapshotActionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters)1