diff --git a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java index 414fbbc194d..94dc659242f 100644 --- a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java @@ -32,7 +32,6 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.NetworkOfferingResponse; import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; @@ -95,7 +94,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { @Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network") private Map serviceProviderList; - @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list network offerings by state") + @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the network offering") private String state; ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index 22fe6561750..c93800a27b3 100644 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -34,6 +34,7 @@ import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; +import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; public interface NetworkService { @@ -126,5 +127,4 @@ public interface NetworkService { List listTrafficTypes(Long physicalNetworkId); PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); - } diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 5dcfb480f1a..f1eece47450 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1382,6 +1382,11 @@ 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); @@ -3254,9 +3259,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura txn.start(); // update network offering success = success && _networkOfferingDao.update(id, offering); - _ntwkOffServiceMapDao.deleteByOfferingId(id); - // update services/providers - delete old ones, insert new ones - if (serviceProviderMap != null) { + + if (!serviceProviderMap.isEmpty()) { + _ntwkOffServiceMapDao.deleteByOfferingId(id); + // update services/providers - delete old ones, insert new ones for (Network.Service service : serviceProviderMap.keySet()) { for (Network.Provider provider : serviceProviderMap.get(service)) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, provider); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 50e81e0fde2..c1c47aac795 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -549,7 +549,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx List defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork); if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { - defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemGuestNetwork); + defaultOffering.add(_networkMgr.getExclusiveGuestNetworkOffering()); } List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork); diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index dda6bf5a62c..ebc41011841 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -1,4 +1,5 @@ /** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. * * This software is licensed under the GNU General Public License v3 or later. @@ -39,6 +40,7 @@ import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.guru.NetworkGuru; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.StaticNat; +import com.cloud.offering.NetworkOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -233,6 +235,7 @@ public interface NetworkManager extends NetworkService { List getElementServices(Provider provider); - boolean canElementEnableIndividualServices(Provider provider); + boolean canElementEnableIndividualServices(Provider provider); + NetworkOfferingVO getExclusiveGuestNetworkOffering(); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index a4a514b22eb..f9b283a81a7 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -890,22 +890,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOfferingVO defaultGuestOffering = _networkOfferingDao.findByUniqueName(NetworkOffering.SystemGuestNetwork); if (defaultGuestOffering == null) { - defaultGuestOffering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, true); - defaultGuestOffering.setState(NetworkOffering.State.Enabled); + defaultGuestOffering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false); _networkOfferingDao.update(defaultGuestOffering.getId(), defaultGuestOffering); } - _systemNetworks.put(NetworkOfferingVO.SystemGuestNetwork, defaultGuestOffering); NetworkOfferingVO offering = null; if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultVirtualizedNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, null, null, false, Availability.Required, null, defaultVirtualNetworkOfferingProviders, true, Network.GuestType.Isolated, false); - offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultDirectNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, null, null, true, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false); - offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1130,6 +1126,22 @@ 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 diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 66dcd09e70b..3b145cc1b71 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -572,12 +572,16 @@ 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. - List offerings = _networkOfferingDao.listByTrafficTypeAndType(true, _frontendTrafficType, Network.GuestType.Shared); - if (offerings == null || offerings.size() == 0) { - s_logger.warn("ELB: Could not find system offering for direct networks of type " + _frontendTrafficType); + 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; } - NetworkOffering frontEndOffering = offerings.get(0); + 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()); diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java b/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java index 9affaf61339..51f6bfe8a06 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java @@ -53,14 +53,14 @@ public interface NetworkOfferingDao extends GenericDao */ NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering); - List listNonSystemNetworkOfferings(); - List listSystemNetworkOfferings(); List listByAvailability(Availability availability, boolean isSystem); - List listByTrafficTypeAndType(boolean isSystem, TrafficType trafficType, Network.GuestType type); - List getOfferingIdsToUpgradeFrom(NetworkOffering originalOffering); + List listByTrafficTypeGuestTypeAndState(NetworkOffering.State state, TrafficType trafficType, Network.GuestType type); + + List listGuestNetworkOfferings(Network.GuestType type, boolean isDefault); + } diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java b/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java index 6aba0643781..3586f92264c 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java @@ -44,7 +44,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase NameSearch; final SearchBuilder SystemOfferingSearch; final SearchBuilder AvailabilitySearch; - final SearchBuilder TrafficTypeGuestTypeSearch; + final SearchBuilder AllFieldsSearch; private final GenericSearchBuilder UpgradeSearch; protected NetworkOfferingDaoImpl() { @@ -64,11 +64,12 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase listNonSystemNetworkOfferings() { - SearchCriteria sc = SystemOfferingSearch.create(); - sc.setParameters("system", false); - return this.listIncludingRemovedBy(sc, null); - } - @Override public List listSystemNetworkOfferings() { SearchCriteria sc = SystemOfferingSearch.create(); @@ -128,15 +122,6 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase listByTrafficTypeAndType(boolean isSystem, TrafficType trafficType, Network.GuestType type) { - SearchCriteria sc = TrafficTypeGuestTypeSearch.create(); - sc.setParameters("trafficType", trafficType); - sc.setParameters("guestType", type); - sc.setParameters("isSystem", isSystem); - return listBy(sc, null); - } - @Override public boolean remove(Long networkOfferingId){ NetworkOfferingVO offering = findById(networkOfferingId); @@ -164,4 +149,22 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase listByTrafficTypeGuestTypeAndState(NetworkOffering.State state, TrafficType trafficType, Network.GuestType type) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("trafficType", trafficType); + sc.setParameters("guestType", type); + sc.setParameters("state", state); + return listBy(sc, null); + } + + @Override + public List listGuestNetworkOfferings(Network.GuestType type, boolean isDefault) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("trafficType", TrafficType.Guest); + sc.setParameters("guestType", type); + sc.setParameters("isDefault", isDefault); + return listBy(sc, null); + } } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index f84c1c196de..f6f3636e0bf 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -833,75 +833,73 @@ public class ConfigurationServerImpl implements ConfigurationServer { storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering); //populate providers - Map defaultDirectNetworkOfferingProviders = new HashMap(); - defaultDirectNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer); - defaultDirectNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer); - defaultDirectNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer); + Map defaultSharedNetworkOfferingProviders = new HashMap(); + defaultSharedNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer); + defaultSharedNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer); + defaultSharedNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer); - Map defaultDirectGuestNetworkOfferingProviders = new HashMap(); - defaultDirectGuestNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer); - defaultDirectGuestNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer); - defaultDirectGuestNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer); - defaultDirectGuestNetworkOfferingProviders.put(Service.SecurityGroup, Provider.SecurityGroupProvider); + Map defaultSharedSGNetworkOfferingProviders = new HashMap(); + defaultSharedSGNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer); + defaultSharedSGNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer); + defaultSharedSGNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer); + defaultSharedSGNetworkOfferingProviders.put(Service.SecurityGroup, Provider.SecurityGroupProvider); - Map defaultVirtualNetworkOfferingProviders = new HashMap(); - defaultVirtualNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Firewall, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Gateway, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Lb, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.SourceNat, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.StaticNat, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.PortForwarding, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Vpn, Provider.VirtualRouter); + Map defaultIsolatedNetworkOfferingProviders = new HashMap(); + defaultIsolatedNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.Firewall, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.Gateway, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.Lb, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.SourceNat, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.StaticNat, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.PortForwarding, Provider.VirtualRouter); + defaultIsolatedNetworkOfferingProviders.put(Service.Vpn, Provider.VirtualRouter); + - NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO( + //The only one diff between 1 and 3 network offerings is that the first one has SG enabled. In Basic zone only first network offering has to be enabled, in Advance zone - the third one + NetworkOfferingVO deafultSharedSGNetworkOffering = new NetworkOfferingVO( NetworkOffering.SystemGuestNetwork, "System-Guest-Network", TrafficType.Guest, - true, false, null, null, null, true, + false, false, null, null, null, true, Availability.Optional, null, Network.GuestType.Shared); - guestNetworkOffering.setState(NetworkOffering.State.Enabled); - - guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering); + deafultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(deafultSharedSGNetworkOffering); - for (Service service : defaultDirectGuestNetworkOfferingProviders.keySet()) { - NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(guestNetworkOffering.getId(), service, defaultDirectGuestNetworkOfferingProviders.get(service)); + for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) { + NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(deafultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service)); _offeringServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } - NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO( + NetworkOfferingVO defaultIsolatedNetworkOffering = new NetworkOfferingVO( NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, false, false, null, null, null, true, Availability.Required, null, Network.GuestType.Isolated); - defaultGuestNetworkOffering.setState(NetworkOffering.State.Enabled); - defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); + defaultIsolatedNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedNetworkOffering); - for (Service service : defaultVirtualNetworkOfferingProviders.keySet()) { - NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultGuestNetworkOffering.getId(), service, defaultVirtualNetworkOfferingProviders.get(service)); + for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) { + NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service)); _offeringServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } - NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO( + NetworkOfferingVO defaultSharedNetworkOffering = new NetworkOfferingVO( NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, - false, true, null, null, null, true, + false, false, null, null, null, true, Availability.Optional, null, Network.GuestType.Shared); - defaultGuestDirectNetworkOffering.setState(NetworkOffering.State.Enabled); - defaultGuestDirectNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); + defaultSharedNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedNetworkOffering); - for (Service service : defaultDirectNetworkOfferingProviders.keySet()) { - NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultGuestDirectNetworkOffering.getId(), service, defaultDirectNetworkOfferingProviders.get(service)); + for (Service service : defaultSharedNetworkOfferingProviders.keySet()) { + NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service)); _offeringServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index d18aecf8c28..94e8cb0ee44 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -495,7 +495,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V List defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork); if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { - defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemGuestNetwork); + defaultOffering.add(_networkMgr.getExclusiveGuestNetworkOffering()); } List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index a55b4cfc882..f776bed794a 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2176,7 +2176,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager // 2) If Availability=Optional, search for default networks for the account. If it's more than 1, throw an error. // If it's 0, and there are no default direct networks, create default Guest Virtual network - List defaultVirtualOffering = _networkOfferingDao.listByTrafficTypeAndType(false, TrafficType.Guest, Network.GuestType.Isolated); + List defaultVirtualOffering = _networkOfferingDao.listByTrafficTypeGuestTypeAndState(NetworkOffering.State.Enabled, TrafficType.Guest, Network.GuestType.Isolated); PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId()); if (defaultVirtualOffering.get(0).getAvailability() == Availability.Required) { // get Virtual netowrks