ravening commented on a change in pull request #3997:
URL: https://github.com/apache/cloudstack/pull/3997#discussion_r521407293



##########
File path: 
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
##########
@@ -4075,6 +4079,152 @@ public VlanVO doInTransaction(final TransactionStatus 
status) {
 
     }
 
+    @Override
+    public Vlan updateVlanAndPublicIpRange(UpdateVlanIpRangeCmd cmd) throws 
ConcurrentOperationException,
+            ResourceUnavailableException,ResourceAllocationException {
+
+        return  updateVlanAndPublicIpRange(cmd.getId(), 
cmd.getStartIp(),cmd.getEndIp(),
+                cmd.getGateway(),cmd.getNetmask());
+    }
+
+    @DB
+    @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_UPDATE, 
eventDescription = "update vlan ip Range", async
+            = false)
+    public Vlan updateVlanAndPublicIpRange(final long id, String startIp,
+                                           String endIp,
+                                           String gateway,
+                                           String netmask) throws 
ConcurrentOperationException {
+
+        VlanVO vlanRange = _vlanDao.findById(id);
+        if (vlanRange == null) {
+            throw new InvalidParameterValueException("Please specify a valid 
IP range id.");
+        }
+
+        if (gateway == null) {
+            gateway = vlanRange.getVlanGateway();
+        }
+
+        if (netmask == null) {
+            netmask = vlanRange.getVlanNetmask();
+        }
+
+        final String[] existingVlanIPRangeArray = 
vlanRange.getIpRange().split("-");
+        final String currentStartIP = existingVlanIPRangeArray[0];
+        final String currentEndIP = existingVlanIPRangeArray [1];
+
+        if(startIp == null) {
+            startIp = currentStartIP;
+        }
+
+        if(endIp == null) {
+            endIp = currentEndIP;
+        }
+
+        final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(id);
+        checkAllocatedIpsAreWithinVlanRange(ips,startIp,endIp);
+
+        final String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
+        final String cidrAddress = getCidrAddress(cidr);
+        final long cidrSize = getCidrSize(cidr);
+
+        checkIpRange(currentStartIP,currentEndIP,cidrAddress,cidrSize);
+
+        checkIpRange(startIp, endIp, cidrAddress, cidrSize);
+
+        checkGatewayOverlap(startIp,endIp,gateway);
+
+        VlanVO range;
+        try {
+            final String newStartIP = startIp;
+            final String newEndIP = endIp;
+
+            range = _vlanDao.acquireInLockTable(id, 30);
+            if (range == null) {
+                throw new CloudRuntimeException("Unable to acquire vlan 
configuration: " + id);
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("lock vlan " + id + " is acquired");
+            }
+
+            commitUpdateVlanAndIpRange(id, newStartIP, newEndIP, 
currentStartIP, currentEndIP,true);

Review comment:
       are you using the `ipv4` parameter to check if its ipv4 or ipv6 ip range 
or some other reason?




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


Reply via email to