Search in sources :

Example 1 with GlusterBrick

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

the class BackendGlusterBrickResource method remove.

@Override
public Response remove() {
    get();
    GlusterBrick brick = new GlusterBrick();
    brick.setId(id);
    GlusterBricks bricks = new GlusterBricks();
    bricks.getGlusterBricks().add(brick);
    Action action = new Action();
    action.setBricks(bricks);
    return parent.remove(action);
}
Also used : Action(org.ovirt.engine.api.model.Action) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 2 with GlusterBrick

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

the class BackendGlusterBricksResource method add.

@Override
public Response add(GlusterBricks bricks) {
    for (GlusterBrick brick : bricks.getGlusterBricks()) {
        validateParameters(brick, "serverId", "brickDir");
    }
    List<GlusterBrickEntity> brickEntities = mapBricks(asGuid(getVolumeId()), bricks);
    int replicaCount = ParametersHelper.getIntegerParameter(httpHeaders, uriInfo, REPLICA_COUNT, 0, 0);
    int stripeCount = ParametersHelper.getIntegerParameter(httpHeaders, uriInfo, STRIPE_COUNT, 0, 0);
    return performCreationMultiple(ActionType.AddBricksToGlusterVolume, new GlusterVolumeBricksActionParameters(asGuid(getVolumeId()), brickEntities, replicaCount, stripeCount, isForce()), new QueryIdResolver<>(QueryType.GetGlusterBrickById, IdQueryParameters.class));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeBricksActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeBricksActionParameters) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 3 with GlusterBrick

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

the class BackendGlusterBricksResource method mapBricks.

private List<GlusterBrickEntity> mapBricks(Guid volumeId, GlusterBricks glusterBricks) {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    if (glusterBricks.getGlusterBricks().size() > 0) {
        for (GlusterBrick brick : glusterBricks.getGlusterBricks()) {
            GlusterBrickEntity brickEntity = getMapper(GlusterBrick.class, GlusterBrickEntity.class).map(brick, null);
            brickEntity.setVolumeId(volumeId);
            bricks.add(brickEntity);
        }
    }
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 4 with GlusterBrick

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

the class BackendGlusterBricksResource method remove.

@Override
public Response remove(Action action) {
    GlusterBricks bricks = action.getBricks();
    if (bricks.getGlusterBricks().size() > 0) {
        for (GlusterBrick brick : bricks.getGlusterBricks()) {
            validateParameters(brick, "id|name");
        }
    }
    int replicaCount = ParametersHelper.getIntegerParameter(httpHeaders, uriInfo, REPLICA_COUNT, 0, 0);
    GlusterVolumeRemoveBricksParameters params = toParameters(bricks);
    params.setReplicaCount(replicaCount);
    GlusterVolumeEntity volume = getEntity(GlusterVolumeEntity.class, QueryType.GetGlusterVolumeById, new IdQueryParameters(asGuid(getVolumeId())), "");
    if (volume.getAsyncTask() != null && volume.getAsyncTask().getType() == GlusterTaskType.REMOVE_BRICK && volume.getAsyncTask().getStatus() == JobExecutionStatus.FINISHED) {
        return performAction(ActionType.CommitRemoveGlusterVolumeBricks, params);
    } else {
        return performAction(ActionType.GlusterVolumeRemoveBricks, params);
    }
}
Also used : GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)

Example 5 with GlusterBrick

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

the class BackendGlusterVolumesResource method mapBricks.

private void mapBricks(GlusterVolume volume, GlusterVolumeEntity volumeEntity) {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    for (GlusterBrick brick : volume.getBricks().getGlusterBricks()) {
        bricks.add(getMapper(GlusterBrick.class, GlusterBrickEntity.class).map(brick, null));
    }
    volumeEntity.setBricks(bricks);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) 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