Search in sources :

Example 46 with GlusterVolumeEntity

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

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

the class VolumeBrickListModel method onAddBricks.

private void onAddBricks() {
    VolumeBrickModel volumeBrickModel = (VolumeBrickModel) getWindow();
    if (volumeBrickModel == null) {
        return;
    }
    if (!volumeBrickModel.validate()) {
        return;
    }
    GlusterVolumeEntity volumeEntity = getEntity();
    if (volumeEntity == null) {
        return;
    }
    ArrayList<GlusterBrickEntity> brickList = new ArrayList<>();
    for (Object model : volumeBrickModel.getBricks().getItems()) {
        GlusterBrickEntity brickEntity = (GlusterBrickEntity) ((EntityModel) model).getEntity();
        brickEntity.setVolumeId(volumeEntity.getId());
        brickList.add(brickEntity);
    }
    volumeBrickModel.setMessage(null);
    if (!validateReplicaStripeCount(volumeEntity, volumeBrickModel)) {
        return;
    }
    if (brickList.size() == 0) {
        volumeBrickModel.setMessage(ConstantsManager.getInstance().getConstants().emptyAddBricksMsg());
        return;
    }
    if (!VolumeBrickModel.validateBrickCount(volumeEntity.getVolumeType(), volumeEntity.getBricks().size() + brickList.size(), volumeBrickModel.getReplicaCountValue(), volumeBrickModel.getStripeCountValue(), false)) {
        volumeBrickModel.setMessage(VolumeBrickModel.getValidationFailedMsg(volumeEntity.getVolumeType(), false));
        return;
    }
    if ((volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE || volumeEntity.getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) && !volumeBrickModel.validateReplicateBricks(volumeEntity.getReplicaCount(), volumeEntity.getBricks())) {
        ConfirmationModel confirmModel = new ConfirmationModel();
        setConfirmWindow(confirmModel);
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().addBricksReplicateConfirmationTitle());
        confirmModel.setHelpTag(HelpTag.add_bricks_confirmation);
        // $NON-NLS-1$
        confirmModel.setHashName("add_bricks_confirmation");
        confirmModel.setMessage(ConstantsManager.getInstance().getConstants().addBricksToReplicateVolumeFromSameServerMsg());
        // $NON-NLS-1$
        UICommand okCommand = new UICommand("OnAddBricksInternal", this);
        okCommand.setTitle(ConstantsManager.getInstance().getConstants().yes());
        okCommand.setIsDefault(true);
        getConfirmWindow().getCommands().add(okCommand);
        // $NON-NLS-1$
        UICommand cancelCommand = new UICommand("CancelConfirmation", this);
        cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no());
        cancelCommand.setIsCancel(true);
        getConfirmWindow().getCommands().add(cancelCommand);
    } else {
        onAddBricksInternal();
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 48 with GlusterVolumeEntity

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

the class VolumeParameterListModel method onResetAllParameters.

private void onResetAllParameters() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (getEntity() == null) {
        return;
    }
    GlusterVolumeEntity volume = getEntity();
    ResetGlusterVolumeOptionsParameters parameters = new ResetGlusterVolumeOptionsParameters(volume.getId(), null, false);
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.ResetGlusterVolumeOptions, parameters, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ResetGlusterVolumeOptionsParameters(org.ovirt.engine.core.common.action.gluster.ResetGlusterVolumeOptionsParameters)

Example 49 with GlusterVolumeEntity

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

the class VolumeParameterListModel method onSetParameter.

private void onSetParameter() {
    if (getEntity() == null) {
        return;
    }
    GlusterVolumeEntity volume = getEntity();
    VolumeParameterModel model = (VolumeParameterModel) getWindow();
    if (!model.validate()) {
        return;
    }
    GlusterVolumeOptionEntity option = new GlusterVolumeOptionEntity();
    option.setVolumeId(volume.getId());
    option.setKey(model.getKeyList().getSelectedItem());
    option.setValue(model.getValue().getEntity());
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option), result -> {
        VolumeParameterListModel localModel = (VolumeParameterListModel) result.getState();
        localModel.postOnSetParameter(result.getReturnValue());
    }, this);
}
Also used : GlusterVolumeOptionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 50 with GlusterVolumeEntity

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

the class VolumeBrickListModel method replaceBrick.

private void replaceBrick() {
    if (getWindow() != null) {
        return;
    }
    GlusterVolumeEntity volumeEntity = getEntity();
    if (volumeEntity == null) {
        return;
    }
    final ReplaceBrickModel brickModel = new ReplaceBrickModel();
    setWindow(brickModel);
    brickModel.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle());
    brickModel.setHelpTag(HelpTag.replace_brick);
    // $NON-NLS-1$
    brickModel.setHashName("replace_brick");
    AsyncDataProvider.getInstance().getClusterById(brickModel.asyncQuery(cluster -> AsyncDataProvider.getInstance().getHostListByCluster(brickModel.asyncQuery(hostList -> brickModel.getServers().setItems(hostList)), cluster.getName())), volumeEntity.getClusterId());
    // $NON-NLS-1$
    UICommand command = UICommand.createDefaultOkUiCommand("OnReplace", this);
    brickModel.getCommands().add(command);
    // $NON-NLS-1$
    brickModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : GlusterTaskType(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) GlusterVolumeReplaceBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClientInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) GlusterVolumeBricksActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeBricksActionParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Iterator(java.util.Iterator) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) GlusterVolumeResetBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeResetBrickActionParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

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