You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2019/05/30 11:05:49 UTC

[GitHub] [cloudstack] shwstppr commented on a change in pull request #3248: [WIP DO NOT MERGE] server: offerings for specified domain(s) and zone(s)

shwstppr commented on a change in pull request #3248: [WIP DO NOT MERGE] server: offerings for specified domain(s) and zone(s) 
URL: https://github.com/apache/cloudstack/pull/3248#discussion_r288948696
 
 

 ##########
 File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
 ##########
 @@ -2782,11 +2808,50 @@
             sc.addAnd("vmType", SearchCriteria.Op.EQ, vmTypeStr);
         }
 
+        if (zoneId != null) {
+            SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
+            sb.and("zoneId", sb.entity().getZoneId(), Op.FIND_IN_SET);
+            sb.or("zId", sb.entity().getZoneId(), Op.NULL);
+            sb.done();
+            SearchCriteria<ServiceOfferingJoinVO> zoneSC = sb.create();
+            zoneSC.setParameters("zoneId", String.valueOf(zoneId));
+            sc.addAnd("zoneId", SearchCriteria.Op.SC, zoneSC);
+        }
+
         Pair<List<ServiceOfferingJoinVO>, Integer> result = _srvOfferingJoinDao.searchAndCount(sc, searchFilter);
 
         //Couldn't figure out a smart way to filter offerings based on tags in sql so doing it in Java.
         List<ServiceOfferingJoinVO> filteredOfferings = filterOfferingsOnCurrentTags(result.first(), currentVmOffering);
-        return new Pair<>(filteredOfferings, result.second());
+        // Remove offerings that are not associated with caller's domain
+        // TODO: Better approach
 
 Review comment:
   @rhtyd I was hoping to do this with Java ArrayList _removeIf_ method to make code concise but it won't work.
   Concerned code needs to filter offerings. 
   Recursively  - when listing offerings for root or domain admin in ServiceOfferings page
   Non-recursively(including offerings from parent domain) - when listing offerings for vm deployment.
   Since we have multiple domains are linked with offerings, it is not possible to filter them with DB params alone as our *_offering_view gives comma-separated list of linked domains. Therefore had to be handled in Java code, I'll remove TODO comment.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services