From 87f5150e381ea3350e68a04e57499121d5c5998f Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 14 Nov 2011 10:43:47 -0800 Subject: [PATCH] Basic zone is fixed and works with new NaaS now --- .../ConfigurationManagerImpl.java | 19 +--- .../DefaultComponentLibrary.java | 4 +- .../consoleproxy/ConsoleProxyManagerImpl.java | 31 +++++-- .../src/com/cloud/network/NetworkManager.java | 2 - .../com/cloud/network/NetworkManagerImpl.java | 91 +++++++++---------- .../src/com/cloud/network/dao/NetworkDao.java | 1 + .../com/cloud/network/dao/NetworkDaoImpl.java | 9 ++ .../lb/ElasticLoadBalancerManagerImpl.java | 23 ++--- .../SecondaryStorageManagerImpl.java | 25 ++++- .../cloud/network/MockNetworkManagerImpl.java | 6 -- 10 files changed, 107 insertions(+), 104 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 5da6e4ea8d4..e97dfcbeec2 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1429,11 +1429,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura // the zone creation if (zone != null) { List ntwkOff = _networkOfferingDao.listSystemNetworkOfferings(); - - //for Advance security group enabled zone and Basic zone we have to find only one guest network offering enabled in the system - if (zone.getNetworkType() == NetworkType.Basic || isSecurityGroupEnabled) { - ntwkOff.add(_networkMgr.getExclusiveGuestNetworkOffering()); - } for (NetworkOfferingVO offering : ntwkOff) { DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null, null, null); @@ -1453,20 +1448,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } else { continue; } - } else if (offering.getTrafficType() == TrafficType.Guest) { - if (zone.getNetworkType() == NetworkType.Basic) { - isNetworkDefault = true; - broadcastDomainType = BroadcastDomainType.Native; - //set physicalnetworkId to the default Guest network in a basic Zone. - plan = new DataCenterDeployment(zone.getId(), null, null, null, null, physicalNetworkId); - } else if (offering.getGuestType() == GuestType.Shared && isSecurityGroupEnabled) { - isNetworkDefault = true; - } else { - continue; - } - - networkDomain = "cs" + Long.toHexString(Account.ACCOUNT_ID_SYSTEM) + _networkMgr.getGlobalGuestDomainSuffix(); } + userNetwork.setBroadcastDomainType(broadcastDomainType); userNetwork.setNetworkDomain(networkDomain); _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, isNetworkDefault, false, Domain.ROOT_DOMAIN, null); diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index df876f36bfa..c2c56224578 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -22,6 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.cloud.identity.IdentityServiceImpl; +import com.cloud.identity.dao.IdentityDaoImpl; import com.cloud.agent.manager.ClusteredAgentManagerImpl; import com.cloud.alert.AlertManagerImpl; import com.cloud.alert.dao.AlertDaoImpl; @@ -65,8 +67,6 @@ import com.cloud.host.dao.HostDetailsDaoImpl; import com.cloud.host.dao.HostTagsDaoImpl; import com.cloud.hypervisor.HypervisorGuruManagerImpl; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl; -import com.cloud.identity.IdentityServiceImpl; -import com.cloud.identity.dao.IdentityDaoImpl; import com.cloud.keystore.KeystoreDaoImpl; import com.cloud.keystore.KeystoreManagerImpl; import com.cloud.maint.UpgradeManagerImpl; diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 00389780c2d..63c4a59ae8c 100755 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -32,6 +32,7 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; +import com.cloud.identity.dao.IdentityDao; import com.cloud.agent.AgentManager; import com.cloud.agent.api.AgentControlAnswer; import com.cloud.agent.api.Answer; @@ -69,12 +70,11 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.StorageUnavailableException; -import com.cloud.host.Host.Type; import com.cloud.host.Host; +import com.cloud.host.Host.Type; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.identity.dao.IdentityDao; import com.cloud.info.ConsoleProxyConnectionInfo; import com.cloud.info.ConsoleProxyInfo; import com.cloud.info.ConsoleProxyLoadInfo; @@ -88,6 +88,7 @@ import com.cloud.keystore.KeystoreVO; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.TrafficType; +import com.cloud.network.dao.NetworkDao; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.resource.ResourceManager; @@ -118,10 +119,10 @@ import com.cloud.utils.component.Inject; import com.cloud.utils.component.Manager; import com.cloud.utils.db.DB; import com.cloud.utils.db.GlobalLock; +import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.SearchCriteria2; import com.cloud.utils.db.SearchCriteriaService; import com.cloud.utils.db.Transaction; -import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.events.SubscriptionMgr; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; @@ -208,10 +209,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx @Inject UserVmDetailsDao _vmDetailsDao; @Inject - ResourceManager _resourceMgr; - + ResourceManager _resourceMgr; @Inject IdentityDao _identityDao; + @Inject + NetworkDao _networkDao; private ConsoleProxyListener _listener; @@ -220,6 +222,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx NetworkOfferingVO _publicNetworkOffering; NetworkOfferingVO _managementNetworkOffering; NetworkOfferingVO _linkLocalNetworkOffering; + @Inject private VirtualMachineManager _itMgr; @@ -560,18 +563,28 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx Account systemAcct = _accountMgr.getSystemAccount(); DataCenterDeployment plan = new DataCenterDeployment(dataCenterId); - NetworkOfferingVO defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0); - + + TrafficType defaultTrafficType = TrafficType.Public; if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { - defaultOffering = _networkMgr.getExclusiveGuestNetworkOffering(); + defaultTrafficType = TrafficType.Guest; } + + List defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); + + if (defaultNetworks.size() != 1) { + throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1"); + } + + NetworkVO defaultNetwork = defaultNetworks.get(0); List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork); List> networks = new ArrayList>(offerings.size() + 1); NicProfile defaultNic = new NicProfile(); defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false).get(0), defaultNic)); + + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), null, plan, null, null, false, false, null, null).get(0), defaultNic)); + for (NetworkOfferingVO offering : offerings) { networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null)); } diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index cff95787e6a..3084d3396f2 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -235,8 +235,6 @@ public interface NetworkManager extends NetworkService { List getElementServices(Provider provider); boolean canElementEnableIndividualServices(Provider provider); - - NetworkOfferingVO getExclusiveGuestNetworkOffering(); PhysicalNetworkServiceProvider addDefaultVirtualRouterToPhysicalNetwork(long physicalNetworkId); diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 1548430d294..a55904da8cd 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1148,22 +1148,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } return offerings; } - - - @Override - public NetworkOfferingVO getExclusiveGuestNetworkOffering() { - //this method should return Guest network offering in Enabled state; and this network offering should be unique, otherwise Runtime exception is going to be thrown - List offerings = _networkOfferingDao.listByTrafficTypeGuestTypeAndState(NetworkOffering.State.Enabled, TrafficType.Guest, GuestType.Shared); - if (offerings.isEmpty()) { - throw new CloudRuntimeException("Unable to find network offering in state " + NetworkOffering.State.Enabled + ", traffic type " + TrafficType.Guest + " and guest type " + GuestType.Shared); - } - - if (offerings.size() > 1) { - throw new CloudRuntimeException("Found more than 1 network offering in state " + NetworkOffering.State.Enabled + ", traffic type " + TrafficType.Guest + " and guest type " + GuestType.Shared); - - } - return offerings.get(0); - } @Override @DB @@ -1886,12 +1870,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Network network = createNetwork(networkOfferingId, name, displayText, isDefault, gateway, cidr, vlanId, networkDomain, owner, false, sharedDomainId, pNtwk, zoneId, aclType); - //Vlan is created in 2 cases: + //Vlan is created in 2 cases - works in Advance zone only: //1) GuestType is Shared //2) GuestType is Isolated, but SourceNat service is disabled boolean createVlan = ((network.getGuestType() == Network.GuestType.Shared) || (network.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))); - if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan && defineNetworkConfig) { + if (zone.getNetworkType() == NetworkType.Advanced && caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan && defineNetworkConfig) { // Create vlan ip range _configMgr.createVlanAndPublicIpRange(userId, pNtwk.getDataCenterId(), null, startIP, endIP, gateway, netmask, false, vlanId, null, network.getId(), physicalNetworkId); } @@ -1908,25 +1892,31 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); DataCenterVO zone = _dcDao.findById(zoneId); -// removed during the merge for network as service -// Only Direct Account specific networks can be created in Advanced Security Group enabled zone -// if (zone.isSecurityGroupEnabled() && (networkOffering.getGuestType() == GuestIpType.Virtual || (isShared != null && isShared))) { -// throw new InvalidParameterValueException("Virtual Network and Direct Shared Network creation is not allowed if zone is security group enabled"); -// } -// -// if (zone.getNetworkType() == NetworkType.Basic) { -// throw new InvalidParameterValueException("Network creation is not allowed in zone with network type " + NetworkType.Basic); -// } -// - - //Only one guest network is supported in Basic zone - if (zone.getNetworkType() == NetworkType.Basic) { - throw new InvalidParameterValueException("Network creation is not allowed in zone with network type " + NetworkType.Basic); - } + if (zone.getNetworkType() == NetworkType.Basic) { + //Only one guest network is supported in Basic zone + List guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest); + if (!guestNetworks.isEmpty()) { + throw new InvalidParameterValueException("Can't have more than one Guest network in zone with network type " + NetworkType.Basic); + } + + //if zone is basic, only Shared network offerings w/o source nat service are allowed + if (!(networkOffering.getGuestType() == GuestType.Shared && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) { + throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName() + " service are allowed"); + } + + } else if (zone.isSecurityGroupEnabled()) { + //Only Account specific Isolated network with sourceNat service disabled are allowed in security group enabled zone + boolean allowCreation = (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)); + if (!allowCreation) { + throw new InvalidParameterValueException("Only Account specific Isolated network with sourceNat service disabled are allowed in security group enabled zone"); + } + } + + // allow isDefault to be set only for Shared network and Isolated networks with source nat disabled service - boolean allowSettingDefault = (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))); + boolean allowSettingDefault = (zone.getNetworkType() == NetworkType.Advanced && (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)))); if (allowSettingDefault) { if (isDefault == null) { isDefault = false; @@ -1934,18 +1924,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } else { if (isDefault == null) { isDefault = true; + } else { + throw new InvalidParameterValueException("isDefault parameter can be passed in only for network creation of guestType Shared or Isolated with source nat service disabled; and only in Advance zone"); } } - - // Don't allow to create network with vlan that already exists in the system - if (vlanId != null) { - String uri = "vlan://" + vlanId; - List networks = _networksDao.listBy(zoneId, uri); - if ((networks != null && !networks.isEmpty())) { - throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); - } - } - + // VlanId can be specified only when network offering supports it if (vlanId != null && !networkOffering.getSpecifyVlan()) { throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it"); @@ -1962,6 +1945,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } + // Don't allow to create network with vlan that already exists in the system + if (vlanId != null) { + String uri = "vlan://" + vlanId; + List networks = _networksDao.listBy(zoneId, uri); + if ((networks != null && !networks.isEmpty())) { + throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); + } + } + + // If networkDomain is not specified, take it from the global configuration if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) { Map dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(networkOfferingId), Service.Dns); @@ -1995,11 +1988,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - // Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x limitation, remove after we introduce support for multiple ip ranges + // In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x limitation, remove after we introduce support for multiple ip ranges // with different Cidrs for the same Shared network - boolean cidrRequired = networkOffering.getTrafficType() == TrafficType.Guest && (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))); + boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && networkOffering.getTrafficType() == TrafficType.Guest && (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))); if (cidr == null && cidrRequired) { throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled"); + } + + //No cidr can be specified in Basic zone + if (zone.getNetworkType() == NetworkType.Basic && cidr != null) { + throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask can't be specified for zone of type " + NetworkType.Basic); } // Check if cidr is RFC1918 compliant if the network is Guest Isolated @@ -3285,6 +3283,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag long oldNetworkOfferingId = network.getNetworkOfferingId(); if (networkOfferingId != null) { + NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); if (networkOffering == null || networkOffering.isSystemOnly()) { throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId); diff --git a/server/src/com/cloud/network/dao/NetworkDao.java b/server/src/com/cloud/network/dao/NetworkDao.java index d255e8cba6b..642f03b93cc 100644 --- a/server/src/com/cloud/network/dao/NetworkDao.java +++ b/server/src/com/cloud/network/dao/NetworkDao.java @@ -90,4 +90,5 @@ public interface NetworkDao extends GenericDao { boolean update(Long networkId, NetworkVO network, Map serviceProviderMap); + List listByZoneAndTrafficType(long zoneId, TrafficType trafficType); } diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java index cc92e12cf5e..7f13e132490 100644 --- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -387,4 +387,13 @@ public class NetworkDaoImpl extends GenericDaoBase implements N return listBy(sc, null); } + + @Override + public List listByZoneAndTrafficType(long zoneId, TrafficType trafficType) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("datacenter", zoneId); + sc.setParameters("trafficType", trafficType); + + return listBy(sc, null); + } } diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 9ea8f2db737..0835b951fe1 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -589,22 +589,13 @@ public class ElasticLoadBalancerManagerImpl implements @DB public PublicIp allocIp(CreateLoadBalancerRuleCmd lb, Account account) throws InsufficientAddressCapacityException { - //TODO: this only works in the guest network. Handle the public network case also. - NetworkOfferingVO frontEndOffering = null; - if (_frontendTrafficType == TrafficType.Guest) { - frontEndOffering = _networkMgr.getExclusiveGuestNetworkOffering(); - } - - if (frontEndOffering == null) { - s_logger.warn("ELB: Could not find offering for direct networks of type " + _frontendTrafficType); - return null; - } - - List networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, frontEndOffering.getId(), lb.getZoneId()); - if (networks == null || networks.size() == 0) { - s_logger.warn("ELB: Could not find network of offering type " + frontEndOffering + " in zone " + lb.getZoneId()); - return null; - } + //TODO: this only works in the guest network in Basic zone. Handle the public network case also. + List networks = _networkDao.listByZoneAndTrafficType(lb.getZoneId(), TrafficType.Guest); + if (networks.isEmpty()) { + s_logger.warn("Unable to find network with traffic type " + TrafficType.Guest + " in zone id=" + lb.getZoneId()); + return null; + } + Network frontEndNetwork = networks.get(0); Transaction txn = Transaction.currentTxn(); txn.start(); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 6ae6acfba5b..8113eaba6eb 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -71,7 +71,9 @@ import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.TrafficType; +import com.cloud.network.dao.NetworkDao; import com.cloud.offerings.NetworkOfferingVO; +import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; @@ -208,6 +210,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V protected ResourceManager _resourceMgr; @Inject protected SecondaryStorageVmManager _ssvmMgr; + @Inject + NetworkDao _networkDao; + @Inject + NetworkOfferingDao _networkOfferingDao; + private long _capacityScanInterval = DEFAULT_CAPACITY_SCAN_INTERVAL; @@ -513,12 +520,20 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V DataCenterDeployment plan = new DataCenterDeployment(dataCenterId); DataCenter dc = _dcDao.findById(plan.getDataCenterId()); - - NetworkOfferingVO defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0); - + + TrafficType defaultTrafficType = TrafficType.Public; if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { - defaultOffering = _networkMgr.getExclusiveGuestNetworkOffering(); + defaultTrafficType = TrafficType.Guest; } + + List defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); + + //api should never allow this situation to happen + if (defaultNetworks.size() != 1) { + throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1"); + } + + NetworkVO defaultNetwork = defaultNetworks.get(0); List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork); List> networks = new ArrayList>(offerings.size() + 1); @@ -526,7 +541,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); try { - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false).get(0), defaultNic)); + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), null, plan, null, null, false, false, null, null).get(0), defaultNic)); for (NetworkOfferingVO offering : offerings) { networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null)); } diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index 3a0c36596a1..2dae895b4fd 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -655,12 +655,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return false; } - @Override - public NetworkOfferingVO getExclusiveGuestNetworkOffering() { - // TODO Auto-generated method stub - return null; - } - @Override public List getPasswordResetElements() { // TODO Auto-generated method stub