use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.
the class UsageEventDetailsDaoImpl method persist.
@Override
public void persist(long eventId, Map<String, String> details) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SearchCriteria<UsageEventDetailsVO> sc = EventDetailsSearch.create();
sc.setParameters("eventId", eventId);
expunge(sc);
for (Map.Entry<String, String> detail : details.entrySet()) {
UsageEventDetailsVO vo = new UsageEventDetailsVO(eventId, detail.getKey(), detail.getValue());
persist(vo);
}
txn.commit();
}
use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.
the class UsageEventDetailsDaoImpl method deleteDetails.
@Override
public void deleteDetails(long eventId) {
SearchCriteria<UsageEventDetailsVO> sc = EventDetailsSearch.create();
sc.setParameters("eventId", eventId);
List<UsageEventDetailsVO> results = search(sc, null);
for (UsageEventDetailsVO result : results) {
remove(result.getId());
}
}
use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.
the class UsageManagerImpl method populateDynamicComputeOfferingDetailsAndPersist.
private void populateDynamicComputeOfferingDetailsAndPersist(UsageVMInstanceVO usageInstance, Long eventId) {
//populate the cpu, memory and cpuSpeed of the vm when created from a dynamic offering.
UsageEventDetailsVO cpuNumber = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.cpuNumber.name());
if (cpuNumber != null) {
usageInstance.setCpuCores(Long.parseLong(cpuNumber.getValue()));
} else {
usageInstance.setCpuCores(null);
}
UsageEventDetailsVO cpuSpeed = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.cpuSpeed.name());
if (cpuSpeed != null) {
usageInstance.setCpuSpeed(Long.parseLong(cpuSpeed.getValue()));
} else {
usageInstance.setCpuSpeed(null);
}
UsageEventDetailsVO memory = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.memory.name());
if (memory != null) {
usageInstance.setMemory(Long.parseLong(memory.getValue()));
} else {
usageInstance.setMemory(null);
}
_usageInstanceDao.persist(usageInstance);
}
Aggregations