Skip to content

Commit 9cd59a8

Browse files
author
Daan Hoogland
committed
remaining configs moved
1 parent 2c9149a commit 9cd59a8

2 files changed

Lines changed: 6 additions & 26 deletions

File tree

api/src/main/java/org/apache/cloudstack/usage/UsageService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public interface UsageService {
4545
ConfigKey<Boolean> EnableUsageServer = new ConfigKey<>("Usage", Boolean.class, "enable.usage.server", "true",
4646
"Flag for enabling usage", true);
4747

48+
ConfigKey<Boolean> UsageSnapshotVirtualSizeSelect = new ConfigKey<>("Usage", Boolean.class, "usage.snapshot.virtualsize.select", "false",
49+
"Set the value to true if snapshot usage need to consider virtual size, else physical size is considered", true);
50+
4851
/**
4952
* Generate Billing Records from the last time it was generated to the
5053
* time specified.

usage/src/main/java/com/cloud/usage/UsageManagerImpl.java

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
import javax.naming.ConfigurationException;
4343
import javax.persistence.EntityExistsException;
4444

45-
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4645
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
4746
import org.apache.cloudstack.quota.QuotaAlertManager;
4847
import org.apache.cloudstack.quota.QuotaManager;
4948
import org.apache.cloudstack.quota.QuotaStatement;
49+
import org.apache.cloudstack.quota.constant.QuotaConfig;
5050
import org.apache.cloudstack.usage.UsageService;
5151
import org.apache.cloudstack.usage.UsageTypes;
5252
import org.apache.cloudstack.utils.usage.UsageUtils;
@@ -92,7 +92,6 @@
9292
import com.cloud.utils.db.QueryBuilder;
9393
import com.cloud.utils.db.SearchCriteria;
9494
import com.cloud.utils.db.TransactionLegacy;
95-
import com.cloud.utils.exception.CloudRuntimeException;
9695

9796
@Component
9897
public class UsageManagerImpl extends ManagerBase implements UsageManager, Runnable {
@@ -144,8 +143,6 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
144143
@Inject
145144
protected UsageEventDetailsDao _usageEventDetailsDao;
146145
@Inject
147-
ConfigurationDao _configDao;
148-
@Inject
149146
private UsageVMSnapshotDao _usageVMSnapshotDao;
150147
@Inject
151148
private UsageVMSnapshotOnPrimaryDao _usageSnapshotOnPrimaryDao;
@@ -195,12 +192,6 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
195192
public UsageManagerImpl() {
196193
}
197194

198-
private void mergeConfigs(Map<String, String> dbParams, Map<String, Object> xmlParams) {
199-
for (Map.Entry<String, Object> param : xmlParams.entrySet()) {
200-
dbParams.put(param.getKey(), (String)param.getValue());
201-
}
202-
}
203-
204195
@Override
205196
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
206197
final String run = "usage.vmops.pid";
@@ -217,27 +208,13 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
217208
logger.info("Implementation Version is " + _version);
218209
}
219210

220-
Map<String, String> configs;
221-
try {
222-
configs = _configDao.getConfiguration(params);
223-
224-
if (params != null) {
225-
mergeConfigs(configs, params);
226-
logger.info("configs = " + configs);
227-
}
228-
} catch (CloudRuntimeException e) {
229-
logger.error("Unhandled configuration exception: " + e.getMessage());
230-
throw new CloudRuntimeException("Unhandled configuration exception", e);
231-
}
232-
233211
String execTime = UsageService.UsageStatsJobExecTime.value();
234212
Integer aggregationRange = UsageService.UsageStatsJobAggregationRange.value();
235213
String execTimeZone = UsageService.UsageExecutionTimezone.value();
236214
String aggregationTimeZone = UsageService.UsageAggregationTimezone.value();
237215
Integer sanityCheckInterval = UsageService.UsageSanityCheckInterval.value();
238-
String quotaEnable = configs.get("quota.enable.service");
239-
_runQuota = Boolean.valueOf(quotaEnable == null ? "false" : quotaEnable );
240-
usageSnapshotSelection = Boolean.valueOf(configs.get("usage.snapshot.virtualsize.select"));
216+
_runQuota = QuotaConfig.QuotaPluginEnabled.value();
217+
usageSnapshotSelection = UsageService.UsageSnapshotVirtualSizeSelect.value();
241218
if (sanityCheckInterval != null) {
242219
_sanityCheckInterval = sanityCheckInterval;
243220
}

0 commit comments

Comments
 (0)