Search in sources :

Example 6 with GlusterVolume

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

the class BrickStatisticalQuery method clone.

private GlusterBrick clone(GlusterBrick brick) {
    // Needed to avoid NPE in LinkHelper due to unsetting of grandparent in LinkHelper#addLinks.
    GlusterBrick cloned = new GlusterBrick();
    cloned.setId(brick.getId());
    cloned.setGlusterVolume(new GlusterVolume());
    cloned.getGlusterVolume().setId(brick.getGlusterVolume().getId());
    cloned.getGlusterVolume().setCluster(new Cluster());
    cloned.getGlusterVolume().getCluster().setId(brick.getGlusterVolume().getCluster().getId());
    return cloned;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 7 with GlusterVolume

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

the class BackendGlusterBricksResourceTest method testActivate.

@Test
public void testActivate() 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.StopRemoveGlusterVolumeBricks, GlusterVolumeRemoveBricksParameters.class, new String[] {}, new Object[] {}, true, true));
    Action action = new Action();
    action.setBricks(bricks);
    collection.stopMigrate(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 8 with GlusterVolume

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

the class BackendGlusterBricksResourceTest method testStopMigrate.

@Test
public void testStopMigrate() 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.StopRemoveGlusterVolumeBricks, GlusterVolumeRemoveBricksParameters.class, new String[] {}, new Object[] {}, true, true));
    Action action = new Action();
    action.setBricks(bricks);
    collection.stopMigrate(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 9 with GlusterVolume

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

the class BackendGlusterBricksResourceTest method setUpParentMocks.

/**
 * The method {@link BackendGlusterBricksResource#list()} internally invokes
 * {@link BackendGlusterVolumeResource#get()} to fetch the volume object, and then invokes the query to fetch the
 * bricks of that volume. This method mocks the volume resource to return pre-defined volume id
 */
private void setUpParentMocks() {
    GlusterVolume volume = new GlusterVolume();
    volume.setId(volumeId.toString());
    Cluster cluster = new Cluster();
    cluster.setId(clusterId.toString());
    volume.setCluster(cluster);
    ClusterResource clusterResourceMock = mock(ClusterResource.class);
    when(clusterResourceMock.get()).thenReturn(cluster);
    BackendGlusterVolumesResource volumesResourceMock = mock(BackendGlusterVolumesResource.class);
    when(volumesResourceMock.getParent()).thenReturn(clusterResourceMock);
    parentMock = mock(BackendGlusterVolumeResource.class);
    when(parentMock.getParent()).thenReturn(volumesResourceMock);
    when(parentMock.get()).thenReturn(volume);
    collection.setParent(parentMock);
    doAnswer(invocation -> {
        GlusterVolume model = (GlusterVolume) invocation.getArguments()[0];
        Cluster clusterModel = new Cluster();
        clusterModel.setId(clusterId.toString());
        model.setCluster(clusterModel);
        model.setId(volumeId.toString());
        return model;
    }).when(parentMock).addParents(isA(GlusterVolume.class));
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) ClusterResource(org.ovirt.engine.api.resource.ClusterResource)

Example 10 with GlusterVolume

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

the class BackendGlusterBricksResourceTest method createModel.

private GlusterBricks createModel() {
    GlusterBricks bricks = new GlusterBricks();
    GlusterBrick brick = new GlusterBrick();
    brick.setId(GUIDS[0].toString());
    brick.setGlusterVolume(new GlusterVolume());
    brick.getGlusterVolume().setId(volumeId.toString());
    brick.setServerId(serverId.toString());
    brick.setBrickDir(brickDir);
    bricks.getGlusterBricks().add(brick);
    return bricks;
}
Also used : GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Aggregations

GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)18 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)7 Test (org.junit.Test)6 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)6 Cluster (org.ovirt.engine.api.model.Cluster)5 Response (javax.ws.rs.core.Response)3 Action (org.ovirt.engine.api.model.Action)3 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)3 UriInfo (javax.ws.rs.core.UriInfo)2 Options (org.ovirt.engine.api.model.Options)2 ClusterResource (org.ovirt.engine.api.resource.ClusterResource)2 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)2 ArrayList (java.util.ArrayList)1 Option (org.ovirt.engine.api.model.Option)1 TransportType (org.ovirt.engine.api.model.TransportType)1 V3GlusterVolume (org.ovirt.engine.api.v3.types.V3GlusterVolume)1 CreateGlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters)1 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1