|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.user; |
18 | 18 |
|
19 | | -import java.util.*; |
| 19 | +import java.util.HashSet; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Set; |
| 22 | +import java.util.UUID; |
20 | 23 |
|
21 | 24 | import javax.ejb.Local; |
22 | 25 | import javax.inject.Inject; |
23 | | -import javax.naming.ConfigurationException; |
24 | 26 |
|
25 | 27 | import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd; |
26 | 28 | import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd; |
|
29 | 31 | import org.apache.log4j.Logger; |
30 | 32 | import org.springframework.stereotype.Component; |
31 | 33 |
|
| 34 | +import com.cloud.configuration.Resource.ResourceOwnerType; |
32 | 35 | import com.cloud.configuration.ResourceLimit; |
33 | 36 | import com.cloud.configuration.dao.ResourceCountDao; |
| 37 | +import com.cloud.configuration.dao.ResourceLimitDao; |
34 | 38 | import com.cloud.domain.Domain; |
35 | 39 | import com.cloud.domain.DomainVO; |
36 | 40 | import com.cloud.domain.dao.DomainDao; |
|
49 | 53 | import com.cloud.storage.dao.DiskOfferingDao; |
50 | 54 | import com.cloud.user.dao.AccountDao; |
51 | 55 | import com.cloud.utils.Pair; |
52 | | -import com.cloud.utils.component.Manager; |
53 | 56 | import com.cloud.utils.component.ManagerBase; |
54 | 57 | import com.cloud.utils.db.DB; |
55 | 58 | import com.cloud.utils.db.Filter; |
@@ -82,6 +85,8 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom |
82 | 85 | private ProjectManager _projectMgr; |
83 | 86 | @Inject |
84 | 87 | private RegionManager _regionMgr; |
| 88 | + @Inject |
| 89 | + private ResourceLimitDao _resourceLimitDao; |
85 | 90 |
|
86 | 91 | @Override |
87 | 92 | public Domain getDomain(long domainId) { |
@@ -329,6 +334,10 @@ private boolean cleanupDomain(Long domainId, Long ownerId) throws ConcurrentOper |
329 | 334 | List<AccountVO> accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domainId); |
330 | 335 | if (accountsForCleanup.isEmpty()) { |
331 | 336 | deleteDomainSuccess = _domainDao.remove(domainId); |
| 337 | + |
| 338 | + // Delete resource count and resource limits entries set for this domain (if there are any). |
| 339 | + _resourceCountDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); |
| 340 | + _resourceLimitDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); |
332 | 341 | } else { |
333 | 342 | s_logger.debug("Can't delete the domain yet because it has " + accountsForCleanup.size() + "accounts that need a cleanup"); |
334 | 343 | } |
|
0 commit comments