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