mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
bug 9419: implement api to reset resource count
This commit is contained in:
parent
8ae65de6b3
commit
b625bb1d27
@ -163,7 +163,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
|
||||
CountSnapshotsByAccount = createSearchBuilder(Long.class);
|
||||
CountSnapshotsByAccount.select(null, Func.COUNT, null);
|
||||
CountSnapshotsByAccount.and("account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
CountSnapshotsByAccount.done();
|
||||
}
|
||||
|
||||
|
||||
@ -286,7 +286,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
CountTemplatesByAccount = createSearchBuilder(Long.class);
|
||||
CountTemplatesByAccount.select(null, Func.COUNT, null);
|
||||
CountTemplatesByAccount.and("account", CountTemplatesByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
CountTemplatesByAccount.done();
|
||||
|
||||
return result;
|
||||
|
||||
@ -793,13 +793,14 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
for (DomainVO domainChild : domainChildren) {
|
||||
long domainCount = updateDomainResourceCount(domainChild.getId(), type);
|
||||
count = count + domainCount; // add the child domain count to parent domain count
|
||||
}
|
||||
|
||||
List<AccountVO> accounts = _accountDao.findActiveAccountsForDomain(domainChild.getId());
|
||||
List<AccountVO> accounts = _accountDao.findActiveAccountsForDomain(domain.getId());
|
||||
for (AccountVO account : accounts) {
|
||||
long accountCount = updateAccountResourceCount(account.getId(), type);
|
||||
count = count + accountCount; // add account's resource count to parent domain count
|
||||
}
|
||||
}
|
||||
|
||||
_resourceCountDao.setDomainCount(domainId, type, count);
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Failed to update resource count for domain with Id " + domainId);
|
||||
|
||||
@ -66,7 +66,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
||||
|
||||
DomainAccountsSearch = createSearchBuilder();
|
||||
DomainAccountsSearch.and("domainId", DomainAccountsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
DomainAccountsSearch.and("removed", DomainAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
DomainAccountsSearch.and("removed", DomainAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
DomainAccountsSearch.done();
|
||||
|
||||
CleanupSearch = createSearchBuilder();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user