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);
}
}
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);
}
}
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;
}
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());
}
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();
}
Aggregations