Skip to content

generateUsageRecords does not work  #7133

@weizhouapache

Description

@weizhouapache

According to CloudStack API description:

https://cloudstack.apache.org/api/apidocs-4.17/apis/generateUsageRecords.html

Generates usage records. This will generate records only if there any records to be generated, i.e if the scheduled usage job was not run or failed

startdate and enddate are required parameters of the API. However, both seem not used (and domainid as well).

@Override
public boolean generateUsageRecords(GenerateUsageRecordsCmd cmd) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
UsageJobVO immediateJob = _usageJobDao.getNextImmediateJob();
if (immediateJob == null) {
UsageJobVO job = _usageJobDao.getLastJob();
String host = null;
int pid = 0;
if (job != null) {
host = job.getHost();
pid = ((job.getPid() == null) ? 0 : job.getPid().intValue());
}
_usageJobDao.createNewJob(host, pid, UsageJobVO.JOB_TYPE_SINGLE);
}
} finally {
txn.close();
// switch back to VMOPS_DB
TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
swap.close();
}
return true;
}

ISSUE TYPE
  • Bug Report
COMPONENT NAME
Usage
CLOUDSTACK VERSION
4.18
CONFIGURATION
OS / ENVIRONMENT
SUMMARY
STEPS TO REPRODUCE

EXPECTED RESULTS

ACTUAL RESULTS

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions