sureshanaparti commented on a change in pull request #4428:
URL: https://github.com/apache/cloudstack/pull/4428#discussion_r523992700
##########
File path:
engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
##########
@@ -115,22 +123,46 @@ protected EndPoint findEndPointInScope(Scope scope,
String sqlBase, Long poolId)
StringBuilder sbuilder = new StringBuilder();
sbuilder.append(sqlBase);
+ List<Long> dedicatedHosts = new ArrayList<Long>();
+
if (scope != null) {
if (scope.getScopeType() == ScopeType.HOST) {
sbuilder.append(" and h.id = ");
sbuilder.append(scope.getScopeId());
} else if (scope.getScopeType() == ScopeType.CLUSTER) {
sbuilder.append(" and h.cluster_id = ");
sbuilder.append(scope.getScopeId());
+ DedicatedResourceVO dedicatedHost =
dedicatedResourceDao.findByClusterId(scope.getScopeId());
+ if (dedicatedHost != null){
+ List<HostVO> clusterHosts =
hostDao.findByClusterId(scope.getScopeId());
+ for (HostVO hostVO: clusterHosts){
+ dedicatedHosts.add(hostVO.getId());
+ }
+ }
} else if (scope.getScopeType() == ScopeType.ZONE) {
sbuilder.append(" and h.data_center_id = ");
sbuilder.append(scope.getScopeId());
+ DedicatedResourceVO dedicatedHost =
dedicatedResourceDao.findByZoneId(scope.getScopeId());
+ if (dedicatedHost != null){
+ List<HostVO> zoneHosts =
hostDao.findByDataCenterId(scope.getScopeId());
+ for (HostVO hostVO: zoneHosts){
+ dedicatedHosts.add(hostVO.getId());
+ }
+ }
}
}
+ // We didn't find any hosts specifically dedicated to a zone or cluster
+ if (dedicatedHosts.size() == 0) {
+ dedicatedHosts = dedicatedResourceDao.listAllHosts();
Review comment:
@Spaceman1984 the scope is not considered here, this returns all the
dedicated hosts same as the earlier case.
If the cluster is not dedicated and some hosts in that cluster are
dedicated, then get the dedicated hosts in that cluster only, which you can
move to the end of the result set. Got me? Didn't see any dao method for this?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]