Updated Branches: refs/heads/4.2 2b6b99ffb -> c1294fdfa
CLOUDSTACK-4596: CloudStack is currently allowing same ip range to be defined in different VLANs across public and portable ranges added checks to restric same ip range to be configure as both public ip range and 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/c1294fdf Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c1294fdf Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c1294fdf Branch: refs/heads/4.2 Commit: c1294fdfa019e4e86e52299378b244d46b06b5c2 Parents: 2b6b99f Author: Murali Reddy <muralimmre...@gmail.com> Authored: Fri Oct 18 15:06:35 2013 +0530 Committer: Murali Reddy <muralimmre...@gmail.com> Committed: Fri Oct 18 15:08:07 2013 +0530 ---------------------------------------------------------------------- .../configuration/ConfigurationManagerImpl.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1294fdf/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 b09b8ca..e77e1d1 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -3094,6 +3094,12 @@ 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()); + } + // 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 @@ -5091,17 +5097,18 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("Invalid vlan id " + vlanId); } - // check if there is zone vlan with same id List<DataCenterVO> zones= _zoneDao.listAllZones(); if (zones != null && !zones.isEmpty()) { for (DataCenterVO zone: zones) { + // check if there is zone vlan with same id if (_vlanDao.findByZoneAndVlanId(zone.getId(), vlanId) != null) { throw new InvalidParameterValueException("Found a VLAN id " + vlanId + " already existing in" + " zone " + zone.getUuid() + " that conflicts with VLAN id of the portable ip range being configured"); } + //check if there is a public ip range that overlaps with portable ip range being created + checkOverlapPublicIpRange(zone.getId(), startIP, endIP); } } - } GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange"); portableIpLock.lock(5); @@ -5204,6 +5211,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati long newEndIp = NetUtils.ip2Long(newEndIpStr); List<PortableIpRangeVO> existingPortableIPRanges = _portableIpRangeDao.listByRegionId(regionId); + + if (existingPortableIPRanges == null || existingPortableIPRanges.isEmpty()) { + return false; + } + for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) { String ipRangeStr = portableIpRange.getIpRange(); String[] range = ipRangeStr.split("-");