Search in sources :

Example 1 with ConfigValues

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);
}
Also used : ConfigValues(org.ovirt.engine.core.common.config.ConfigValues)

Example 2 with ConfigValues

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);
}
Also used : GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues)

Example 3 with ConfigValues

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);
}
Also used : KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with ConfigValues

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);
        }
    }
}
Also used : GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues)

Example 5 with ConfigValues

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();
}
Also used : ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)8 GetConfigurationValueParameters (org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 StringUtils (org.apache.commons.lang.StringUtils)1 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)1 Config (org.ovirt.engine.core.common.config.Config)1 GetSystemOptionParameters (org.ovirt.engine.core.common.queries.GetSystemOptionParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 KeyValuePairCompat (org.ovirt.engine.core.compat.KeyValuePairCompat)1 JobDataMap (org.quartz.JobDataMap)1 JobDetail (org.quartz.JobDetail)1 JobExecutionContext (org.quartz.JobExecutionContext)1 JobExecutionException (org.quartz.JobExecutionException)1 JobListener (org.quartz.JobListener)1 SchedulerException (org.quartz.SchedulerException)1