From e28ed752fcddf717358aba9da374135f97ff0613 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 4 Jan 2011 15:14:25 -0800 Subject: [PATCH] bug 7835: fixing the vnet range issues for add zone and edit zone status 7835: resolved fixed --- .../ConfigurationManagerImpl.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 9c54adc44f5..a0cdcd2f0e9 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -962,6 +962,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura // String domain = cmd.getDomain(); Long userId = UserContext.current().getCallerUserId(); // Long domainId = cmd.getDomainId(); + int startVnetRange = 0; + int stopVnetRange = 0; if (userId == null) { userId = Long.valueOf(User.UID_SYSTEM); @@ -991,6 +993,33 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (zoneHasAllocatedVnets(zoneId)) { throw new CloudRuntimeException("The vlan range is not editable because there are allocated vlans."); } + + String[] startStopRange = new String[2]; + startStopRange = vnetRange.split("-"); + + if(startStopRange.length == 1) { + throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096"); + } + + if(startStopRange[0] == null || startStopRange[1] == null) { + throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096"); + } + + try { + startVnetRange = Integer.parseInt(startStopRange[0]); + stopVnetRange = Integer.parseInt(startStopRange[1]); + } catch (NumberFormatException e) { + s_logger.warn("Unable to parse vnet range:",e); + throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096"); + } + + if(startVnetRange < 0 || stopVnetRange > 4096) { + throw new InvalidParameterValueException("Vnet range has to be between 0-4096"); + } + + if(startVnetRange > stopVnetRange) { + throw new InvalidParameterValueException("Vnet range has to be between 0-4096 and start range should be lesser than or equal to stop range"); + } } String oldZoneName = zone.getName(); @@ -1115,6 +1144,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } catch (NumberFormatException e) { throw new InvalidParameterValueException("Please specify valid integers for the vlan range."); } + + if(vnetStart > vnetEnd) { + s_logger.warn("Invalid vnet range: start range:"+vnetStart+" end range:"+vnetEnd); + throw new InvalidParameterValueException("Vnet range should be between 0-4096 and start range should be lesser than or equal to end range"); + } } //checking the following params outside checkzoneparams method as we do not use these params for updatezone