From 03653b936e689f7725966a4c62971282a301908b Mon Sep 17 00:00:00 2001 From: prachi Date: Fri, 20 Jan 2012 17:21:23 -0800 Subject: [PATCH] NAAS Changes: Before enabling a Zone, Check if the zone has: - For Advance zone, a physical Network with Public/Management trafficType - For Basic zone, a physical Network with Management trafficType --- .../configuration/ConfigurationManagerImpl.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 02f2e0ab2c8..b7ab4db11dd 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1452,6 +1452,23 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (allocationStateStr != null && !allocationStateStr.isEmpty()) { Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr); + + if(allocationState == Grouping.AllocationState.Enabled){ + //check if zone has necessary trafficTypes before enabling + try{ + if(NetworkType.Advanced == zone.getNetworkType()){ + //zone should have a physical network with public and management traffiType + _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public); + _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management); + }else{ + //zone should have a physical network with management traffiType + _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management); + } + }catch(InvalidParameterValueException ex){ + throw new InvalidParameterValueException("Cannot enable this Zone since: "+ ex.getMessage()); + } + } + zone.setAllocationState(allocationState); }