Search in sources :

Example 11 with GlusterBricks

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

the class BackendGlusterVolumesResourceTest method createModel.

private GlusterVolume createModel() {
    GlusterVolume volume = new GlusterVolume();
    volume.setName("testVol1");
    volume.setCluster(new Cluster());
    volume.getCluster().setId(clusterId.toString());
    volume.setVolumeType(org.ovirt.engine.api.model.GlusterVolumeType.DISTRIBUTE);
    volume.setBricks(new GlusterBricks());
    volume.getBricks().getGlusterBricks().add(createBrick("/export/vol1/brick1"));
    return volume;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) Cluster(org.ovirt.engine.api.model.Cluster)

Example 12 with GlusterBricks

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

the class BackendGlusterBricksResourceTest method testAddForce.

@Test
public void testAddForce() throws Exception {
    UriInfo uriInfo = setUpBasicUriExpectations();
    when(uriInfo.getPath()).thenReturn("clusters/" + clusterId + "/glustervolumes/" + volumeId + "/bricks");
    setUriInfo(setUpGetMatrixConstraintsExpectations(BackendResource.FORCE_CONSTRAINT, true, "true", uriInfo));
    setUpBrickCreationExpectation(true);
    Response response = collection.add(createModel());
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof GlusterBricks);
    verifyModel(((GlusterBricks) response.getEntity()).getGlusterBricks().get(0), 0);
}
Also used : Response(javax.ws.rs.core.Response) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 13 with GlusterBricks

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

the class BackendGlusterBricksResourceTest method testAddForceFalse.

@Test
public void testAddForceFalse() throws Exception {
    UriInfo uriInfo = setUpBasicUriExpectations();
    when(uriInfo.getPath()).thenReturn("clusters/" + clusterId + "/glustervolumes/" + volumeId + "/bricks");
    setUriInfo(setUpGetMatrixConstraintsExpectations(BackendResource.FORCE_CONSTRAINT, false, "false", uriInfo));
    setUpBrickCreationExpectation(false);
    Response response = collection.add(createModel());
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof GlusterBricks);
    verifyModel(((GlusterBricks) response.getEntity()).getGlusterBricks().get(0), 0);
}
Also used : Response(javax.ws.rs.core.Response) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 14 with GlusterBricks

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

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

the class BackendGlusterBricksResource method list.

@SuppressWarnings("unchecked")
@Override
public GlusterBricks list() {
    List<GlusterBrickEntity> bricks = getBackendCollection(QueryType.GetGlusterVolumeBricks, new IdQueryParameters(asGuid(getVolumeId())));
    GlusterBricks bricksModel = mapCollection(bricks);
    return addActions(bricksModel);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks)

Aggregations

GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)16 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)7 Test (org.junit.Test)6 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)6 Response (javax.ws.rs.core.Response)4 Action (org.ovirt.engine.api.model.Action)4 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)4 UriInfo (javax.ws.rs.core.UriInfo)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Cluster (org.ovirt.engine.api.model.Cluster)1 Options (org.ovirt.engine.api.model.Options)1 V3GlusterBricks (org.ovirt.engine.api.v3.types.V3GlusterBricks)1 V3GlusterVolume (org.ovirt.engine.api.v3.types.V3GlusterVolume)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1