Search in sources :

Example 1 with GlusterBricks

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

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

the class BackendGlusterBricksResource method performCreationMultiple.

protected Response performCreationMultiple(ActionType task, ActionParametersBase taskParams, EntityIdResolver<Guid> entityResolver) {
    ActionReturnValue createResult;
    try {
        createResult = doAction(task, taskParams);
    } catch (Exception e) {
        return handleError(e, false);
    }
    GlusterBricks model = resolveCreatedList(createResult, entityResolver);
    Response response = null;
    if (model == null) {
        response = Response.status(ACCEPTED_STATUS).build();
    } else {
        response = Response.created(URI.create(getUriInfo().getPath())).entity(model).build();
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 3 with GlusterBricks

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

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

the class V3GlusterVolumeInAdapter method adapt.

@Override
public GlusterVolume adapt(V3GlusterVolume from) {
    GlusterVolume to = new GlusterVolume();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBricks()) {
        to.setBricks(new GlusterBricks());
        to.getBricks().getGlusterBricks().addAll(adaptIn(from.getBricks().getGlusterBricks()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptIn(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDisperseCount()) {
        to.setDisperseCount(from.getDisperseCount());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOptions()) {
        to.setOptions(new Options());
        to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
    }
    if (from.isSetRedundancyCount()) {
        to.setRedundancyCount(from.getRedundancyCount());
    }
    if (from.isSetReplicaCount()) {
        to.setReplicaCount(from.getReplicaCount());
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(GlusterVolumeStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetStripeCount()) {
        to.setStripeCount(from.getStripeCount());
    }
    if (from.isSetTransportTypes()) {
        to.setTransportTypes(new GlusterVolume.TransportTypesList());
        to.getTransportTypes().getTransportTypes().addAll(adaptTransportTypes(from));
    }
    if (from.isSetVolumeType()) {
        to.setVolumeType(GlusterVolumeType.fromValue(from.getVolumeType()));
    }
    return to;
}
Also used : Options(org.ovirt.engine.api.model.Options) V3GlusterVolume(org.ovirt.engine.api.v3.types.V3GlusterVolume) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks)

Example 5 with GlusterBricks

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

the class V3GlusterBricksInAdapter method adapt.

@Override
public GlusterBricks adapt(V3GlusterBricks from) {
    GlusterBricks to = new GlusterBricks();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getGlusterBricks().addAll(adaptIn(from.getGlusterBricks()));
    return to;
}
Also used : GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) V3GlusterBricks(org.ovirt.engine.api.v3.types.V3GlusterBricks)

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