soreana commented on a change in pull request #4438:
URL: https://github.com/apache/cloudstack/pull/4438#discussion_r769760141
##########
File path: engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java
##########
@@ -802,6 +802,27 @@ public Long countByZoneAndState(long zoneId, State state) {
return customSearch(sc, null).get(0);
}
+ @Override
+ public Long countByZoneAndStateAndHostTag(long dcId, State state, String
hostTag) {
+ TransactionLegacy txn = TransactionLegacy.currentTxn();
+ String sql = "SELECT COUNT(1) FROM vm_instance vi "
+ + "JOIN service_offering so ON vi.service_offering_id=so.id "
+ + "JOIN vm_template vt ON vi.vm_template_id = vt.id "
+ + "WHERE vi.data_center_id= " + dcId + " AND vi.state = '" +
state + "' AND vi.removed IS NULL "
+ + "AND (so.host_tag='" + hostTag + "' OR vt.template_tag='" +
hostTag + "')";
Review comment:
@DaanHoogland I gave up using search criteria and used prepared
statements. SearchCriteria with two join statements were over complicated for
me.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]