@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 String getValue(String name) { ConfigurationVO config = findByName(name); return (config == null) ? null : config.getValue(); }
@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); } /**
@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; }
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 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); } }
/** * 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); } }