@Override public Map<String, String> getConfiguration(String instance, Map<String, ? extends Object> params) { if (_configs == null) { _configs = new HashMap<String, String>(); SearchCriteria<ConfigurationVO> sc = InstanceSearch.create(); sc.setParameters("instance", "DEFAULT"); List<ConfigurationVO> configurations = listIncludingRemovedBy(sc); for (ConfigurationVO config : configurations) { if (config.getValue() != null) _configs.put(config.getName(), config.getValue()); } if (!"DEFAULT".equals(instance)) { //Default instance params are already added, need not add again sc = InstanceSearch.create(); sc.setParameters("instance", instance); configurations = listIncludingRemovedBy(sc); for (ConfigurationVO config : configurations) { _configs.put(config.getName(), config.getValue()); } } } mergeConfigs(_configs, params); return _configs; }
private void createOrupdateConfigObject(Date date, String componentName, ConfigKey<?> key, String value) { ConfigurationVO vo = _configDao.findById(key.key()); if (vo == null) { vo = new ConfigurationVO(componentName, key); vo.setUpdated(date); if (value != null) { vo.setValue(value); } _configDao.persist(vo); } else { if (vo.isDynamic() != key.isDynamic() || !ObjectUtils.equals(vo.getDescription(), key.description()) || !ObjectUtils.equals(vo.getDefaultValue(), key.defaultValue()) || !ObjectUtils.equals(vo.getScope(), key.scope().toString()) || !ObjectUtils.equals(vo.getComponent(), componentName)) { vo.setDynamic(key.isDynamic()); vo.setDescription(key.description()); vo.setDefaultValue(key.defaultValue()); vo.setScope(key.scope().toString()); vo.setComponent(componentName); vo.setUpdated(date); _configDao.persist(vo); } } }
@Override public boolean isEncrypted() { return "Hidden".equals(getCategory()) || "Secure".equals(getCategory()); }
_configDao.update(cvo.getName(), cvo.getCategory(), getSearchBase()); _configDao.update(cvo.getName(), cvo.getCategory(), getBindDN()); _configDao.update(cvo.getName(), cvo.getCategory(), getBindPassword()); _configDao.update(cvo.getName(), cvo.getCategory(), getTrustStore()); _configDao.update(cvo.getName(), cvo.getCategory(), getTrustStorePassword());
@Override @DB public String getValueAndInitIfNotExist(String name, String category, String initValue, String desc) { String returnValue = initValue; try { ConfigurationVO config = findByName(name); if (config != null) { if (config.getValue() != null) { returnValue = config.getValue(); } else { update(name, category, initValue); } } else { ConfigurationVO newConfig = new ConfigurationVO(category, "DEFAULT", "management-server", name, initValue, desc); persist(newConfig); } return returnValue; } catch (Exception e) { s_logger.warn("Unable to update Configuration Value", e); throw new CloudRuntimeException("Unable to initialize configuration variable: " + name); } }
@Deprecated private void removeLegacyNuageVspDeviceCmsId(long deviceId) { ConfigurationVO cmsIdConfig = _configDao.findByName(CMSID_CONFIG_KEY); if (cmsIdConfig != null) { if (!cmsIdConfig.getValue().contains(";") && cmsIdConfig.getValue().startsWith(deviceId + ":")) { _configDao.update(CMSID_CONFIG_KEY, "Advanced", ""); } else { String newValue = cmsIdConfig.getValue().replace(String.format("(^|;)%d:[0-9a-f\\-]+;?", deviceId), ";"); _configDao.update(CMSID_CONFIG_KEY, "Advanced", newValue); } } }
final ConfigurationVO configVo = _configDao.findByName(param.getName()); if (configVo != null) { final ConfigKey<?> key = _configDepot.get(param.getName()); if (key != null) { configVo.setValue(key.valueIn(id) == null ? null : key.valueIn(id).toString()); configVOList.add(configVo); } else { s_logger.warn("ConfigDepot could not find parameter " + param.getName() + " for scope " + scope); s_logger.warn("Configuration item " + param.getName() + " not found in " + scope);
public ConfigurationDaoImpl() { InstanceSearch = createSearchBuilder(); InstanceSearch.and("instance", InstanceSearch.entity().getInstance(), SearchCriteria.Op.EQ); NameSearch = createSearchBuilder(); NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ); setRunLevel(ComponentLifecycle.RUN_LEVEL_SYSTEM_BOOTSTRAP); }
String value = c.getDefaultValue(); String description = c.getDescription(); ConfigurationVO configVO = new ConfigurationVO(category, instance, component, name, value, description); configVO.setDefaultValue(value); _configDao.persist(configVO);
@Override @DB public void resetEncryptionKeyIV() { SearchBuilder<ConfigurationVO> sb = _configDao.createSearchBuilder(); sb.and("name1", sb.entity().getName(), SearchCriteria.Op.EQ); sb.or("name2", sb.entity().getName(), SearchCriteria.Op.EQ); sb.done(); SearchCriteria<ConfigurationVO> sc = sb.create(); sc.setParameters("name1", EncryptionKey.key()); sc.setParameters("name2", EncryptionIV.key()); _configDao.expunge(sc); }
private void setCloudbyteGlobalConfiguration() { if (configurationDao.findByName("cloudbyte.management.ip") == null) { ConfigurationVO managementIP = new ConfigurationVO("Advanced", "DEFAULT", "management-server", "cloudbyte.management.ip", null, "configure the cloudbyte elasticenter management IP"); configurationDao.persist(managementIP); } if (configurationDao.findByName("cloudbyte.management.apikey") == null) { ConfigurationVO managementApiKey = new ConfigurationVO("Advanced", "DEFAULT", "management-server", "cloudbyte.management.apikey", null, "configure the cloudbyte elasticenter management API KEY"); configurationDao.persist(managementApiKey); } } }
public ConfigurationVO(String category, String instance, String component, String name, String value, String description) { this.category = category; this.instance = instance; this.component = component; this.name = name; this.description = description; setValue(value); }
final String configScope = cfg.getScope(); if (scope != null) { if (!configScope.contains(scope)) {
/** * preshared key to be used by management server to communicate with SSVM during volume/template upload */ private void updateSecondaryStorageVMSharedKey() { try { ConfigurationVO configInDB = _configDao.findByName(Config.SSVMPSK.key()); if(configInDB == null) { ConfigurationVO configVO = new ConfigurationVO(Config.SSVMPSK.getCategory(), "DEFAULT", Config.SSVMPSK.getComponent(), Config.SSVMPSK.key(), getPrivateKey(), Config.SSVMPSK.getDescription()); s_logger.info("generating a new SSVM PSK. This goes to SSVM on Start"); _configDao.persist(configVO); } else if (StringUtils.isEmpty(configInDB.getValue())) { s_logger.info("updating the SSVM PSK with new value. This goes to SSVM on Start"); _configDao.update(Config.SSVMPSK.key(), Config.SSVMPSK.getCategory(), getPrivateKey()); } } catch (NoSuchAlgorithmException ex) { s_logger.error("error generating ssvm psk", ex); } }
@Override public String getValue(String name) { ConfigurationVO config = findByName(name); return (config == null) ? null : config.getValue(); }
@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; }
@Deprecated private String findNuageVspCmsIdForDevice(long deviceId) { ConfigurationVO cmsIdConfig = _configDao.findByName(CMSID_CONFIG_KEY); if(cmsIdConfig != null) { String configValue = cmsIdConfig.getValue(); if (!Strings.isNullOrEmpty(configValue)) { String[] configuredNuageVspDevices = configValue.split(";"); for (String configuredNuageVspDevice : configuredNuageVspDevices) { if (configuredNuageVspDevice.startsWith(deviceId + ":")) { String[] split = configuredNuageVspDevice.split(":"); if (split.length != 2 || (split.length > 1 && Strings.isNullOrEmpty(split[1]))) { throw new IllegalArgumentException("The configured CMS ID for Nuage VSP device " + deviceId + " is in an incorrect format"); } return split[1]; } } } } return null; }
catergory = config.getCategory();
/** * Retrieve global secondary storage NFS version default value * @return global default value */ protected Integer getGlobalDefaultNfsVersion(){ ConfigurationVO globalNfsVersion = configurationDao.findByName(CapacityManager.ImageStoreNFSVersion.key()); Preconditions.checkState(globalNfsVersion != null, "Unable to find global NFS version for version key " + CapacityManager.ImageStoreNFSVersion.key()); String value = globalNfsVersion.getValue(); return (value != null ? Integer.valueOf(value) : null); } /**
public T value() { if (_value == null || isDynamic()) { ConfigurationVO vo = s_depot != null ? s_depot.global().findById(key()) : null; final String value = (vo != null && vo.getValue() != null) ? vo.getValue() : defaultValue(); _value = ((value == null) ? (T)defaultValue() : valueOf(value)); } return _value; }