Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@ private ListResponse<StoragePoolResponse> createStoragesPoolResponse(Pair<List<S
ListResponse<StoragePoolResponse> response = new ListResponse<>();

List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(storagePools.first().toArray(new StoragePoolJoinVO[storagePools.first().size()]));
Map<String, Long> poolUuidToIdMap = storagePools.first().stream().collect(Collectors.toMap(StoragePoolJoinVO::getUuid, StoragePoolJoinVO::getId));
Map<String, Long> poolUuidToIdMap = storagePools.first().stream().collect(Collectors.toMap(StoragePoolJoinVO::getUuid, StoragePoolJoinVO::getId, (a, b) -> a));
for (StoragePoolResponse poolResponse : poolResponses) {
DataStore store = dataStoreManager.getPrimaryDataStore(poolResponse.getId());
if (store != null) {
Expand Down Expand Up @@ -3790,9 +3790,8 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
List<String> storageTags = com.cloud.utils.StringUtils.csvTagsToList(diskOffering.getTags());
if (!storageTags.isEmpty() && VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.value()) {
for (String tag : storageTags) {
diskOfferingSearch.and(tag, diskOfferingSearch.entity().getTags(), Op.EQ);
diskOfferingSearch.and("storageTag" + tag, diskOfferingSearch.entity().getTags(), Op.FIND_IN_SET);
}
diskOfferingSearch.done();
}
}

Expand Down Expand Up @@ -3904,18 +3903,24 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
srvOffrDomainDetailSearch.entity().getName(), serviceOfferingSearch.entity().setString(ApiConstants.DOMAIN_ID));
}

List<String> hostTags = new ArrayList<>();
if (currentVmOffering != null) {
List<String> hostTags = com.cloud.utils.StringUtils.csvTagsToList(currentVmOffering.getHostTag());
if (!hostTags.isEmpty()) {

serviceOfferingSearch.and().op("hostTag", serviceOfferingSearch.entity().getHostTag(), Op.NULL);
serviceOfferingSearch.or().op();
hostTags.addAll(com.cloud.utils.StringUtils.csvTagsToList(currentVmOffering.getHostTag()));
}

for(String tag : hostTags) {
serviceOfferingSearch.and(tag, serviceOfferingSearch.entity().getHostTag(), Op.EQ);
if (!hostTags.isEmpty()) {
serviceOfferingSearch.and().op("hostTag", serviceOfferingSearch.entity().getHostTag(), Op.NULL);
serviceOfferingSearch.or();
boolean flag = true;
for(String tag : hostTags) {
if (flag) {
flag = false;
serviceOfferingSearch.op("hostTag" + tag, serviceOfferingSearch.entity().getHostTag(), Op.FIND_IN_SET);
} else {
serviceOfferingSearch.and("hostTag" + tag, serviceOfferingSearch.entity().getHostTag(), Op.FIND_IN_SET);
}
serviceOfferingSearch.cp().cp().done();
}
serviceOfferingSearch.cp().cp();
}

SearchCriteria<ServiceOfferingVO> sc = serviceOfferingSearch.create();
Expand Down Expand Up @@ -4032,22 +4037,18 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
sc.setJoinParameters("domainDetailSearchNormalUser", "domainIdIN", domainIds.toArray());
}

if (currentVmOffering != null) {

if (diskOffering != null) {
List<String> storageTags = com.cloud.utils.StringUtils.csvTagsToList(diskOffering.getTags());
if (!storageTags.isEmpty() && VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.value()) {
for(String tag : storageTags) {
sc.setJoinParameters("diskOfferingSearch", tag, tag);
}
if (diskOffering != null) {
List<String> storageTags = com.cloud.utils.StringUtils.csvTagsToList(diskOffering.getTags());
if (!storageTags.isEmpty() && VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.value()) {
for (String tag : storageTags) {
sc.setJoinParameters("diskOfferingSearch", "storageTag" + tag, tag);
}
}
}

List<String> hostTags = com.cloud.utils.StringUtils.csvTagsToList(currentVmOffering.getHostTag());
if (!hostTags.isEmpty()) {
for(String tag : hostTags) {
sc.setParameters(tag, tag);
}
if (!hostTags.isEmpty()) {
for(String tag : hostTags) {
sc.setParameters("hostTag" + tag, tag);
}
}

Expand Down