Search in sources :

Example 36 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class GlusterBrickValidatorTest method getDistributedVolume.

private GlusterVolumeEntity getDistributedVolume(Guid volumeId, int brickCount) {
    GlusterVolumeEntity volumeEntity = new GlusterVolumeEntity();
    volumeEntity.setId(volumeId);
    volumeEntity.setName("test-vol");
    volumeEntity.addAccessProtocol(AccessProtocol.GLUSTER);
    volumeEntity.addTransportType(TransportType.TCP);
    volumeEntity.setVolumeType(GlusterVolumeType.DISTRIBUTE);
    volumeEntity.setBricks(getBricks(volumeId, brickCount));
    return volumeEntity;
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Example 37 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class BackendGlusterBrickResource method getStatisticsResource.

@Override
public StatisticsResource getStatisticsResource() {
    EntityIdResolver<Guid> resolver = new QueryIdResolver<Guid>(QueryType.GetGlusterBrickById, IdQueryParameters.class) {

        @Override
        public GlusterBrickEntity lookupEntity(Guid id) throws BackendFailureException {
            GlusterBrickEntity brickEntity = getEntity(GlusterBrickEntity.class, QueryType.GetGlusterBrickById, new IdQueryParameters(id), null, true);
            GlusterVolumeEntity volumeEntity = getEntity(GlusterVolumeEntity.class, QueryType.GetGlusterVolumeById, new IdQueryParameters(brickEntity.getVolumeId()), null, true);
            GlusterVolumeAdvancedDetails detailsEntity = getEntity(GlusterVolumeAdvancedDetails.class, QueryType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsParameters(volumeEntity.getClusterId(), volumeEntity.getId(), brickEntity.getId(), true), null, true);
            brickEntity.setBrickDetails(detailsEntity.getBrickDetails().get(0));
            return brickEntity;
        }
    };
    BrickStatisticalQuery query = new BrickStatisticalQuery(resolver, newModel(id));
    return inject(new BackendStatisticsResource<>(GlusterBrickEntity.class, guid, query));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) GlusterVolumeAdvancedDetailsParameters(org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters) BrickStatisticalQuery(org.ovirt.engine.api.restapi.resource.BrickStatisticalQuery) Guid(org.ovirt.engine.core.compat.Guid)

Example 38 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity 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 39 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method activate.

@Override
public Response activate(Action action) {
    validateParameters(action, "bricks");
    validateBrickNames(action);
    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 stopMigrate(action);
    } else {
        Fault fault = new Fault();
        fault.setReason(localize(Messages.CANNOT_ACTIVATE_UNLESS_MIGRATION_COMPLETED));
        throw new WebApplicationException(Response.status(Response.Status.CONFLICT).entity(fault).build());
    }
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) WebApplicationException(javax.ws.rs.WebApplicationException) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Fault(org.ovirt.engine.api.model.Fault)

Example 40 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method populateAdvancedDetails.

protected GlusterBrick populateAdvancedDetails(GlusterBrick model, GlusterBrickEntity entity) {
    GlusterVolumeEntity volumeEntity = getEntity(GlusterVolumeEntity.class, QueryType.GetGlusterVolumeById, new IdQueryParameters(entity.getVolumeId()), null, true);
    GlusterVolumeAdvancedDetails detailsEntity = getEntity(GlusterVolumeAdvancedDetails.class, QueryType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsParameters(volumeEntity.getClusterId(), volumeEntity.getId(), entity.getId(), true), null, true);
    model = getMapper(GlusterVolumeAdvancedDetails.class, GlusterBrick.class).map(detailsEntity, model);
    return model;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) GlusterVolumeAdvancedDetailsParameters(org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters)

Aggregations

GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)220 ArrayList (java.util.ArrayList)57 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)49 Test (org.junit.Test)47 Guid (org.ovirt.engine.core.compat.Guid)30 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)30 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)26 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)20 VDS (org.ovirt.engine.core.common.businessentities.VDS)19 HashMap (java.util.HashMap)16 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)16 List (java.util.List)15 Map (java.util.Map)15 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)15 ActionType (org.ovirt.engine.core.common.action.ActionType)13 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)13 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)13 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)13 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)12 GlusterTaskType (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType)12