Search in sources :

Example 11 with GlusterVolumeOptionEntity

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

the class VolumeParameterListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    GlusterVolumeEntity glusterVolumeEntity = getEntity();
    ArrayList<GlusterVolumeOptionEntity> list = new ArrayList<>();
    for (GlusterVolumeOptionEntity glusterVolumeOption : glusterVolumeEntity.getOptions()) {
        list.add(glusterVolumeOption);
    }
    setItems(list);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 12 with GlusterVolumeOptionEntity

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

the class VolumeParameterListModel method onResetParameter.

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

Example 13 with GlusterVolumeOptionEntity

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

the class VolumeParameterListModel method editParameter.

private void editParameter() {
    if (getWindow() != null) {
        return;
    }
    GlusterVolumeEntity volume = getEntity();
    if (volume == null) {
        return;
    }
    VolumeParameterModel volumeParameterModel = new VolumeParameterModel();
    volumeParameterModel.setTitle(ConstantsManager.getInstance().getConstants().editOptionVolume());
    volumeParameterModel.setHelpTag(HelpTag.edit_option);
    // $NON-NLS-1$
    volumeParameterModel.setHashName("edit_option");
    volumeParameterModel.setIsNew(false);
    setWindow(volumeParameterModel);
    volumeParameterModel.getKeyList().setIsChangeable(false);
    volumeParameterModel.startProgress();
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        VolumeParameterModel innerParameterModel = (VolumeParameterModel) getWindow();
        if (!returnValue.getSucceeded()) {
            innerParameterModel.setOptionsMap(new HashMap<String, GlusterVolumeOptionInfo>());
            innerParameterModel.setMessage(ConstantsManager.getInstance().getConstants().errorInFetchingVolumeOptionList());
        } else {
            innerParameterModel.setOptionsMap(getOptionsMap((Set<GlusterVolumeOptionInfo>) returnValue.getReturnValue()));
        }
        GlusterVolumeOptionEntity selectedOption = getSelectedItem();
        // $NON-NLS-1$
        innerParameterModel.getDescription().setEntity("");
        innerParameterModel.getKeyList().setSelectedItem(selectedOption.getKey());
        innerParameterModel.getValue().setEntity(selectedOption.getValue());
        innerParameterModel.stopProgress();
        // $NON-NLS-1$
        UICommand command = UICommand.createDefaultOkUiCommand("OnSetParameter", VolumeParameterListModel.this);
        innerParameterModel.getCommands().add(command);
        // $NON-NLS-1$
        command = UICommand.createCancelUiCommand("OnCancel", VolumeParameterListModel.this);
        innerParameterModel.getCommands().add(command);
    });
    asyncQuery.setHandleFailure(true);
    AsyncDataProvider.getInstance().getGlusterVolumeOptionInfoList(asyncQuery, volume.getClusterId());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Set(java.util.Set) GlusterVolumeOptionInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionInfo) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 14 with GlusterVolumeOptionEntity

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

the class CreateGlusterVolumeCommand method setVolumeOptions.

/**
 * Sets all options of a volume by invoking the action {@link ActionType#SetGlusterVolumeOption} in a loop. <br>
 * Errors if any are collected and added to "executeFailedMessages"
 */
private void setVolumeOptions(GlusterVolumeEntity volume) {
    List<String> errors = new ArrayList<>();
    for (GlusterVolumeOptionEntity option : volume.getOptions()) {
        // make sure that volume id is set
        option.setVolumeId(volume.getId());
        ActionReturnValue setOptionReturnValue = runInternalAction(ActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option), createCommandContext(volume, option));
        if (!setOptionReturnValue.getSucceeded()) {
            setSucceeded(false);
            errors.addAll(setOptionReturnValue.getValidationMessages());
            errors.addAll(setOptionReturnValue.getExecuteFailedMessages());
        }
    }
    if (!errors.isEmpty()) {
        handleVdsErrors(AuditLogType.GLUSTER_VOLUME_OPTION_SET_FAILED, errors);
    }
}
Also used : GlusterVolumeOptionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 15 with GlusterVolumeOptionEntity

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

the class GlusterSyncJob method saveNewOptions.

private void saveNewOptions(GlusterVolumeEntity volume, Collection<GlusterVolumeOptionEntity> entities) {
    optionDao.saveAll(entities);
    for (final GlusterVolumeOptionEntity entity : entities) {
        Map<String, String> customValues = new HashMap<>();
        customValues.put(GlusterConstants.OPTION_KEY, entity.getKey());
        customValues.put(GlusterConstants.OPTION_VALUE, entity.getValue());
        logUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_OPTION_SET_FROM_CLI, customValues);
        log.info("New option '{}'='{}' set on volume '{}' from gluster CLI. Updating engine DB accordingly.", entity.getKey(), entity.getValue(), volume.getName());
    }
}
Also used : HashMap(java.util.HashMap) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Aggregations

GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)18 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)3 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 Test (org.junit.Test)2 Option (org.ovirt.engine.api.model.Option)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 Set (java.util.Set)1 InOrder (org.mockito.InOrder)1 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)1 Options (org.ovirt.engine.api.model.Options)1 TransportType (org.ovirt.engine.api.model.TransportType)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ResetGlusterVolumeOptionsParameters (org.ovirt.engine.core.common.action.gluster.ResetGlusterVolumeOptionsParameters)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterGeoRepSessionConfiguration (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration)1 GlusterVolumeOptionInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionInfo)1