From 529d0706e17cc87e9819e03f6d840c7fcc3fa9ea Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 30 Jan 2012 12:31:03 -0800 Subject: [PATCH] SpecifyVlan should always be true for shared network offerings and for network offerings with specifyIpRanges=true SpecifyIpRanges should always be true for Shared network offerings --- .../ConfigurationManagerImpl.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 137a64c59ed..a2211b5ecb8 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -150,7 +150,6 @@ import com.cloud.utils.StringUtils; import com.cloud.utils.component.Adapters; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.component.Inject; -import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.DB; import com.cloud.utils.db.Filter; import com.cloud.utils.db.SearchCriteria; @@ -2253,11 +2252,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura throw new InvalidParameterValueException("Please specify a valid zone."); } - PhysicalNetworkVO pNtwk; - if (physicalNetworkId == null || ((pNtwk = _physicalNetworkDao.findById(physicalNetworkId)) == null)) { + if (physicalNetworkId == null || ((_physicalNetworkDao.findById(physicalNetworkId)) == null)) { throw new InvalidParameterValueException("Please specify a valid physical network."); } - // Allow adding untagged direct vlan only for Basic zone if (zone.getNetworkType() == NetworkType.Advanced && vlanId.equals(Vlan.UNTAGGED) && (!forVirtualNetwork || zone.isSecurityGroupEnabled())) { @@ -3155,6 +3152,20 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); tags = cleanupTags(tags); + //specifyIpRanges should always be true for Shared network offerings + if (!specifyIpRanges && type == GuestType.Shared) { + throw new InvalidParameterValueException("SpecifyIpRanges should be true if network offering's type is " + type); + } + + //specifyVlan should always be true for Shared network offerings and Isolated network offerings with specifyIpRanges = true + if (!specifyVlan) { + if (type == GuestType.Shared) { + throw new InvalidParameterValueException("SpecifyVlan should be true if network offering's type is " + type); + } else if (specifyIpRanges) { + throw new InvalidParameterValueException("SpecifyVlan should be true if network offering has specifyIpRanges=true"); + } + } + //validate availability value if (availability == NetworkOffering.Availability.Required) { boolean canOffBeRequired = (type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat));