@@ -2977,7 +2977,7 @@ private ListResponse<StoragePoolResponse> createStoragesPoolResponse(Pair<List<S
29772977 ListResponse <StoragePoolResponse > response = new ListResponse <>();
29782978
29792979 List <StoragePoolResponse > poolResponses = ViewResponseHelper .createStoragePoolResponse (storagePools .first ().toArray (new StoragePoolJoinVO [storagePools .first ().size ()]));
2980- Map <String , Long > poolUuidToIdMap = storagePools .first ().stream ().collect (Collectors .toMap (StoragePoolJoinVO ::getUuid , StoragePoolJoinVO ::getId ));
2980+ Map <String , Long > poolUuidToIdMap = storagePools .first ().stream ().collect (Collectors .toMap (StoragePoolJoinVO ::getUuid , StoragePoolJoinVO ::getId , ( a , b ) -> a ));
29812981 for (StoragePoolResponse poolResponse : poolResponses ) {
29822982 DataStore store = dataStoreManager .getPrimaryDataStore (poolResponse .getId ());
29832983 if (store != null ) {
@@ -3790,9 +3790,8 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
37903790 List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
37913791 if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
37923792 for (String tag : storageTags ) {
3793- diskOfferingSearch .and (tag , diskOfferingSearch .entity ().getTags (), Op .EQ );
3793+ diskOfferingSearch .and ("storageTag" + tag , diskOfferingSearch .entity ().getTags (), Op .FIND_IN_SET );
37943794 }
3795- diskOfferingSearch .done ();
37963795 }
37973796 }
37983797
@@ -3904,18 +3903,24 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
39043903 srvOffrDomainDetailSearch .entity ().getName (), serviceOfferingSearch .entity ().setString (ApiConstants .DOMAIN_ID ));
39053904 }
39063905
3906+ List <String > hostTags = new ArrayList <>();
39073907 if (currentVmOffering != null ) {
3908- List <String > hostTags = com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ());
3909- if (!hostTags .isEmpty ()) {
3910-
3911- serviceOfferingSearch .and ().op ("hostTag" , serviceOfferingSearch .entity ().getHostTag (), Op .NULL );
3912- serviceOfferingSearch .or ().op ();
3908+ hostTags .addAll (com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ()));
3909+ }
39133910
3914- for (String tag : hostTags ) {
3915- serviceOfferingSearch .and (tag , serviceOfferingSearch .entity ().getHostTag (), Op .EQ );
3911+ if (!hostTags .isEmpty ()) {
3912+ serviceOfferingSearch .and ().op ("hostTag" , serviceOfferingSearch .entity ().getHostTag (), Op .NULL );
3913+ serviceOfferingSearch .or ();
3914+ boolean flag = true ;
3915+ for (String tag : hostTags ) {
3916+ if (flag ) {
3917+ flag = false ;
3918+ serviceOfferingSearch .op ("hostTag" + tag , serviceOfferingSearch .entity ().getHostTag (), Op .FIND_IN_SET );
3919+ } else {
3920+ serviceOfferingSearch .and ("hostTag" + tag , serviceOfferingSearch .entity ().getHostTag (), Op .FIND_IN_SET );
39163921 }
3917- serviceOfferingSearch .cp ().cp ().done ();
39183922 }
3923+ serviceOfferingSearch .cp ().cp ();
39193924 }
39203925
39213926 SearchCriteria <ServiceOfferingVO > sc = serviceOfferingSearch .create ();
@@ -4032,22 +4037,18 @@ private Pair<List<Long>, Integer> searchForServiceOfferingIdsAndCount(ListServic
40324037 sc .setJoinParameters ("domainDetailSearchNormalUser" , "domainIdIN" , domainIds .toArray ());
40334038 }
40344039
4035- if (currentVmOffering != null ) {
4036-
4037- if (diskOffering != null ) {
4038- List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
4039- if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
4040- for (String tag : storageTags ) {
4041- sc .setJoinParameters ("diskOfferingSearch" , tag , tag );
4042- }
4040+ if (diskOffering != null ) {
4041+ List <String > storageTags = com .cloud .utils .StringUtils .csvTagsToList (diskOffering .getTags ());
4042+ if (!storageTags .isEmpty () && VolumeApiServiceImpl .MatchStoragePoolTagsWithDiskOffering .value ()) {
4043+ for (String tag : storageTags ) {
4044+ sc .setJoinParameters ("diskOfferingSearch" , "storageTag" + tag , tag );
40434045 }
40444046 }
4047+ }
40454048
4046- List <String > hostTags = com .cloud .utils .StringUtils .csvTagsToList (currentVmOffering .getHostTag ());
4047- if (!hostTags .isEmpty ()) {
4048- for (String tag : hostTags ) {
4049- sc .setParameters (tag , tag );
4050- }
4049+ if (!hostTags .isEmpty ()) {
4050+ for (String tag : hostTags ) {
4051+ sc .setParameters ("hostTag" + tag , tag );
40514052 }
40524053 }
40534054
0 commit comments