/** * First check domain resources before removing domain. There are 2 cases: * <ol> * <li>Domain doesn't have accounts for cleanup, non-removed networks, or dedicated resources</li> * <ul><li>Delete domain</li></ul> * <li>Domain has one of the following: accounts set for cleanup, non-removed networks, dedicated resources</li> * <ul><li>Dont' delete domain</li><li>Fail operation</li></ul> * </ol> * @param domain domain to remove * @throws CloudRuntimeException when case 2 or when domain cannot be deleted on case 1 */ protected void removeDomainWithNoAccountsForCleanupNetworksOrDedicatedResources(DomainVO domain) { boolean hasDedicatedResources = false; List<Long> networkIds = _networkDomainDao.listNetworkIdsByDomain(domain.getId()); List<AccountVO> accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domain.getId()); List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domain.getId()); if (CollectionUtils.isNotEmpty(dedicatedResources)) { s_logger.error("There are dedicated resources for the domain " + domain.getId()); hasDedicatedResources = true; } if (accountsForCleanup.isEmpty() && networkIds.isEmpty() && !hasDedicatedResources) { publishRemoveEventsAndRemoveDomain(domain); } else { failRemoveOperation(domain, accountsForCleanup, networkIds, hasDedicatedResources); } }
List<Long> networkIds = _networkDomainDao.listNetworkIdsByDomain(domainId); CallContext ctx = CallContext.current(); ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallingUserId()), ctx.getCallingAccount());