mirror of https://github.com/apache/cloudstack.git
bug 11961: Before creating template usage_storage records, check if entry already exists. In multiple secondary storage case, duplicate usage events will be ignored.
status 11961: resolved fixed reviewed-by: Nitin
This commit is contained in:
parent
4b074600eb
commit
c15dbd561a
|
|
@ -1054,6 +1054,11 @@ public class UsageManagerImpl implements UsageManager, Runnable {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("create template with id : " + templateId + " for account: " + event.getAccountId());
|
||||
}
|
||||
List<UsageStorageVO> storageVOs = m_usageStorageDao.listByIdAndZone(event.getAccountId(), templateId, StorageTypes.TEMPLATE, zoneId);
|
||||
if (storageVOs.size() > 0) {
|
||||
s_logger.warn("Usage entry for Template: " + templateId + " assigned to account: " + event.getAccountId() + "already exists in zone "+zoneId);
|
||||
return;
|
||||
}
|
||||
Account acct = m_accountDao.findByIdIncludingRemoved(event.getAccountId());
|
||||
UsageStorageVO storageVO = new UsageStorageVO(templateId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.TEMPLATE, event.getTemplateId(),
|
||||
templateSize, event.getCreateDate(), null);
|
||||
|
|
@ -1091,6 +1096,11 @@ public class UsageManagerImpl implements UsageManager, Runnable {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("create iso with id : " + isoId + " for account: " + event.getAccountId());
|
||||
}
|
||||
List<UsageStorageVO> storageVOs = m_usageStorageDao.listByIdAndZone(event.getAccountId(), isoId, StorageTypes.ISO, zoneId);
|
||||
if (storageVOs.size() > 0) {
|
||||
s_logger.warn("Usage entry for ISO: " + isoId + " assigned to account: " + event.getAccountId() + "already exists in zone "+zoneId);
|
||||
return;
|
||||
}
|
||||
Account acct = m_accountDao.findByIdIncludingRemoved(event.getAccountId());
|
||||
UsageStorageVO storageVO = new UsageStorageVO( isoId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.ISO, null,
|
||||
isoSize, event.getCreateDate(), null);
|
||||
|
|
|
|||
Loading…
Reference in New Issue