mirror of https://github.com/apache/cloudstack.git
List service offerings without host tags when filtering VM which the current service offering has host tags (#6359)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
This commit is contained in:
parent
ac2857158d
commit
9bc3b7b98c
|
|
@ -3319,17 +3319,22 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
|
||||
List<String> hostTags = com.cloud.utils.StringUtils.csvTagsToList(currentVmOffering.getHostTag());
|
||||
if (!hostTags.isEmpty()) {
|
||||
SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
|
||||
SearchBuilder<ServiceOfferingJoinVO> hostTagsSearchBuilder = _srvOfferingJoinDao.createSearchBuilder();
|
||||
for(String tag : hostTags) {
|
||||
sb.and(tag, sb.entity().getHostTag(), Op.FIND_IN_SET);
|
||||
hostTagsSearchBuilder.and(tag, hostTagsSearchBuilder.entity().getHostTag(), Op.FIND_IN_SET);
|
||||
}
|
||||
sb.done();
|
||||
hostTagsSearchBuilder.done();
|
||||
|
||||
SearchCriteria<ServiceOfferingJoinVO> scc = sb.create();
|
||||
SearchCriteria<ServiceOfferingJoinVO> hostTagsSearchCriteria = hostTagsSearchBuilder.create();
|
||||
for(String tag : hostTags) {
|
||||
scc.setParameters(tag, tag);
|
||||
hostTagsSearchCriteria.setParameters(tag, tag);
|
||||
}
|
||||
sc.addAnd("hostTags", SearchCriteria.Op.SC, scc);
|
||||
|
||||
SearchCriteria<ServiceOfferingJoinVO> finalHostTagsSearchCriteria = _srvOfferingJoinDao.createSearchCriteria();
|
||||
finalHostTagsSearchCriteria.addOr("hostTag", Op.NULL);
|
||||
finalHostTagsSearchCriteria.addOr("hostTag", Op.SC, hostTagsSearchCriteria);
|
||||
|
||||
sc.addAnd("hostTagsConstraint", SearchCriteria.Op.SC, finalHostTagsSearchCriteria);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue