Search in sources :

Example 1 with GlusterGeoRepSessionConfiguration

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

the class GlusterGeoRepSyncJob method updateDiscoveredSessionConfig.

protected void updateDiscoveredSessionConfig(Cluster cluster, GlusterGeoRepSession session) {
    List<GlusterGeoRepSessionConfiguration> sessionConfigList = getSessionConfigFromCLI(cluster, session);
    if (sessionConfigList == null) {
        log.info("No configuration information returned from VDS for session '{}'", session.getSessionKey());
        return;
    }
    List<GlusterGeoRepSessionConfiguration> existingSessionConfigs = geoRepDao.getGeoRepSessionConfig(session.getId());
    Map<String, GlusterGeoRepSessionConfiguration> existingKeyConfigMap = prepareMapOfGeoRepSessionConfigs(existingSessionConfigs);
    for (GlusterGeoRepSessionConfiguration sessionConfig : sessionConfigList) {
        // update sessionId for fetched object.
        sessionConfig.setId(session.getId());
        // check if session config not same as in db
        if (!existingSessionConfigs.contains(sessionConfig)) {
            // confirm that it exists in db, which means config has been updated
            if (existingKeyConfigMap.containsKey(sessionConfig.getKey())) {
                geoRepDao.updateConfig(sessionConfig);
                String oldValue = existingKeyConfigMap.get(sessionConfig.getKey()).getValue();
                logGeoRepMessage(AuditLogType.GEOREP_OPTION_CHANGED_FROM_CLI, cluster, getOptionChangedCustomVars(session, sessionConfig.getKey(), sessionConfig.getValue(), oldValue));
            } else {
                geoRepDao.saveConfig(sessionConfig);
                logGeoRepMessage(AuditLogType.GEOREP_OPTION_SET_FROM_CLI, cluster, getOptionChangedCustomVars(session, sessionConfig.getKey(), sessionConfig.getValue(), null));
            }
        }
    }
    // If configs are reset some of them will disappear from config list
    Map<String, GlusterGeoRepSessionConfiguration> sessionKeyConfigMap = prepareMapOfGeoRepSessionConfigs(sessionConfigList);
    existingKeyConfigMap.keySet().removeAll(sessionKeyConfigMap.keySet());
    existingKeyConfigMap.keySet().forEach(key -> {
        GlusterGeoRepSessionConfiguration config = new GlusterGeoRepSessionConfiguration();
        config.setId(session.getId());
        config.setKey(key);
        geoRepDao.updateConfig(config);
    });
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration)

Example 2 with GlusterGeoRepSessionConfiguration

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

the class GlusterVolumeGeoRepConfigList method prepareConfigMap.

private void prepareConfigMap(Map<String, Object> geoRepConfigs) {
    for (Entry<String, Object> currentGeoRepConfig : geoRepConfigs.entrySet()) {
        GlusterGeoRepSessionConfiguration config = new GlusterGeoRepSessionConfiguration();
        config.setKey(currentGeoRepConfig.getKey());
        config.setValue((String) currentGeoRepConfig.getValue());
        geoRepConfigList.add(config);
    }
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration)

Example 3 with GlusterGeoRepSessionConfiguration

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

the class VolumeGeoRepListModel method updateConfig.

private void updateConfig() {
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    List<IFrontendActionAsyncCallback> callbacks;
    final GlusterVolumeGeoReplicationSessionConfigModel geoRepConfigModel = (GlusterVolumeGeoReplicationSessionConfigModel) getWindow();
    LinkedHashMap<String, String> oldConfigs = geoRepConfigModel.getConfigs();
    geoRepConfigModel.startProgress();
    for (EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> newConfigEntity : geoRepConfigModel.getConfigsModel().getItems()) {
        Pair<Boolean, GlusterGeoRepSessionConfiguration> newConfigPair = newConfigEntity.getEntity();
        GlusterGeoRepSessionConfiguration newConfig = newConfigPair.getSecond();
        boolean isOldConfigNull = oldConfigs.get(newConfig.getKey()) == null;
        boolean isNewConfigNull = newConfig.getValue() == null;
        if (!isNewConfigNull && !newConfig.getValue().isEmpty() && (isOldConfigNull || !newConfig.getValue().equals(oldConfigs.get(newConfig.getKey())))) {
            actionTypes.add(ActionType.SetGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
        if (newConfigPair.getFirst()) {
            actionTypes.add(ActionType.ResetDefaultGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
    }
    int numberOfConfigUpdates = parameters.size();
    if (numberOfConfigUpdates == 0) {
        geoRepConfigModel.stopProgress();
        closeWindow();
        return;
    }
    callbacks = new ArrayList<>(Collections.nCopies(numberOfConfigUpdates, (IFrontendActionAsyncCallback) null));
    callbacks.set(numberOfConfigUpdates - 1, result -> {
        geoRepConfigModel.stopProgress();
        closeWindow();
    });
    // Failure call back. Update the config list just to reflect any new changes and default error msg
    // dialog is thrown.
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, result -> fetchConfigForSession(geoRepConfigModel.getGeoRepSession()), this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 4 with GlusterGeoRepSessionConfiguration

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

the class SetGeoRepConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    String configKey = getParameters().getConfigKey();
    String configValue = getParameters().getConfigValue();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetGlusterVolumeGeoRepConfig, new GlusterVolumeGeoRepConfigVdsParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), configKey, configValue, session.getUserName()));
    boolean succeeded = returnValue.getSucceeded();
    if (succeeded && configKey.equals("use_meta_volume")) {
        // Not handling failures as there's no way to figure out if the error is that the option is already set.
        runVdsCommand(VDSCommandType.SetGlusterVolumeOption, new GlusterVolumeOptionVDSParameters(upServer.getId(), "all", new GlusterVolumeOptionEntity(getGeoRepSession().getMasterVolumeId(), "cluster.enable-shared-storage", "enable")));
    }
    setSucceeded(succeeded);
    if (getSucceeded()) {
        GlusterGeoRepSessionConfiguration geoRepSessionConfig = new GlusterGeoRepSessionConfiguration();
        geoRepSessionConfig.setValue(configValue);
        geoRepSessionConfig.setKey(configKey);
        geoRepSessionConfig.setId(session.getId());
        if (glusterGeoRepDao.getGeoRepSessionConfigByKey(session.getId(), configKey) == null) {
            glusterGeoRepDao.saveConfig(geoRepSessionConfig);
        } else {
            glusterGeoRepDao.updateConfig(geoRepSessionConfig);
        }
    } else {
        handleVdsError(AuditLogType.GLUSTER_GEOREP_CONFIG_SET_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) GlusterVolumeOptionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterVolumeGeoRepConfigVdsParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)

Example 5 with GlusterGeoRepSessionConfiguration

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

the class GlusterGeoRepSyncJobTest method getSessionConfigList.

private List<GlusterGeoRepSessionConfiguration> getSessionConfigList() {
    List<GlusterGeoRepSessionConfiguration> configList = new ArrayList<>();
    GlusterGeoRepSessionConfiguration config = new GlusterGeoRepSessionConfiguration();
    config.setKey("georep-crawl");
    config.setValue("hybrid");
    configList.add(config);
    return configList;
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) ArrayList(java.util.ArrayList)

Aggregations

GlusterGeoRepSessionConfiguration (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration)10 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 GWT (com.google.gwt.core.client.GWT)1 EventBus (com.google.gwt.event.shared.EventBus)1 UiBinder (com.google.gwt.uibinder.client.UiBinder)1 UiField (com.google.gwt.uibinder.client.UiField)1 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)1 Inject (com.google.inject.Inject)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 GlusterVolumeGeoRepConfigVdsParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)1 GlusterVolumeOptionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters)1 UiCommonEditorDriver (org.ovirt.engine.ui.common.editor.UiCommonEditorDriver)1 ElementIdHandler (org.ovirt.engine.ui.common.idhandler.ElementIdHandler)1 WithElementId (org.ovirt.engine.ui.common.idhandler.WithElementId)1