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);
});
}
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);
}
}
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);
}
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;
}
}
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;
}
Aggregations