From e3ed681be64215476bf45a2c61fb3338664553e9 Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 27 Apr 2011 13:56:13 -0700 Subject: [PATCH] listNetworks: allow seeing Guest system network in Basic zone --- .../com/cloud/network/NetworkManagerImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index d49e48c2638..e863d48601d 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1728,21 +1728,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag List avoidNetworks = new ArrayList(); List allowedSharedNetworks = new ArrayList(); - if (isSystem == null) { + if (isSystem == null && id == null) { isSystem = false; } // Account/domainId parameters and isSystem are mutually exclusive - if (isSystem && (accountName != null || domainId != null)) { + if (isSystem != null && isSystem && (accountName != null || domainId != null)) { throw new InvalidParameterValueException("System network belongs to system, account and domainId parameters can't be specified"); } if (_accountMgr.isAdmin(account.getType())) { if (domainId != null) { - if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) { - throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list networks"); + DomainVO domain = _domainDao.findById(domainId); + if (domain == null) { + throw new InvalidParameterValueException("Domain id=" + domainId + " doesn't exist in the system"); } + _accountMgr.checkAccess(account, domain); + if (accountName != null) { account = _accountMgr.getActiveAccount(accountName, domainId); if (account == null) { @@ -1772,7 +1775,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // Don't display networks created of system network offerings SearchBuilder networkOfferingSearch = _networkOfferingDao.createSearchBuilder(); networkOfferingSearch.and("systemOnly", networkOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ); - if (isSystem) { + if (isSystem != null && isSystem) { networkOfferingSearch.and("trafficType", networkOfferingSearch.entity().getTrafficType(), SearchCriteria.Op.EQ); } sb.join("networkOfferingSearch", networkOfferingSearch, sb.entity().getNetworkOfferingId(), networkOfferingSearch.entity().getId(), JoinBuilder.JoinType.INNER); @@ -1824,7 +1827,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag sc.addAnd("guestType", SearchCriteria.Op.EQ, type); } - if (!isSystem) { + if (isSystem != null && !isSystem) { if (accountName != null && domainId != null) { if (isShared == null) { sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId); @@ -1880,7 +1883,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType); } - if (!isSystem && path != null && (isShared == null || !isShared)) { + if (isSystem != null && !isSystem && path != null && (isShared == null || !isShared)) { sc.setJoinParameters("domainSearch", "path", path + "%"); }