use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class AsyncDataProvider method getMaxMaxMemorySize.
/**
* Upper bound of maximum memory size for given OS and compatibilityVersion. If {@code osId} is null then maximum of
* all configuration values is returned. If {@code compatVersion} is null then last Version is used.
*
* <p>
* Inspired by {@link VmCommonUtils#maxMemorySizeWithHotplugInMb(int, Version)}
* </p>
*
* @param osId
* operating system id, may be null
* @param compatVersion
* compatibility version, may be null
* @return upper bound of maximum memory size for given OS and compatibilityVersion,
*/
public int getMaxMaxMemorySize(Integer osId, Version compatVersion) {
String usedVersion = compatVersion != null ? compatVersion.getValue() : Version.getLast().getValue();
if (osId == null) {
return getMaxMaxMemoryForAllOss(usedVersion);
}
final ConfigValues maxMaxMemoryConfigValue = getMaxMaxMemoryConfigValue(osId);
return (Integer) getConfigValuePreConverted(maxMaxMemoryConfigValue, usedVersion);
}
use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class GetConfigurationValueQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Object returnValue = null;
if (shouldReturnValue()) {
try {
final GetConfigurationValueParameters params = getParameters();
final ConfigValues value = params.getConfigValue();
String version = params.getVersion();
if (version == null) {
log.warn("calling {} ({}) with null version, using default {} for version", GetConfigurationValueQuery.class.getSimpleName(), value, ConfigCommon.defaultConfigurationVersion);
version = ConfigCommon.defaultConfigurationVersion;
}
returnValue = Config.getValue(value, version);
} catch (Exception e) {
log.error("Unable to return config parameter {}: {}", getParameters(), e.getMessage());
log.debug("Exception", e);
}
}
getQueryReturnValue().setReturnValue(returnValue);
}
use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class GetConfigurationValuesQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Map<KeyValuePairCompat<ConfigValues, String>, Object> configValuesMap = new HashMap<>();
for (ConfigValues configValue : ConfigValues.values()) {
// Ignore an admin configuration value on filtered mode
if (!shouldReturnValue(configValue) || configValue == ConfigValues.Invalid) {
continue;
}
Map<String, Object> values = Config.getValuesForAllVersions(configValue);
for (Map.Entry<String, Object> entry : values.entrySet()) {
KeyValuePairCompat<ConfigValues, String> key = new KeyValuePairCompat<>(configValue, entry.getKey());
configValuesMap.put(key, entry.getValue());
}
}
getQueryReturnValue().setReturnValue(configValuesMap);
}
use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class GetFenceConfigurationValueQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
if (shouldReturnValue()) {
try {
final GetConfigurationValueParameters params = getParameters();
final ConfigValues value = params.getConfigValue();
String version = params.getVersion();
if (version == null) {
log.warn("calling {} ({}) with null version, using default {} for version", GetConfigurationValueQuery.class.getSimpleName(), ConfigCommon.defaultConfigurationVersion, value);
version = ConfigCommon.defaultConfigurationVersion;
}
getQueryReturnValue().setReturnValue(FenceConfigHelper.getFenceConfigurationValue(getParameters().getConfigValue().toString(), version));
} catch (Exception e) {
log.error("Unable to return config parameter {}: {}", getParameters(), e.getMessage());
log.debug("Exception", e);
}
}
}
use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class GetSystemOptionQuery method shouldReturnValue.
/**
* Validates if the query should return anything or not, according to the user's permissions:
* <ul>
* <li>If the query is run by administrator, the results are return if configuration value has not
* {@link ConfigValues.ClientAccessLevel#Internal}.</li>
* <li>If the query is run by user, it may return results <b>ONLY</b> if the configuration value has
* {@link ConfigValues.ClientAccessLevel#User}.</li>
* </ul>
*/
private boolean shouldReturnValue() {
DbUser user = getUser();
ConfigValues config = getParameters().getOptionName();
return user.isAdmin() ? config.getAccessLevel() != ConfigValues.ClientAccessLevel.Internal : config.nonAdminVisible();
}
Aggregations