Search in sources :

Example 1 with GlusterVolumeRemoveBricksParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters 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 2 with GlusterVolumeRemoveBricksParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method migrate.

@Override
public Response migrate(Action action) {
    validateParameters(action, "bricks");
    validateBrickNames(action);
    GlusterVolumeRemoveBricksParameters params = toParameters(action.getBricks());
    return performAction(ActionType.StartRemoveGlusterVolumeBricks, params, action, false);
}
Also used : GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)

Example 3 with GlusterVolumeRemoveBricksParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters in project ovirt-engine by oVirt.

the class BackendGlusterBricksResource method stopMigrate.

@Override
public Response stopMigrate(Action action) {
    validateParameters(action, "bricks");
    validateBrickNames(action);
    GlusterVolumeRemoveBricksParameters params = toParameters(action.getBricks());
    return performAction(ActionType.StopRemoveGlusterVolumeBricks, params, action, false);
}
Also used : GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)

Example 4 with GlusterVolumeRemoveBricksParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters in project ovirt-engine by oVirt.

the class VolumeBrickListModel method onRemoveBricks.

private void onRemoveBricks() {
    if (getWindow() == null) {
        return;
    }
    RemoveBrickModel model = (RemoveBrickModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (getSelectedItems() == null || getSelectedItems().isEmpty()) {
        return;
    }
    GlusterVolumeEntity volumeEntity = getEntity();
    GlusterVolumeRemoveBricksParameters parameter = new GlusterVolumeRemoveBricksParameters(volumeEntity.getId(), getSelectedItems());
    if (volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE) {
        parameter.setReplicaCount(volumeEntity.getReplicaCount() - 1);
    } else if (volumeEntity.getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) {
        if (model.isReduceReplica()) {
            parameter.setReplicaCount(volumeEntity.getReplicaCount() - 1);
        } else {
            parameter.setReplicaCount(volumeEntity.getReplicaCount());
        }
    }
    model.startProgress();
    boolean isMigrate = model.getMigrateData().getEntity();
    Frontend.getInstance().runAction(isMigrate ? ActionType.StartRemoveGlusterVolumeBricks : ActionType.GlusterVolumeRemoveBricks, parameter, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        setWindow(null);
    }, model);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)

Example 5 with GlusterVolumeRemoveBricksParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters in project ovirt-engine by oVirt.

the class VolumeBrickListModel method onCommitRemoveBricks.

private void onCommitRemoveBricks() {
    if (getConfirmWindow() == null) {
        return;
    }
    ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
    GlusterVolumeEntity volumeEntity = getVolumeEntity();
    ArrayList<GlusterBrickEntity> list = new ArrayList<>();
    for (Object brickName : model.getItems()) {
        GlusterBrickEntity brick = volumeEntity.getBrickWithQualifiedName((String) brickName);
        if (brick != null) {
            list.add(brick);
        }
    }
    GlusterVolumeRemoveBricksParameters parameter = new GlusterVolumeRemoveBricksParameters(volumeEntity.getId(), list);
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.CommitRemoveGlusterVolumeBricks, parameter, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        setConfirmWindow(null);
        if (result.getReturnValue().getSucceeded()) {
            disableRemoveBrickStatusPopUpActions();
        }
    }, model);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)

Aggregations

GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)8 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)5 ArrayList (java.util.ArrayList)4 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)4 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)4 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)2 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1