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); } } }
/** * 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 @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); } }
String value = c.getDefaultValue(); String description = c.getDescription(); ConfigurationVO configVO = new ConfigurationVO(category, instance, component, name, value, description); configVO.setDefaultValue(value); _configDao.persist(configVO);
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); } } }