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 2019/08/19 11:15:30 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3562: New API endpoint: UpdateVlanIpRange

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

 ##########
 File path: server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
 ##########
 @@ -3958,6 +3960,116 @@ 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{
+
+        // verify parameters
+        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;
+        }
+
+        // Check if the VLAN has any allocated public IPs
+        final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(id);
+        for (final IPAddressVO ip : ips) {
+            if (ip.getState()== IpAddress.State.Allocated){
+                if (!Strings.isNullOrEmpty(startIp) && NetUtils.ip2Long(startIp) > NetUtils.ip2Long(ip.getAddress().addr())) {
 
 Review comment:
   Hey @kioie I answerred in the old PR but let's continue here. I think mentioning the upper and lower and maybe the number of addresses should give an admin enough info. I am not sure if we should block for that or do further work in a new PR. I'll leave that to you .

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services