@@ -2978,7 +2978,7 @@ private ListResponse<StoragePoolResponse> createStoragesPoolResponse(Pair<List<S
29782978 ListResponse <StoragePoolResponse > response = new ListResponse <>();
29792979
29802980 List <StoragePoolResponse > poolResponses = ViewResponseHelper .createStoragePoolResponse (storagePools .first ().toArray (new StoragePoolJoinVO [storagePools .first ().size ()]));
2981- Map <String , Long > poolUuidToIdMap = storagePools .first ().stream ().collect (Collectors .toMap (StoragePoolJoinVO ::getUuid , StoragePoolJoinVO ::getId ));
2981+ Map <String , Long > poolUuidToIdMap = storagePools .first ().stream ().collect (Collectors .toMap (StoragePoolJoinVO ::getUuid , StoragePoolJoinVO ::getId , ( a , b ) -> a ));
29822982 for (StoragePoolResponse poolResponse : poolResponses ) {
29832983 DataStore store = dataStoreManager .getPrimaryDataStore (poolResponse .getId ());
29842984 if (store != null ) {
@@ -3821,9 +3821,8 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
38213821 List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
38223822 if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
38233823 for (String tag : storageTags ) {
3824- diskOfferingSearch .and (tag , diskOfferingSearch .entity ().getTags (), Op .EQ );
3824+ diskOfferingSearch .and ("storageTag" + tag , diskOfferingSearch .entity ().getTags (), Op .FIND_IN_SET );
38253825 }
3826- diskOfferingSearch .done ();
38273826 }
38283827 }
38293828
@@ -3935,18 +3934,24 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
39353934 srvOffrDomainDetailSearch .entity ().getName (), serviceOfferingSearch .entity ().setString (ApiConstants .DOMAIN_ID ));
39363935 }
39373936
3937+ List <String > hostTags = getHostTagsFromTemplateForServiceOfferingsListing (caller , templateId );
39383938 if (currentVmOffering != null ) {
3939- List <String > hostTags = com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ());
3940- if (!hostTags .isEmpty ()) {
3941-
3942- serviceOfferingSearch .and ().op ("hostTag" , serviceOfferingSearch .entity ().getHostTag (), Op .NULL );
3943- serviceOfferingSearch .or ().op ();
3939+ hostTags .addAll (com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ()));
3940+ }
39443941
3945- for (String tag : hostTags ) {
3946- serviceOfferingSearch .and (tag , serviceOfferingSearch .entity ().getHostTag (), Op .EQ );
3942+ if (!hostTags .isEmpty ()) {
3943+ serviceOfferingSearch .and ().op ("hostTag" , serviceOfferingSearch .entity ().getHostTag (), Op .NULL );
3944+ serviceOfferingSearch .or ();
3945+ boolean flag = true ;
3946+ for (String tag : hostTags ) {
3947+ if (flag ) {
3948+ flag = false ;
3949+ serviceOfferingSearch .op ("hostTag" + tag , serviceOfferingSearch .entity ().getHostTag (), Op .FIND_IN_SET );
3950+ } else {
3951+ serviceOfferingSearch .and ("hostTag" + tag , serviceOfferingSearch .entity ().getHostTag (), Op .FIND_IN_SET );
39473952 }
3948- serviceOfferingSearch .cp ().cp ().done ();
39493953 }
3954+ serviceOfferingSearch .cp ().cp ();
39503955 }
39513956
39523957 SearchCriteria <ServiceOfferingVO > sc = serviceOfferingSearch .create ();
@@ -4063,41 +4068,19 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
40634068 sc .setJoinParameters ("domainDetailSearchNormalUser" , "domainIdIN" , domainIds .toArray ());
40644069 }
40654070
4066- List <String > hostTags = getHostTagsFromTemplateForServiceOfferingsListing (caller , templateId );
4067-
4068- if (currentVmOffering != null ) {
4069-
4070- if (diskOffering != null ) {
4071- List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
4072- if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
4073- for (String tag : storageTags ) {
4074- sc .setJoinParameters ("diskOfferingSearch" , tag , tag );
4075- }
4071+ if (diskOffering != null ) {
4072+ List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
4073+ if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
4074+ for (String tag : storageTags ) {
4075+ sc .setJoinParameters ("diskOfferingSearch" , "storageTag" + tag , tag );
40764076 }
40774077 }
4078-
4079- List <String > offeringHostTags = com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ());
4080- if (!offeringHostTags .isEmpty ()) {
4081- hostTags .addAll (offeringHostTags );
4082- }
40834078 }
4084- if (CollectionUtils .isNotEmpty (hostTags )) {
4085- SearchBuilder <ServiceOfferingJoinVO > hostTagsSearchBuilder = _srvOfferingJoinDao .createSearchBuilder ();
4086- for (String tag : hostTags ) {
4087- hostTagsSearchBuilder .and (tag , hostTagsSearchBuilder .entity ().getHostTag (), Op .FIND_IN_SET );
4088- }
4089- hostTagsSearchBuilder .done ();
40904079
4091- SearchCriteria < ServiceOfferingJoinVO > hostTagsSearchCriteria = hostTagsSearchBuilder . create ();
4092- for (String tag : hostTags ) {
4093- hostTagsSearchCriteria .setParameters (tag , tag );
4080+ if ( CollectionUtils . isNotEmpty ( hostTags )) {
4081+ for (String tag : hostTags ) {
4082+ sc .setParameters ("hostTag" + tag , tag );
40944083 }
4095-
4096- SearchCriteria <ServiceOfferingJoinVO > finalHostTagsSearchCriteria = _srvOfferingJoinDao .createSearchCriteria ();
4097- finalHostTagsSearchCriteria .addOr ("hostTag" , Op .NULL );
4098- finalHostTagsSearchCriteria .addOr ("hostTag" , Op .SC , hostTagsSearchCriteria );
4099-
4100- sc .addAnd ("hostTagsConstraint" , SearchCriteria .Op .SC , finalHostTagsSearchCriteria );
41014084 }
41024085
41034086 Pair <List <ServiceOfferingVO >, Integer > uniquePair = _srvOfferingDao .searchAndCount (sc , searchFilter );
0 commit comments