use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.
the class ConfigurationServerImpl method updateSecondaryStorageVMSharedKey.
/**
* 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);
}
}
use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.
the class ManagementServerImpl method searchForConfigurations.
@Override
public Pair<List<? extends Configuration>, Integer> searchForConfigurations(final ListCfgsByCmd cmd) {
final Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
final SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
final Object name = cmd.getConfigName();
final Object category = cmd.getCategory();
final Object keyword = cmd.getKeyword();
final Long zoneId = cmd.getZoneId();
final Long clusterId = cmd.getClusterId();
final Long storagepoolId = cmd.getStoragepoolId();
final Long imageStoreId = cmd.getImageStoreId();
Long accountId = cmd.getAccountId();
Long domainId = cmd.getDomainId();
String scope = null;
Long id = null;
int paramCountCheck = 0;
final Account caller = CallContext.current().getCallingAccount();
if (_accountMgr.isDomainAdmin(caller.getId())) {
if (accountId == null && domainId == null) {
domainId = caller.getDomainId();
}
} else if (_accountMgr.isNormalUser(caller.getId())) {
if (accountId == null) {
accountId = caller.getAccountId();
}
}
if (zoneId != null) {
scope = ConfigKey.Scope.Zone.toString();
id = zoneId;
paramCountCheck++;
}
if (clusterId != null) {
scope = ConfigKey.Scope.Cluster.toString();
id = clusterId;
paramCountCheck++;
}
if (accountId != null) {
Account account = _accountMgr.getAccount(accountId);
_accountMgr.checkAccess(caller, null, false, account);
scope = ConfigKey.Scope.Account.toString();
id = accountId;
paramCountCheck++;
}
if (domainId != null) {
_accountMgr.checkAccess(caller, _domainDao.findById(domainId));
scope = ConfigKey.Scope.Domain.toString();
id = domainId;
paramCountCheck++;
}
if (storagepoolId != null) {
scope = ConfigKey.Scope.StoragePool.toString();
id = storagepoolId;
paramCountCheck++;
}
if (imageStoreId != null) {
scope = ConfigKey.Scope.ImageStore.toString();
id = imageStoreId;
paramCountCheck++;
}
if (paramCountCheck > 1) {
throw new InvalidParameterValueException("cannot handle multiple IDs, provide only one ID corresponding to the scope");
}
if (keyword != null) {
final SearchCriteria<ConfigurationVO> ssc = _configDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("instance", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("component", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("category", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("value", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
}
if (name != null) {
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
}
if (category != null) {
sc.addAnd("category", SearchCriteria.Op.EQ, category);
}
// hidden configurations are not displayed using the search API
sc.addAnd("category", SearchCriteria.Op.NEQ, "Hidden");
if (scope != null && !scope.isEmpty()) {
// getting the list of parameters at requested scope
if (ConfigurationManagerImpl.ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && scope.equals(ConfigKey.Scope.Domain.toString())) {
sc.addAnd("scope", SearchCriteria.Op.IN, ConfigKey.Scope.Domain.toString(), ConfigKey.Scope.Account.toString());
} else {
sc.addAnd("scope", SearchCriteria.Op.EQ, scope);
}
}
final Pair<List<ConfigurationVO>, Integer> result = _configDao.searchAndCount(sc, searchFilter);
if (scope != null && !scope.isEmpty()) {
// Populate values corresponding the resource id
final List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
for (final ConfigurationVO param : result.first()) {
final ConfigurationVO configVo = _configDao.findByName(param.getName());
if (configVo != null) {
final ConfigKey<?> key = _configDepot.get(param.getName());
if (key != null) {
if (scope.equals(ConfigKey.Scope.Domain.toString())) {
Object value = key.valueInDomain(id);
configVo.setValue(value == null ? null : value.toString());
} else {
Object value = key.valueIn(id);
configVo.setValue(value == null ? null : value.toString());
}
configVOList.add(configVo);
} else {
s_logger.warn("ConfigDepot could not find parameter " + param.getName() + " for scope " + scope);
}
} else {
s_logger.warn("Configuration item " + param.getName() + " not found in " + scope);
}
}
return new Pair<List<? extends Configuration>, Integer>(configVOList, configVOList.size());
}
return new Pair<List<? extends Configuration>, Integer>(result.first(), result.second());
}
use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.
the class LDAPConfigCmd method updateLDAP.
private boolean updateLDAP() {
_ldapManager.addConfiguration(hostname, port, null);
/**
* There is no query filter now. It is derived from ldap.user.object and ldap.search.group.principle
*/
// ConfigurationVO cvo = _configDao.findByName(LDAPParams.queryfilter.toString());
// _configDao.update(cvo.getName(),cvo.getCategory(),getQueryFilter());
ConfigurationVO cvo = _configDao.findByName("ldap.basedn");
_configDao.update(cvo.getName(), cvo.getCategory(), getSearchBase());
/**
* There is no ssl now. it is derived from the presence of trust store and password
*/
// cvo = _configDao.findByName(LDAPParams.usessl.toString());
// _configDao.update(cvo.getName(),cvo.getCategory(),getUseSSL().toString());
cvo = _configDao.findByName("ldap.bind.principal");
_configDao.update(cvo.getName(), cvo.getCategory(), getBindDN());
cvo = _configDao.findByName("ldap.bind.password");
_configDao.update(cvo.getName(), cvo.getCategory(), getBindPassword());
cvo = _configDao.findByName("ldap.truststore");
_configDao.update(cvo.getName(), cvo.getCategory(), getTrustStore());
cvo = _configDao.findByName("ldap.truststore.password");
_configDao.update(cvo.getName(), cvo.getCategory(), getTrustStorePassword());
return true;
}
use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.
the class ConfigurationDaoImpl method getConfiguration.
@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;
}
Aggregations