weizhouapache commented on code in PR #7898:
URL: https://github.com/apache/cloudstack/pull/7898#discussion_r1304126696


##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -2475,7 +2476,20 @@ public Pair<List<? extends IpAddress>, Integer> 
searchForIPAddresses(final ListP
             for (IPAddressVO addr: freeAddrs) {
                 freeAddrIds.add(addr.getId());
             }
+        } else if (vlanType == VlanType.DirectAttached && network != null && 
!isAllocatedTemp && isAllocated) {
+            if (caller.getType() != Account.Type.ADMIN && 
!IpAddressManager.AllowUserListAvailableIpsOnSharedNetwork.value()) {
+                s_logger.debug("Non-admin users are not allowed to list 
available IPs on shared networks");
+            } else {
+                final SearchBuilder<IPAddressVO> searchBuilder = 
_publicIpAddressDao.createSearchBuilder();
+                buildParameters(searchBuilder, cmd, false);
+
+                SearchCriteria<IPAddressVO> searchCriteria = 
searchBuilder.create();
+                setParameters(searchCriteria, cmd, vlanType, false);
+                searchCriteria.setParameters("state", 
IpAddress.State.Free.name());
+                addrs.addAll(_publicIpAddressDao.search(searchCriteria, 
searchFilter)); // Free IPs on shared network
+            }

Review Comment:
   @DaanHoogland 
   moving to Dao seems difficult, as this code block calls two methods to build 
and set search parameters: `buildParameters` and `setParameters`
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to