use of com.cloud.framework.config.impl.ConfigurationVO in project cosmic by MissionCriticalCloud.
the class ConfigurationDaoImpl method getConfiguration.
@Override
public Map<String, String> getConfiguration(final String instance, final Map<String, ? extends Object> params) {
if (_configs == null) {
_configs = new HashMap<>();
SearchCriteria<ConfigurationVO> sc = InstanceSearch.create();
sc.setParameters("instance", "DEFAULT");
List<ConfigurationVO> configurations = listIncludingRemovedBy(sc);
for (final 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 (final ConfigurationVO config : configurations) {
_configs.put(config.getName(), config.getValue());
}
}
}
mergeConfigs(_configs, params);
return _configs;
}
use of com.cloud.framework.config.impl.ConfigurationVO in project cosmic by MissionCriticalCloud.
the class CreateNetworkOfferingTest method setUp.
@Override
@Before
public void setUp() {
ComponentContext.initComponentsLifeCycle();
final ConfigurationVO configVO = new ConfigurationVO("200", "200", "200", "200", "200", "200");
Mockito.when(configDao.findByName(Matchers.anyString())).thenReturn(configVO);
Mockito.when(offDao.persist(Matchers.any(NetworkOfferingVO.class))).thenReturn(new NetworkOfferingVO());
Mockito.when(offDao.persist(Matchers.any(NetworkOfferingVO.class), Matchers.anyMap())).thenReturn(new NetworkOfferingVO());
Mockito.when(mapDao.persist(Matchers.any(NetworkOfferingServiceMapVO.class))).thenReturn(new NetworkOfferingServiceMapVO());
Mockito.when(accountMgr.getSystemUser()).thenReturn(new UserVO(1));
Mockito.when(accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
CallContext.register(accountMgr.getSystemUser(), accountMgr.getSystemAccount());
}
use of com.cloud.framework.config.impl.ConfigurationVO in project cosmic by MissionCriticalCloud.
the class ApiServer method start.
@Override
public boolean start() {
// api port, null by default
Integer apiPort = null;
final SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
sc.addAnd("name", SearchCriteria.Op.EQ, Config.IntegrationAPIPort.key());
final List<ConfigurationVO> values = _configDao.search(sc, null);
if ((values != null) && (values.size() > 0)) {
final ConfigurationVO apiPortConfig = values.get(0);
if (apiPortConfig.getValue() != null) {
apiPort = Integer.parseInt(apiPortConfig.getValue());
}
}
final Map<String, String> configs = _configDao.getConfiguration();
final String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
if (strSnapshotLimit != null) {
final Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
if (snapshotLimit.longValue() <= 0) {
s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString() + " is less or equal 0; defaulting to unlimited");
} else {
_dispatcher.setCreateSnapshotQueueSizeLimit(snapshotLimit);
}
}
final Set<Class<?>> cmdClasses = new HashSet<>();
for (final PluggableService pluggableService : _pluggableServices) {
cmdClasses.addAll(pluggableService.getCommands());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Discovered plugin " + pluggableService.getClass().getSimpleName());
}
}
for (final Class<?> cmdClass : cmdClasses) {
final APICommand at = cmdClass.getAnnotation(APICommand.class);
if (at == null) {
throw new CloudRuntimeException(String.format("%s is claimed as a API command, but it doesn't have @APICommand annotation", cmdClass.getName()));
}
final String apiName = at.name();
List<Class<?>> apiCmdList = s_apiNameCmdClassMap.get(apiName);
if (apiCmdList == null) {
apiCmdList = new ArrayList<>();
s_apiNameCmdClassMap.put(apiName, apiCmdList);
}
apiCmdList.add(cmdClass);
}
setEncodeApiResponse(Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key())));
final String jsonType = _configDao.getValue(Config.JSONDefaultContentType.key());
if (jsonType != null) {
s_jsonContentType = jsonType;
}
final Boolean enableSecureSessionCookie = Boolean.valueOf(_configDao.getValue(Config.EnableSecureSessionCookie.key()));
if (enableSecureSessionCookie != null) {
s_enableSecureCookie = enableSecureSessionCookie;
}
if (apiPort != null) {
final ListenerThread listenerThread = new ListenerThread(this, apiPort);
listenerThread.start();
}
return true;
}
Aggregations