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