Search in sources :

Example 46 with GlusterBrickEntity

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;
}
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)

Example 47 with GlusterBrickEntity

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);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 48 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Example 49 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid)

Example 50 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Aggregations

GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)132 ArrayList (java.util.ArrayList)63 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)43 Test (org.junit.Test)28 Guid (org.ovirt.engine.core.compat.Guid)19 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)14 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 List (java.util.List)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)9 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)9 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)7 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)7 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)7 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)7 Iterator (java.util.Iterator)5