Updated Branches:
  refs/heads/4.2 63e73ca94 -> 80dd1e263

CLOUDSTACK-4277:listTemplate should return empty list without any zone
configuration.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/80dd1e26
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/80dd1e26
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/80dd1e26

Branch: refs/heads/4.2
Commit: 80dd1e263f1e7743f1c6d343d744bf97433002e8
Parents: 63e73ca
Author: Min Chen <[email protected]>
Authored: Thu Aug 15 16:27:31 2013 -0700
Committer: Min Chen <[email protected]>
Committed: Thu Aug 15 16:34:11 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/api/query/QueryManagerImpl.java   | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/80dd1e26/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java 
b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 586b6d2..879e74d 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -138,8 +138,6 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.ha.HighAvailabilityManager;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.dao.NetworkDomainVO;
-import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.security.SecurityGroupVMMapVO;
 import com.cloud.network.security.dao.SecurityGroupVMMapDao;
 import com.cloud.org.Grouping;
@@ -2719,6 +2717,16 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
             Long startIndex, Long zoneId, HypervisorType hyperType, boolean 
showDomr, boolean onlyReady,
             List<Account> permittedAccounts, Account caller, 
ListProjectResourcesCriteria listProjectResourcesCriteria,
             Map<String, String> tags) {
+
+        // check if zone is configured, if not, just return empty list
+        List<HypervisorType> hypers = null;
+        if (!isIso) {
+            hypers = _resourceMgr.listAvailHypervisorInZone(null, null);
+            if (hypers == null || hypers.isEmpty()) {
+                return new Pair<List<TemplateJoinVO>, Integer>(new 
ArrayList<TemplateJoinVO>(), 0);
+            }
+        }
+
         VMTemplateVO template = null;
 
         Boolean isAscending = 
Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
@@ -2768,10 +2776,10 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
                 domain = _domainDao.findById(DomainVO.ROOT_DOMAIN);
             }
 
-            List<HypervisorType> hypers = null;
-            if (!isIso) {
-                hypers = _resourceMgr.listAvailHypervisorInZone(null, null);
-            }
+            // List<HypervisorType> hypers = null;
+            // if (!isIso) {
+            // hypers = _resourceMgr.listAvailHypervisorInZone(null, null);
+            // }
 
             // add criteria for project or not
             if (listProjectResourcesCriteria == 
ListProjectResourcesCriteria.SkipProjectResources) {
@@ -3042,7 +3050,7 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
         Filter searchFilter = new Filter(AffinityGroupJoinVO.class, "id", 
true, startIndex, pageSize);
         SearchCriteria<AffinityGroupJoinVO> sc = 
buildAffinityGroupSearchCriteria(domainId, isRecursive,
                 permittedAccounts, listProjectResourcesCriteria, 
affinityGroupId, affinityGroupName, affinityGroupType);
-        
+
         Pair<List<AffinityGroupJoinVO>, Integer> uniqueGroupsPair = 
_affinityGroupJoinDao.searchAndCount(sc,
                 searchFilter);
         // search group details by ids

Reply via email to