GabrielBrascher 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_r185795854
 
 

 ##########
 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:
   The problem is that I do not have a CIDR. The network CIDR (at least in the 
basic network) is null. I like the idea of isIp6InNetwork, but I will need to 
ignore CIDR at this stage and use only ipv4 range.

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


With regards,
Apache Git Services

Reply via email to