Updated Branches:
  refs/heads/4.2 624b324cc -> 779ef4b4c

CLOUDSTACK-3911: [PortableIP] there is no check while adding a zone
public range to see whether the same VLAN exists in portable IP range.

added check to enusre a VLAN id used for a public IP range is not used
for portable ip range


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/779ef4b4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/779ef4b4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/779ef4b4

Branch: refs/heads/4.2
Commit: 779ef4b4c51ca8961098f885811d18d6f1401e0e
Parents: 624b324
Author: Murali Reddy <muralimmre...@gmail.com>
Authored: Fri Oct 18 17:22:03 2013 +0530
Committer: Murali Reddy <muralimmre...@gmail.com>
Committed: Fri Oct 18 17:23:23 2013 +0530

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java | 26 ++++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/779ef4b4/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java 
b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 4df12e2..1d55886 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3099,11 +3099,7 @@ public class ConfigurationManagerImpl extends 
ManagerBase implements Configurati
             // Check if there are any errors with the IP range
             checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, 
startIP, endIP);
 
-            // check and throw exception if there is portable IP range that 
overlaps with ip range being configure
-            if (checkOverlapPortableIpRange(_regionDao.getRegionId(), startIP, 
endIP)) {
-                throw new InvalidParameterValueException("Ip  range: " + 
startIP + "-" + endIP
-                        + " overlaps with a portable" + " IP range already 
configured in the region " + _regionDao.getRegionId());
-            }
+            checkConflictsWithPortableIpRange(zoneId, vlanId, vlanGateway, 
vlanNetmask, startIP, endIP);
 
             // Throw an exception if this subnet overlaps with subnet on other 
VLAN,
             // if this is ip range extension, gateway, network mask should be 
same and ip range should not overlap
@@ -3620,6 +3616,26 @@ public class ConfigurationManagerImpl extends 
ManagerBase implements Configurati
         }
     }
 
+    private void checkConflictsWithPortableIpRange(long zoneId, String vlanId, 
String vlanGateway, String vlanNetmask,
+                                          String startIP, String endIP) {
+        // check and throw exception if there is portable IP range that 
overlaps with public ip range being configured
+        if (checkOverlapPortableIpRange(_regionDao.getRegionId(), startIP, 
endIP)) {
+            throw new InvalidParameterValueException("Ip range: " + startIP + 
"-" + endIP
+                    + " overlaps with a portable" + " IP range already 
configured in the region " + _regionDao.getRegionId());
+        }
+
+        // verify and throw exception if the VLAN Id is used by any portable 
IP range
+        List<PortableIpRangeVO> existingPortableIPRanges = 
_portableIpRangeDao.listByRegionId(_regionDao.getRegionId());
+        if (existingPortableIPRanges != null && 
!existingPortableIPRanges.isEmpty()) {
+            for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) 
{
+                if (portableIpRange.getVlanTag().equalsIgnoreCase(vlanId)) {
+                    throw new InvalidParameterValueException("The VLAN tag " + 
vlanId
+                            + " is already being used for portable ip range in 
this region");
+                }
+            }
+        }
+    }
+
     private String getCidrAddress(String cidr) {
         String[] cidrPair = cidr.split("\\/");
         return cidrPair[0];

Reply via email to