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); }
@Override public void populateConfiguration(Configurable configurable) { populateConfiguration(new Date(), configurable); }
@Override public <T> void createOrUpdateConfigObject(String componentName, ConfigKey<T> key, String value) { createOrupdateConfigObject(new Date(), componentName, key, value); } }
_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); } }
@Override public String getValue(String name) { ConfigurationVO config = findByName(name); return (config == null) ? null : config.getValue(); }
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); }
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; }
@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); }
@Override public boolean isEncrypted() { return "Hidden".equals(getCategory()) || "Secure".equals(getCategory()); }
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 void setValue(String value) { if(isEncrypted()) { this.value = DBEncryptionUtil.encrypt(value); } else { this.value = value; } }
public ConfigDepotImpl() { ConfigKey.init(this); createEmptyScopeLevelMappings(); }
public T valueIn(Long id) { if (id == null) { return value(); } String value = s_depot != null ? s_depot.findScopedConfigStorage(this).getConfigValue(id, this) : null; if (value == null) { return value(); } else { return valueOf(value); } }
@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); } } }
@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; }
@Override public String getValue() { if(isEncrypted()) { return DBEncryptionUtil.decrypt(value); } else { return value; } }
@PostConstruct @Override public void populateConfigurations() { Date date = new Date(); for (Configurable configurable : _configurables) { populateConfiguration(date, configurable); } }
@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; }
/** * 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); } /**