kioie commented on a change in pull request #3562: New API endpoint: 
UpdateVlanIpRange
URL: https://github.com/apache/cloudstack/pull/3562#discussion_r315976228
 
 

 ##########
 File path: 
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
 ##########
 @@ -1727,6 +1730,38 @@ private void checkZoneParameters(final String zoneName, 
final String dns1, final
         }
     }
 
+    private void checkAllocatedIpsAreWithinVlanRange(List<IPAddressVO> ips, 
String startIp, String endIp){
+        // Check if the VLAN has any allocated public IPs
+        List<IPAddressVO> listAllocatedIPs = new ArrayList<>();
+        for (final IPAddressVO ip : ips) {
+            if (ip.getState()== IpAddress.State.Allocated){
+                listAllocatedIPs.add(ip);
+            }
+        }
+        Collections.sort(listAllocatedIPs, 
Comparator.comparing(IPAddressVO::getAddress));
+        for (IPAddressVO allocatedIP : listAllocatedIPs){
+            if (!Strings.isNullOrEmpty(startIp) && NetUtils.ip2Long(startIp) > 
NetUtils.ip2Long(allocatedIP.getAddress().addr())) {
+                throw new InvalidParameterValueException("The start IP address 
must have a lower IP address value " +
+                        "than "+ allocatedIP.getAddress() + " which is already 
in use. The end IP must have a " +
+                        "higher IP address than "+ 
listAllocatedIPs.get(listAllocatedIPs.size() - 1).getAddress()+" .IPs " +
+                        "already allocated in this range: 
"+listAllocatedIPs.size());
+            }
+            if (!Strings.isNullOrEmpty(endIp) && NetUtils.ip2Long(endIp) < 
NetUtils.ip2Long(allocatedIP.getAddress().addr())) {
+                throw new InvalidParameterValueException("The start IP address 
must have a lower IP address value " +
+                        "than "+ listAllocatedIPs.get(0).getAddress() + " 
which is already in use. The end IP must have a " +
+                        "higher IP address than "+  allocatedIP.getAddress()+" 
.IPs " +
+                        "already allocated in this range: 
"+listAllocatedIPs.size());
+            }
+        }
+    }
+
+    private void checkGatewayOverlap(String startIp, String endIp, String 
gateway){
 
 Review comment:
   and this one

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to