Search in sources :

Example 11 with ConfigurationVO

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;
}
Also used : ConfigurationVO(com.cloud.framework.config.impl.ConfigurationVO)

Example 12 with ConfigurationVO

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());
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) ConfigurationVO(com.cloud.framework.config.impl.ConfigurationVO) UserVO(com.cloud.user.UserVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Example 13 with ConfigurationVO

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;
}
Also used : PluggableService(com.cloud.utils.component.PluggableService) ConfigurationVO(com.cloud.framework.config.impl.ConfigurationVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) HashSet(java.util.HashSet)

Aggregations

ConfigurationVO (com.cloud.framework.config.impl.ConfigurationVO)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)4 ConfigurationException (javax.naming.ConfigurationException)3 IPRangeConfig (com.cloud.test.IPRangeConfig)2 Account (com.cloud.user.Account)2 User (com.cloud.user.User)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 ApiServiceConfiguration (com.cloud.config.ApiServiceConfiguration)1 Config (com.cloud.configuration.Config)1 VlanVO (com.cloud.dc.VlanVO)1 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)1 ActionEvent (com.cloud.event.ActionEvent)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1