Skip to content

Commit 3d10f70

Browse files
author
Jessica Wang
committed
CLOUDSTACK-2120: API - mixed zone management - fix a bug that listTemplates/listIsos API didn't take in zoneType properly.
1 parent 50a3c91 commit 3d10f70

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,15 @@ public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, Templa
562562
sql = SELECT_TEMPLATE_HOST_REF;
563563
groupByClause = " GROUP BY t.id, h.data_center_id ";
564564
}
565-
if (((templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.community)) ||(zoneType != null && zoneId != null)) {
565+
if ((templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.community)) {
566566
dataCenterJoin = " INNER JOIN data_center dc on (h.data_center_id = dc.id)";
567567
}
568-
568+
569+
if (zoneType != null) {
570+
dataCenterJoin = " INNER JOIN template_host_ref thr on (t.id = thr.template_id) INNER JOIN host h on (thr.host_id = h.id)";
571+
dataCenterJoin += " INNER JOIN data_center dc on (h.data_center_id = dc.id)";
572+
}
573+
569574
if (templateFilter == TemplateFilter.sharedexecutable || templateFilter == TemplateFilter.shared ){
570575
lpjoin = " INNER JOIN launch_permission lp ON t.id = lp.template_id ";
571576
}
@@ -783,13 +788,15 @@ private String getExtrasWhere(TemplateFilter templateFilter, String name, String
783788
sql += " AND h.data_center_id = " +zoneId;
784789
}
785790
}else if (zoneId != null){
786-
sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
787-
if (zoneType != null){
788-
sql += " AND dc.networktype = " + zoneType;
789-
}
791+
sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
790792
}else{
791793
sql += " AND tzr.removed is null ";
792794
}
795+
796+
if (zoneType != null){
797+
sql += " AND dc.networktype = '" + zoneType + "'";
798+
}
799+
793800
if (!showDomr){
794801
sql += " AND t.type != '" +Storage.TemplateType.SYSTEM.toString() + "'";
795802
}

0 commit comments

Comments
 (0)