From c40a421eb662e56fb6d6a79946b39dca2fdd7b97 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 26 Jan 2012 14:04:43 -0800 Subject: [PATCH] Bug 13250 - Not able to start System Vms when 2 physical networks are configured if admin didn't specify storage traffic type before enabling zone, create default storage traffic type with the same configuration of mgmt traffic type. UI need a warning to admin, will file another bug for this status 13250: resolved fixed --- .../ConfigurationManagerImpl.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index b7ab4db11dd..35006d07fe6 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -112,10 +112,13 @@ import com.cloud.network.NetworkManager; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.TrafficType; +import com.cloud.network.PhysicalNetwork; import com.cloud.network.PhysicalNetworkVO; import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.PhysicalNetworkDao; +import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; +import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; @@ -236,6 +239,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura PhysicalNetworkDao _physicalNetworkDao; @Inject SwiftManager _swiftMgr; + @Inject + PhysicalNetworkTrafficTypeDao _trafficTypeDao; // FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao? protected static final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class); @@ -1456,13 +1461,22 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if(allocationState == Grouping.AllocationState.Enabled){ //check if zone has necessary trafficTypes before enabling try{ + PhysicalNetwork mgmtPhyNetwork; 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); + mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management); }else{ //zone should have a physical network with management traffiType - _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management); + mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management); + } + + try { + _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage); + } catch (InvalidParameterValueException noStorage) { + PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management); + _networkMgr.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan()); + s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + " with same configure of management traffic type"); } }catch(InvalidParameterValueException ex){ throw new InvalidParameterValueException("Cannot enable this Zone since: "+ ex.getMessage());