Martin Mucha has uploaded a new change for review. Change subject: tools: support for deprecating config values. ......................................................................
tools: support for deprecating config values. - each config value can be deprecated via setting its property '.deprecated' to true. If not specified, deprecated=false is assumed. - when someone tries to set deprecated value, following message is printed: "ConfigKey <option_name> is deprecated. Please refer to product documentation." - deprecated config values related to MAC pool. Change-Id: I636f7fe2530acfe00d8f0487001ddc781d1745a0 Signed-off-by: Martin Mucha <mmu...@redhat.com> --- M backend/manager/tools/src/main/java/org/ovirt/engine/core/config/EngineConfigLogic.java M backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKey.java M backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKeyFactory.java M packaging/etc/engine-config/engine-config.properties 4 files changed, 39 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/29295/1 diff --git a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/EngineConfigLogic.java b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/EngineConfigLogic.java index f0e58ec..d3cda4a 100644 --- a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/EngineConfigLogic.java +++ b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/EngineConfigLogic.java @@ -503,6 +503,10 @@ String message = null; boolean res = true; + if (configKey.isDeprecated()) { + throw new IllegalAccessError("ConfigKey " + key + " is deprecated. Please refer to product documentation."); + } + try { configKey.safeSetValue(value); res = (getConfigDAO().updateKey(configKey) == 1); diff --git a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKey.java b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKey.java index 72f990d..cbd56ff 100644 --- a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKey.java +++ b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKey.java @@ -18,9 +18,10 @@ private String alternateKey; private String keyName; private String value; + private final boolean isDeprecated; private boolean reloadable; private List<String> validValues; - private static final ArrayList<String> EMPTY_LIST = new ArrayList<String>(0); + private static final List<String> EMPTY_LIST = new ArrayList<String>(0); private String version; private ValueHelper valueHelper; @@ -32,13 +33,15 @@ String[] validValues, String version, ValueHelper helper, - boolean reloadable) { + boolean reloadable, + boolean isDeprecated) { super(); this.type = type; this.description = description; this.alternateKey = alternateKey; this.keyName = key; this.value = value; + this.isDeprecated = isDeprecated; setVersion(version); this.validValues = validValues != null ? Arrays.asList(validValues) : EMPTY_LIST; this.valueHelper = helper; @@ -159,4 +162,8 @@ return CompositePasswordValueHelper.class.isAssignableFrom(valueHelper.getClass()) || PasswordValueHelper.class.isAssignableFrom(valueHelper.getClass()); } + + public boolean isDeprecated() { + return isDeprecated; + } } diff --git a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKeyFactory.java b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKeyFactory.java index cea1b7e..a0da7eb 100644 --- a/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKeyFactory.java +++ b/backend/manager/tools/src/main/java/org/ovirt/engine/core/config/entity/ConfigKeyFactory.java @@ -2,6 +2,7 @@ import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; import java.util.Map; import org.apache.commons.configuration.HierarchicalConfiguration; import org.apache.commons.configuration.SubnodeConfiguration; @@ -67,13 +68,31 @@ // If the isReloadable attribute isn't specified - assume it is false boolean reloadable = configurationAt.getBoolean("isReloadable", false); ConfigKey configKey = new ConfigKey(type, description, alternateKey, key, "", validValues, - "", getHelperByType(type), reloadable); + "", getHelperByType(type), reloadable, isDeprecated(key)); configKey.setParser(parser); return configKey; } + private boolean isDeprecated(String key) { + final String pathToDeprecatedAttribute = key + "/deprecated"; + if (!keysConfig.containsKey(pathToDeprecatedAttribute)) { + return false; + } + + final List list = keysConfig.getList(pathToDeprecatedAttribute); + if (list.size() != 1) { + throw new IllegalArgumentException("Configuration error"); + } + + try { + return Boolean.parseBoolean((String) list.iterator().next()); + } catch (ClassCastException e) { + throw new IllegalArgumentException("Configuration error"); + } + } + public ConfigKey generateBlankConfigKey(String keyName, String keyType) { - return new ConfigKey(keyType, "", "", keyName, "", null, "", getHelperByType(keyType), false); + return new ConfigKey(keyType, "", "", keyName, "", null, "", getHelperByType(keyType), false, false); } private ValueHelper getHelperByType(String type) { @@ -102,7 +121,8 @@ key.getValidValues().toArray(new String[0]), version, key.getValueHelper(), - key.isReloadable()); + key.isReloadable(), + key.isDeprecated()); } /** diff --git a/packaging/etc/engine-config/engine-config.properties b/packaging/etc/engine-config/engine-config.properties index a530baa..37bafe5 100644 --- a/packaging/etc/engine-config/engine-config.properties +++ b/packaging/etc/engine-config/engine-config.properties @@ -61,8 +61,10 @@ LowUtilizationForPowerSave.type=Integer MacPoolRanges.description="MAC Addresses Pool Ranges (e.g. AA:AA:AA:AA:AA:AA-BB:BB:BB:BB:BB:BB,...")" MacPoolRanges.type=MacAddressPoolRanges +MacPoolRanges.deprecated=true MaxMacsCountInPool.description="Maximum MAC Addresses count in Pool" MaxMacsCountInPool.type=Integer +MaxMacsCountInPool.deprecated=true MaxNumberOfHostsInStoragePool.description="Max number of hosts in Storage Pool" MaxNumberOfHostsInStoragePool.type=Integer MaxNumOfCpuPerSocket.description="Max Number of CPU per socket" @@ -224,6 +226,7 @@ VdsLocalDisksCriticallyLowFreeSpace.type=Integer AllowDuplicateMacAddresses.description="Enable duplicate MAC address for VM network interface" AllowDuplicateMacAddresses.validValues=true,false +AllowDuplicateMacAddresses.deprecated=true JobCleanupRateInMinutes.description="Frequency of jobs clean-up process" JobCleanupRateInMinutes.type=Integer JobCleanupRateInMinutes.validValues=5..100000 -- To view, visit http://gerrit.ovirt.org/29295 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I636f7fe2530acfe00d8f0487001ddc781d1745a0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Mucha <mmu...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches