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 2018/05/03 01:21:11 UTC

[GitHub] rafaelweingartner commented on a change in pull request #2595: CLOUDSTACK-10199: Support requesting a specific IPv4 address

rafaelweingartner commented on a change in pull request #2595: CLOUDSTACK-10199: Support requesting a specific IPv4 address
URL: https://github.com/apache/cloudstack/pull/2595#discussion_r185681019
 
 

 ##########
 File path: engine/schema/src/main/java/com/cloud/dc/dao/VlanDaoImpl.java
 ##########
 @@ -82,6 +83,24 @@ public VlanVO findByZoneAndVlanId(long zoneId, String vlanId) {
         return findOneBy(sc);
     }
 
+    /**
+     * Returns a vlan by the network id and if the given IPv4 is in the network IP range.
+     */
+    @Override
+    public VlanVO findByNetworkIdAndIpv4Range(long networkId, String ipv4Address) {
+        List<VlanVO> vlanVoList = listVlansByNetworkId(networkId);
+        for (VlanVO vlan : vlanVoList) {
+            String ipRange = vlan.getIpRange();
+            String[] ipRangeParts = ipRange.split("-");
+            String startIP = ipRangeParts[0];
+            String endIP = ipRangeParts[1];
+            if (NetUtils.isIpInRange(ipv4Address, startIP, endIP)) {
 
 Review comment:
   What about using something similar to `isIp6InNetwork`?
   I also get a feeling that this method you implemented is doing the same as `isIpWithInCidrRange`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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