shwstppr commented on code in PR #10289:
URL: https://github.com/apache/cloudstack/pull/10289#discussion_r1990706579


##########
engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java:
##########
@@ -1756,6 +1758,29 @@ public List<HypervisorType> 
listDistinctHypervisorTypes(final Long zoneId) {
         return customSearch(sc, null);
     }
 
+    @Override
+    public List<Pair<HypervisorType, CPU.CPUArch>> 
listDistinctHypervisorArchTypes(final Long zoneId) {
+        List<Pair<HypervisorType, CPU.CPUArch>> hypervisorArchList = new 
ArrayList<>();
+        String selectSql = "SELECT DISTINCT hypervisor_type, arch FROM 
cloud.host WHERE removed IS NULL";
+        if (zoneId != null) {
+            selectSql += " AND data_center_id=" + zoneId;
+        }
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try {
+            PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
+            ResultSet rs = stmt.executeQuery();
+            while (rs.next()) {
+                HypervisorType hypervisorType = 
HypervisorType.valueOf(rs.getString("hypervisor_type"));
+                CPU.CPUArch arch = CPU.CPUArch.fromType(rs.getString("arch"));
+                hypervisorArchList.add(new Pair<>(hypervisorType, arch));
+            }
+        } catch (SQLException ex) {
+            logger.error("DB exception {}", ex.getMessage(), ex);
+            return Collections.emptyList();
+        }
+        return hypervisorArchList;
+    }
+

Review Comment:
   @nvazquez moving a method with specific columns in GenericDaoBase doesn't 
sound right to me.
   I've refactored the code use SearchBuilder and SearchCriteria instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to