http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce9f1afa/server/src/com/cloud/network/NetworkManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/NetworkManagerImpl.java index 5ffbdcd,f9c2717..f60008b --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@@ -3044,8 -2778,13 +3040,13 @@@ public class NetworkManagerImpl impleme skipProjectNetworks = false; } + if (domainId != null) { + path = _domainDao.findById(domainId).getPath(); + } else { - path = _domainDao.findById(caller.getDomainId()).getPath(); + path = _domainDao.findById(caller.getDomainId()).getPath(); - if (listAll) { + } + + if (listAll && domainId == null) { isRecursive = true; } @@@ -3091,38 -2822,50 +3092,50 @@@ sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER); } - if (skipProjectNetworks) { + - SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder(); + SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder(); - accountSearch.and("type", accountSearch.entity().getType(), SearchCriteria.Op.NEQ); + accountSearch.and("typeNEQ", accountSearch.entity().getType(), SearchCriteria.Op.NEQ); + accountSearch.and("typeEQ", accountSearch.entity().getType(), SearchCriteria.Op.EQ); + + - sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER); - + sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER); - } + List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>(); - if (isSystem == null || !isSystem) { + if (isSystem == null || !isSystem) { - // Get domain level networks - if (domainId != null) { - networksToReturn - .addAll(listDomainLevelNetworks( - buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, - domainId)); - } - if (!permittedAccounts.isEmpty()) { + //get account level networks networksToReturn.addAll(listAccountSpecificNetworks( buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, tags), searchFilter, - permittedAccounts)); + physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, + permittedAccounts)); - } else if (domainId == null) { + //get domain level networks + if (domainId != null) { + networksToReturn + .addAll(listDomainLevelNetworks( + buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, tags), searchFilter, ++ physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, + domainId, false)); + } + } else { + //add account specific networks networksToReturn.addAll(listAccountSpecificNetworksByDomainPath( buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, tags), searchFilter, path, - isRecursive)); + physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path, + isRecursive)); + //add domain specific networks of domain + parent domains networksToReturn.addAll(listDomainSpecificNetworksByDomainPath( buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, tags), searchFilter, path, + physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path, isRecursive)); + //add networks of subdomains + if (domainId == null) { + networksToReturn + .addAll(listDomainLevelNetworks( + buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, - physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, tags), searchFilter, ++ physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, + caller.getDomainId(), true)); + } } } else { networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, @@@ -3223,9 -2966,11 +3236,11 @@@ } if (skipProjectNetworks) { - sc.setJoinParameters("accountSearch", "type", Account.ACCOUNT_TYPE_PROJECT); + sc.setJoinParameters("accountSearch", "typeNEQ", Account.ACCOUNT_TYPE_PROJECT); + } else { + sc.setJoinParameters("accountSearch", "typeEQ", Account.ACCOUNT_TYPE_PROJECT); } - + if (restartRequired != null) { sc.addAnd("restartRequired", SearchCriteria.Op.EQ, restartRequired); } @@@ -3302,21 -3046,38 +3320,38 @@@ sc.addAnd("id", SearchCriteria.Op.SC, accountSC); return _networksDao.search(sc, searchFilter); } - + - private List<NetworkVO> listDomainSpecificNetworksByDomainPath(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, boolean isRecursive) { - SearchCriteria<NetworkVO> accountSC = _networksDao.createSearchCriteria(); - accountSC.addAnd("aclType", SearchCriteria.Op.EQ, ACLType.Domain.toString()); + private List<NetworkVO> listDomainSpecificNetworksByDomainPath(SearchCriteria<NetworkVO> sc, Filter searchFilter, + String path, boolean isRecursive) { + Set<Long> allowedDomains = new HashSet<Long>(); - if (path != null) { + if (path != null) { if (isRecursive) { - sc.setJoinParameters("domainSearch", "path", path + "%"); + allowedDomains = _domainMgr.getDomainChildrenIds(path); } else { - sc.setJoinParameters("domainSearch", "path", path); + Domain domain = _domainDao.findDomainByPath(path); + allowedDomains.add(domain.getId()); } } - + - sc.addAnd("id", SearchCriteria.Op.SC, accountSC); + 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); + return _networksDao.search(sc, searchFilter); + } else { + return new ArrayList<NetworkVO>(); + } } @Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce9f1afa/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce9f1afa/setup/db/create-schema.sql ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce9f1afa/ui/index.jsp ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce9f1afa/ui/scripts/zoneWizard.js ---------------------------------------------------------------------- diff --cc ui/scripts/zoneWizard.js index 73e06ff,261668f..0ad0cc4 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@@ -2158,9 -2047,9 +2158,9 @@@ alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + errorMsg); } }); - }); - } - }, 3000); + }, 3000); + } + }); //add netscaler provider (end) } else { //selectedNetworkOfferingHavingNetscaler == false
