Search in sources :

Example 1 with ConfigKey

use of org.apache.cloudstack.framework.config.ConfigKey in project cloudstack by apache.

the class LdapTestConfigTool method overrideConfigValue.

void overrideConfigValue(LdapConfiguration ldapConfiguration, final String configKeyName, final Object o) throws IllegalAccessException, NoSuchFieldException {
    Field configKey = LdapConfiguration.class.getDeclaredField(configKeyName);
    configKey.setAccessible(true);
    ConfigKey key = (ConfigKey) configKey.get(ldapConfiguration);
    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(configKey, configKey.getModifiers() & ~Modifier.FINAL);
    Field f = ConfigKey.class.getDeclaredField("_value");
    f.setAccessible(true);
    modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
    f.set(key, o);
    Field dynamic = ConfigKey.class.getDeclaredField("_isDynamic");
    dynamic.setAccessible(true);
    modifiersField.setInt(dynamic, dynamic.getModifiers() & ~Modifier.FINAL);
    dynamic.setBoolean(key, false);
}
Also used : Field(java.lang.reflect.Field) ConfigKey(org.apache.cloudstack.framework.config.ConfigKey)

Example 2 with ConfigKey

use of org.apache.cloudstack.framework.config.ConfigKey in project cloudstack by apache.

the class ConfigurationServerImpl method getConfigListByScope.

@Override
public List<ConfigurationVO> getConfigListByScope(String scope, Long resourceId) {
    // Getting the list of parameters defined at the scope
    Set<ConfigKey<?>> configList = _configDepot.getConfigListByScope(scope);
    List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
    for (ConfigKey<?> param : configList) {
        ConfigurationVO configVo = _configDao.findByName(param.toString());
        configVo.setValue(_configDepot.get(param.toString()).valueIn(resourceId).toString());
        configVOList.add(configVo);
    }
    return configVOList;
}
Also used : ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO) ArrayList(java.util.ArrayList)

Example 3 with ConfigKey

use of org.apache.cloudstack.framework.config.ConfigKey in project cloudstack by apache.

the class DiagnosticsFilesListFactoryTest method testDiagnosticsFileListDefaultsRouter.

@Test
public void testDiagnosticsFileListDefaultsRouter() {
    List<String> filesList = Objects.requireNonNull(DiagnosticsFilesListFactory.getDiagnosticsFilesList(null, vmInstance)).generateFileList();
    ConfigKey configKey = proxyDiagnosticFiles.RouterDefaultSupportedFiles;
    String[] defaultFileArray = configKey.defaultValue().split(",");
    assertEquals(filesList.size(), defaultFileArray.length);
}
Also used : ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) Test(org.junit.Test)

Aggregations

ConfigKey (org.apache.cloudstack.framework.config.ConfigKey)3 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 ConfigurationVO (org.apache.cloudstack.framework.config.impl.ConfigurationVO)1 Test (org.junit.Test)1