You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/23 07:29:59 UTC

[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #4438: Prometheus exporter enhancement

sureshanaparti commented on a change in pull request #4438:
URL: https://github.com/apache/cloudstack/pull/4438#discussion_r714536656



##########
File path: engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java
##########
@@ -411,6 +416,41 @@ public static void setValues(PreparedStatement preparedStatement, Object... valu
 
     }
 
+    @Override
+    public Ternary<Long, Long, Long> findCapacityByZoneAndHostTag(Long zoneId, String hostTag) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        PreparedStatement pstmt;
+
+        StringBuilder allocatedSql = new StringBuilder(LIST_ALLOCATED_CAPACITY_GROUP_BY_CAPACITY_AND_ZONE);
+        if (hostTag != null && ! hostTag.isEmpty()) {
+            allocatedSql.append(LEFT_JOIN_VM_TEMPLATE);
+        }
+        allocatedSql.append(WHERE_STATE_IS_NOT_DESTRUCTIVE);
+        if (zoneId != null){
+            allocatedSql.append(" AND vi.data_center_id = ?");
+        }
+        if (hostTag != null && ! hostTag.isEmpty()) {
+            allocatedSql.append(" AND (vm_template.template_tag = '").append(hostTag).append("'");
+            allocatedSql.append(" OR service_offering.host_tag = '").append(hostTag).append("')");
+        }
+        allocatedSql.append(" ) AS v GROUP BY v.data_center_id");
+
+        try {
+            // add allocated capacity of zone in result
+            pstmt = txn.prepareAutoCloseStatement(allocatedSql.toString());
+            if (zoneId != null){

Review comment:
       ```suggestion
               if (zoneId != null) {
   ```




-- 
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-unsubscribe@cloudstack.apache.org

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