Updated Branches:
  refs/heads/master ad269304f -> 6689e83d7

CLOUDSTACK-3513: ListIsos/ListTemplates does not return correct results
when id and zoneid are passed.


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

Branch: refs/heads/master
Commit: 6689e83d7f8c5af834e2d730d74654318e93b2a4
Parents: ad26930
Author: Min Chen <[email protected]>
Authored: Sat Jul 20 15:15:52 2013 -0700
Committer: Min Chen <[email protected]>
Committed: Sat Jul 20 15:18:33 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/api/query/QueryManagerImpl.java   | 24 +++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6689e83d/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 cef5ddf..33327db 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -2876,17 +2876,6 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
                 sc.addAnd("state", SearchCriteria.Op.SC, readySc);
             }
 
-            if (zoneId != null) {
-                SearchCriteria<TemplateJoinVO> zoneSc = 
_templateJoinDao.createSearchCriteria();
-                zoneSc.addOr("dataCenterId", SearchCriteria.Op.EQ, zoneId);
-                zoneSc.addOr("dataStoreScope", SearchCriteria.Op.EQ, 
ScopeType.REGION);
-                // handle the case where xs-tools.iso and vmware-tools.iso do 
not have data_center information in template_view
-                SearchCriteria<TemplateJoinVO> isoPerhostSc = 
_templateJoinDao.createSearchCriteria();
-                isoPerhostSc.addAnd("format", SearchCriteria.Op.EQ, 
ImageFormat.ISO);
-                isoPerhostSc.addAnd("templateType", SearchCriteria.Op.EQ, 
TemplateType.PERHOST);
-                zoneSc.addOr("templateType", SearchCriteria.Op.SC, 
isoPerhostSc);
-                sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
-            }
 
             if (!showDomr) {
                 // excluding system template
@@ -2894,6 +2883,19 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
             }
         }
 
+        if (zoneId != null) {
+            SearchCriteria<TemplateJoinVO> zoneSc = 
_templateJoinDao.createSearchCriteria();
+            zoneSc.addOr("dataCenterId", SearchCriteria.Op.EQ, zoneId);
+            zoneSc.addOr("dataStoreScope", SearchCriteria.Op.EQ, 
ScopeType.REGION);
+            // handle the case where xs-tools.iso and vmware-tools.iso do not
+            // have data_center information in template_view
+            SearchCriteria<TemplateJoinVO> isoPerhostSc = 
_templateJoinDao.createSearchCriteria();
+            isoPerhostSc.addAnd("format", SearchCriteria.Op.EQ, 
ImageFormat.ISO);
+            isoPerhostSc.addAnd("templateType", SearchCriteria.Op.EQ, 
TemplateType.PERHOST);
+            zoneSc.addOr("templateType", SearchCriteria.Op.SC, isoPerhostSc);
+            sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
+        }
+
         // don't return removed template, this should not be needed since we
         // changed annotation for removed field in TemplateJoinVO.
         // sc.addAnd("removed", SearchCriteria.Op.NULL);

Reply via email to