Search in sources :

Example 71 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class BackendGlusterBricksResourceTest method getBricks.

private List<GlusterBrickEntity> getBricks() {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    GlusterBrickEntity brick = new GlusterBrickEntity();
    brick.setId(GUIDS[0]);
    brick.setServerId(serverId);
    brick.setServerName(serverName);
    brick.setVolumeId(volumeId);
    brick.setBrickDirectory(brickDir);
    bricks.add(brick);
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Example 72 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class BackendGlusterBricksResourceTest method getBrickEntitiesToRemove.

private List<GlusterBrickEntity> getBrickEntitiesToRemove() {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    GlusterBrickEntity brick = new GlusterBrickEntity();
    brick.setId(GUIDS[0]);
    brick.setVolumeId(volumeId);
    bricks.add(brick);
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Example 73 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class BackendGlusterBricksResourceTest method setUpBricksQueryExpectations.

private void setUpBricksQueryExpectations(Object failure) {
    QueryReturnValue queryResult = new QueryReturnValue();
    queryResult.setSucceeded(failure == null);
    List<GlusterBrickEntity> entities = new ArrayList<>();
    if (failure == null) {
        for (int i = 0; i < NAMES.length; i++) {
            entities.add(getEntity(i));
        }
        queryResult.setReturnValue(entities);
    } else {
        if (failure instanceof String) {
            queryResult.setExceptionString((String) failure);
            setUpL10nExpectations((String) failure);
        } else if (failure instanceof Exception) {
            when(backend.runQuery(eq(QueryType.GetGlusterVolumeBricks), any())).thenThrow((Exception) failure);
            return;
        }
    }
    when(backend.runQuery(eq(QueryType.GetGlusterVolumeBricks), any())).thenReturn(queryResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 74 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterBrickMapperTest method testStatusMapping.

private void testStatusMapping(GlusterStatus backendStatus, GlusterBrickStatus restStatus) {
    GlusterBrickEntity brick = new GlusterBrickEntity();
    brick.setStatus(backendStatus);
    GlusterBrick restBrick = GlusterBrickMapper.map(brick, null);
    assertEquals(restBrick.getStatus(), restStatus);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 75 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GetGlusterVolumeGeoRepSessionsQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<GlusterGeoRepSession> geoRepSessions = glusterGeoRepDao.getGeoRepSessions(getParameters().getId());
    /*
         * If master volume has sessions, update the master server names in accordance with masterBrickId in sessionDetails.
         */
    if (geoRepSessions != null) {
        for (GlusterGeoRepSession currentSession : geoRepSessions) {
            // For each session get corresponding session details.
            List<GlusterGeoRepSessionDetails> geoRepSessionDetails = glusterGeoRepDao.getGeoRepSessionDetails(currentSession.getId());
            /*
                 * Session details could be null, if they are not yet synced. possible if session detail command failed for some unexpected reason
                 * such as network failure even though the sessions in the cluster are synced(sessionListCommand)
                 */
            if (geoRepSessionDetails == null) {
                continue;
            }
            /*
                 * If non null session detail, set masterBrick servername in accordance with that in brick
                 * as obtained by using masterbrickId
                 */
            for (GlusterGeoRepSessionDetails currentDetail : geoRepSessionDetails) {
                if (currentDetail == null) {
                    continue;
                }
                Guid currentMasterBrickId = currentDetail.getMasterBrickId();
                if (currentMasterBrickId == null) {
                    continue;
                }
                GlusterBrickEntity currentBrick = glusterBrickDao.getById(currentMasterBrickId);
                if (currentBrick != null) {
                    currentDetail.setMasterBrickHostName(currentBrick.getServerName());
                }
            }
            /*
                 * Finally set session details to the current session
                 */
            currentSession.setSessionDetails((ArrayList<GlusterGeoRepSessionDetails>) geoRepSessionDetails);
        }
    }
    getQueryReturnValue().setReturnValue(geoRepSessions);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterGeoRepSessionDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails) Guid(org.ovirt.engine.core.compat.Guid)

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