@Override public Long getDedicatedNetworkDomain(long networkId) { NetworkDomainVO networkMaps = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId); if (networkMaps != null) { return networkMaps.getDomainId(); } else { return null; } }
protected void addDomainToNetworknetwork(final long networkId, final long domainId, final Boolean subdomainAccess) { final NetworkDomainVO domain = new NetworkDomainVO(networkId, domainId, subdomainAccess); _domainsDao.persist(domain); }
final NetworkDomainVO networkDomain = _networkDomainDao.getDomainNetworkMapByNetworkId(networkFinal.getId()); if (networkDomain != null) { _networkDomainDao.remove(networkDomain.getId());
private List<NetworkVO> listDomainSpecificNetworksByDomainPath(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, boolean isRecursive) { Set<Long> allowedDomains = new HashSet<Long>(); if (path != null) { if (isRecursive) { allowedDomains = _domainMgr.getDomainChildrenIds(path); } else { Domain domain = _domainDao.findDomainByPath(path); allowedDomains.add(domain.getId()); } } List<Long> networkIds = new ArrayList<Long>(); List<NetworkDomainVO> maps = _networkDomainDao.listDomainNetworkMapByDomain(allowedDomains.toArray()); for (NetworkDomainVO map : maps) { networkIds.add(map.getNetworkId()); } if (!networkIds.isEmpty()) { SearchCriteria<NetworkVO> domainSC = _networksDao.createSearchCriteria(); domainSC.addAnd("id", SearchCriteria.Op.IN, networkIds.toArray()); domainSC.addAnd("aclType", SearchCriteria.Op.EQ, ACLType.Domain.toString()); sc.addAnd("id", SearchCriteria.Op.SC, domainSC); return _networksDao.search(sc, searchFilter); } else { return new ArrayList<NetworkVO>(); } }
/** * 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); } }
private List<NetworkVO> listDomainLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, long domainId, boolean parentDomainsOnly) { List<Long> networkIds = new ArrayList<Long>(); Set<Long> allowedDomains = _domainMgr.getDomainParentIds(domainId); List<NetworkDomainVO> maps = _networkDomainDao.listDomainNetworkMapByDomain(allowedDomains.toArray()); for (NetworkDomainVO map : maps) { if (map.getDomainId() == domainId && parentDomainsOnly) { continue; } boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : getAllowSubdomainAccessGlobal(); if (map.getDomainId() == domainId || subdomainAccess) { networkIds.add(map.getNetworkId()); } } if (!networkIds.isEmpty()) { SearchCriteria<NetworkVO> domainSC = _networksDao.createSearchCriteria(); domainSC.addAnd("id", SearchCriteria.Op.IN, networkIds.toArray()); domainSC.addAnd("aclType", SearchCriteria.Op.EQ, ACLType.Domain.toString()); sc.addAnd("id", SearchCriteria.Op.SC, domainSC); return _networksDao.search(sc, searchFilter); } else { return new ArrayList<NetworkVO>(); } }
List<Long> networkIds = _networkDomainDao.listNetworkIdsByDomain(domainId); CallContext ctx = CallContext.current(); ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallingUserId()), ctx.getCallingAccount());
@Override public boolean isNetworkAvailableInDomain(long networkId, long domainId) { Long networkDomainId = null; Network network = getNetwork(networkId); if (network.getGuestType() != GuestType.Shared && network.getGuestType() != GuestType.L2) { s_logger.trace("Network id=" + networkId + " is not shared or L2"); return false; } NetworkDomainVO networkDomainMap = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId); if (networkDomainMap == null) { s_logger.trace("Network id=" + networkId + " is shared or L2, but not domain specific"); return true; } else { networkDomainId = networkDomainMap.getDomainId(); } if (domainId == networkDomainId.longValue()) { return true; } if (networkDomainMap.subdomainAccess) { Set<Long> parentDomains = _domainMgr.getDomainParentIds(domainId); if (parentDomains.contains(networkDomainId)) { return true; } } return false; }
public static Pair<Long, Boolean> getDomainNetworkDetails(long networkId) { NetworkDomainVO map = s_networkDomainDao.getDomainNetworkMapByNetworkId(networkId); boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : s_networkModel.getAllowSubdomainAccessGlobal(); return new Pair<Long, Boolean>(map.getDomainId(), subdomainAccess); }
NetworkDomainVO domainNetworkMapByNetworkId = _networkDomainDao.getDomainNetworkMapByNetworkId(originalNetworkId); AccountVO networkAccount = _accountDao.findById(network.getAccountId());