Search in sources :

Example 16 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick 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 17 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick in project ovirt-engine by oVirt.

the class BackendGlusterBrickResourceTest method setupParentExpectations.

private void setupParentExpectations() {
    volumeResourceMock = mock(BackendGlusterVolumeResource.class);
    when(bricksResourceMock.getParent()).thenReturn(volumeResourceMock);
    when(volumeResourceMock.getId()).thenReturn(volumeId.toString());
    doAnswer(invocation -> {
        GlusterBrick glusterBrick = (GlusterBrick) invocation.getArguments()[0];
        Cluster cluster = new Cluster();
        cluster.setId(clusterId.toString());
        GlusterVolume volume = new GlusterVolume();
        volume.setId(volumeId.toString());
        volume.setCluster(cluster);
        glusterBrick.setGlusterVolume(volume);
        return glusterBrick;
    }).when(bricksResourceMock).addParents(isA(GlusterBrick.class));
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 18 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick in project ovirt-engine by oVirt.

the class BackendGlusterBricksResourceTest method testMigrate.

@Test
public void testMigrate() throws Exception {
    GlusterBrick brick = new GlusterBrick();
    GlusterVolume volume = new GlusterVolume();
    brick.setName(serverName + ":" + brickDir);
    volume.setId(volumeId.toString());
    brick.setGlusterVolume(volume);
    GlusterBricks bricks = mock(GlusterBricks.class);
    when(bricks.getGlusterBricks()).thenReturn(Collections.singletonList(brick));
    setUriInfo(setUpActionExpectations(ActionType.StartRemoveGlusterVolumeBricks, GlusterVolumeRemoveBricksParameters.class, new String[] {}, new Object[] {}, true, true));
    Action action = new Action();
    action.setBricks(bricks);
    collection.migrate(action);
}
Also used : Action(org.ovirt.engine.api.model.Action) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 19 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method validateBrickNames.

private void validateBrickNames(Action action) {
    List<GlusterBrick> bricks = action.getBricks().getGlusterBricks();
    for (GlusterBrick brick : bricks) {
        if (brick.getName() == null || brick.getName().equals("")) {
            Fault fault = new Fault();
            fault.setReason(localize(Messages.INCOMPLETE_PARAMS_REASON));
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(fault).build());
        }
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Fault(org.ovirt.engine.api.model.Fault) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 20 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method toParameters.

private GlusterVolumeRemoveBricksParameters toParameters(GlusterBricks bricks) {
    GlusterVolumeRemoveBricksParameters params = new GlusterVolumeRemoveBricksParameters();
    List<GlusterBrickEntity> entityBricks = new ArrayList<>();
    for (GlusterBrick brick : bricks.getGlusterBricks()) {
        GlusterBrickEntity entity = new GlusterBrickEntity();
        entity.setBrickDirectory(brick.getBrickDir());
        entity.setVolumeId(asGuid(getVolumeId()));
        if (brick.getName() != null) {
            String[] arr = brick.getName().split("\\:");
            if (arr.length > 1) {
                entity.setServerName(arr[0]);
                entity.setBrickDirectory(arr[1]);
            } else {
                continue;
            }
        }
        if (brick.getId() != null) {
            entity.setId(asGuid(brick.getId()));
        }
        entityBricks.add(entity);
    }
    params.setVolumeId(asGuid(getVolumeId()));
    params.setBricks(entityBricks);
    params.setCommandType(ActionType.StartRemoveGlusterVolumeBricks);
    return params;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Aggregations

GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)21 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)7 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)7 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)6 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)5 Action (org.ovirt.engine.api.model.Action)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Cluster (org.ovirt.engine.api.model.Cluster)2 GlusterClients (org.ovirt.engine.api.model.GlusterClients)2 GlusterMemoryPools (org.ovirt.engine.api.model.GlusterMemoryPools)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 BrickProfileDetail (org.ovirt.engine.api.model.BrickProfileDetail)1 BrickProfileDetails (org.ovirt.engine.api.model.BrickProfileDetails)1 Fault (org.ovirt.engine.api.model.Fault)1 GlusterVolumeProfileDetails (org.ovirt.engine.api.model.GlusterVolumeProfileDetails)1 NfsProfileDetail (org.ovirt.engine.api.model.NfsProfileDetail)1 NfsProfileDetails (org.ovirt.engine.api.model.NfsProfileDetails)1