Search in sources :

Example 6 with ConfigurationVO

use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.

the class ConfigurationDaoImpl method getValueAndInitIfNotExist.

@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);
    }
}
Also used : ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DB(com.cloud.utils.db.DB)

Example 7 with ConfigurationVO

use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.

the class ElastistorPrimaryDataStoreProvider method setCloudbyteGlobalConfiguration.

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

Example 8 with ConfigurationVO

use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.

the class FirstFitPlannerTest method initializeForClusterThresholdDisabled.

private List<Long> initializeForClusterThresholdDisabled() {
    when(configDepot.global()).thenReturn(configDao);
    ConfigurationVO config = mock(ConfigurationVO.class);
    when(config.getValue()).thenReturn(String.valueOf(false));
    when(configDao.findById(DeploymentClusterPlanner.ClusterThresholdEnabled.key())).thenReturn(config);
    List<Long> clustersCrossingThreshold = new ArrayList<Long>();
    clustersCrossingThreshold.add(3L);
    when(capacityDao.listClustersCrossingThreshold(Mockito.anyShort(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyLong())).thenReturn(clustersCrossingThreshold);
    return clustersCrossingThreshold;
}
Also used : ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO) ArrayList(java.util.ArrayList)

Example 9 with ConfigurationVO

use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.

the class CreateNetworkOfferingTest method setUp.

@Override
@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    ConfigurationVO configVO = new ConfigurationVO("200", "200", "200", "200", "200", "200");
    Mockito.when(configDao.findByName(anyString())).thenReturn(configVO);
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class), nullable(Map.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(mapDao.persist(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(org.apache.cloudstack.framework.config.impl.ConfigurationVO) UserVO(com.cloud.user.UserVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HashMap(java.util.HashMap) Map(java.util.Map) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Example 10 with ConfigurationVO

use of org.apache.cloudstack.framework.config.impl.ConfigurationVO in project cloudstack by apache.

the class ImageStoreDetailsUtil method getGlobalDefaultNfsVersion.

/**
 * Retrieve global secondary storage NFS version default value
 * @return global default value
 */
protected String getGlobalDefaultNfsVersion() {
    ConfigurationVO globalNfsVersion = configurationDao.findByName(CapacityManager.ImageStoreNFSVersion.key());
    Preconditions.checkState(globalNfsVersion != null, "Unable to find global NFS version for version key " + CapacityManager.ImageStoreNFSVersion.key());
    return globalNfsVersion.getValue();
}
Also used : ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO)

Aggregations

ConfigurationVO (org.apache.cloudstack.framework.config.impl.ConfigurationVO)19 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ArrayList (java.util.ArrayList)3 ConfigurationException (javax.naming.ConfigurationException)3 Before (org.junit.Before)3 IPRangeConfig (com.cloud.test.IPRangeConfig)2 Account (com.cloud.user.Account)2 DB (com.cloud.utils.db.DB)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HashMap (java.util.HashMap)2 NuageTest (com.cloud.NuageTest)1 SyncNuageVspCmsIdAnswer (com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer)1 DeleteNuageVspDeviceCmd (com.cloud.api.commands.DeleteNuageVspDeviceCmd)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