diff --git a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java index c61f9f36e28..6d4519980a9 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java @@ -73,6 +73,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, description="the service offering ID used by virtual router provider") private Long serviceOfferingId; + @Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated") + private String guestIptype; + @Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports dhcp service") private Boolean dhcpService; @@ -108,9 +111,6 @@ public class CreateNetworkOfferingCmd 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.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated") - private String guestIptype; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// diff --git a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java index 93ebaf3c230..8188bc096ac 100644 --- a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java @@ -55,7 +55,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the network offering") private String displayText; - @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering") + @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Supported values are Required, Optional and Unavailable") private String availability; @Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports dhcp service") diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index b5fc70b574d..cb16cb9bfb8 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -575,8 +575,8 @@ public class ApiDBUtils { return _networkDao.findById(id); } - public static Map> getNetworkCapabilities(long networkOfferingId, long zoneId) { - return _networkMgr.getNetworkCapabilities(networkOfferingId); + public static Map> getNetworkCapabilities(long networkId, long zoneId) { + return _networkMgr.getNetworkCapabilities(networkId); } public static long getPublicNetworkIdByZone(long zoneId) { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index a689bbe8643..c0a9e270497 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2157,7 +2157,9 @@ public class ApiResponseHelper implements ResponseGenerator { response.setTrafficType(network.getTrafficType().name()); } - response.setGuestIpType(network.getGuestType().toString()); + if (network.getGuestType() != null) { + response.setGuestIpType(network.getGuestType().toString()); + } // get start ip and end ip of corresponding vlan List vlan = ApiDBUtils.listVlanByNetworkId(network.getId()); @@ -2195,7 +2197,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setDns1(profile.getDns1()); response.setDns2(profile.getDns2()); // populate capability - Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(networkOffering.getId(), network.getDataCenterId()); + Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(network.getId(), network.getDataCenterId()); List serviceResponses = new ArrayList(); if (serviceCapabilitiesMap != null) { for (Service service : serviceCapabilitiesMap.keySet()) { diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index 5aea73c3fdb..6a5b4106d85 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -83,6 +83,7 @@ import com.cloud.network.dao.NetworkDomainDaoImpl; import com.cloud.network.dao.NetworkExternalFirewallDaoImpl; import com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl; import com.cloud.network.dao.NetworkRuleConfigDaoImpl; +import com.cloud.network.dao.NetworkServiceMapDaoImpl; import com.cloud.network.dao.PhysicalNetworkDaoImpl; import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl; import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl; @@ -304,6 +305,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com addDao("NetworkExternalLoadBalancerDao", NetworkExternalLoadBalancerDaoImpl.class); addDao("NetworkExternalFirewallDao", NetworkExternalFirewallDaoImpl.class); addDao("PhysicalNetworkTrafficTypeDao", PhysicalNetworkTrafficTypeDaoImpl.class); + addDao("NetworkServiceMapDao", NetworkServiceMapDaoImpl.class); } @Override diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManager.java b/server/src/com/cloud/network/ExternalNetworkDeviceManager.java index 0e457c38265..dc462a30ee9 100644 --- a/server/src/com/cloud/network/ExternalNetworkDeviceManager.java +++ b/server/src/com/cloud/network/ExternalNetworkDeviceManager.java @@ -35,7 +35,6 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.Host; import com.cloud.network.rules.FirewallRule; -import com.cloud.offering.NetworkOffering; import com.cloud.server.api.response.ExternalFirewallResponse; import com.cloud.server.api.response.ExternalLoadBalancerResponse; import com.cloud.server.api.response.NetworkDeviceResponse; @@ -110,7 +109,7 @@ public interface ExternalNetworkDeviceManager extends Manager { public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall); - public boolean manageGuestNetworkWithExternalFirewall(boolean add, Network network, NetworkOffering offering) throws ResourceUnavailableException, InsufficientCapacityException; + public boolean manageGuestNetworkWithExternalFirewall(boolean add, Network network) throws ResourceUnavailableException, InsufficientCapacityException; public boolean applyFirewallRules(Network network, List rules) throws ResourceUnavailableException; diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java index 67498643ce6..b75d1f56525 100644 --- a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java +++ b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java @@ -72,7 +72,6 @@ import com.cloud.dc.VlanVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.VlanDao; import com.cloud.exception.AgentUnavailableException; -import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientNetworkCapacityException; import com.cloud.exception.InvalidParameterValueException; @@ -93,11 +92,10 @@ import com.cloud.network.dao.InlineLoadBalancerNicMapDao; import com.cloud.network.dao.LoadBalancerDao; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkExternalFirewallDao; +import com.cloud.network.dao.NetworkExternalLoadBalancerDao; import com.cloud.network.dao.PhysicalNetworkDao; import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; -import com.cloud.network.dao.NetworkExternalLoadBalancerDao; -import com.cloud.network.NetworkExternalLoadBalancerVO; import com.cloud.network.dao.VpnUserDao; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.lb.LoadBalancingRule.LbDestination; @@ -112,8 +110,6 @@ import com.cloud.network.rules.PortForwardingRuleVO; import com.cloud.network.rules.StaticNatRule; import com.cloud.network.rules.StaticNatRuleImpl; import com.cloud.network.rules.dao.PortForwardingRulesDao; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; import com.cloud.resource.ServerResource; @@ -171,7 +167,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa @Inject ConfigurationDao _configDao; @Inject HostDetailsDao _detailsDao; @Inject NetworkOfferingDao _networkOfferingDao; - @Inject NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; @Inject NicDao _nicDao; @Inject VpnUserDao _vpnUsersDao; @Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao; @@ -1123,7 +1118,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa } @Override - public boolean manageGuestNetworkWithExternalFirewall(boolean add, Network network, NetworkOffering offering) throws ResourceUnavailableException, InsufficientCapacityException { + public boolean manageGuestNetworkWithExternalFirewall(boolean add, Network network) throws ResourceUnavailableException, InsufficientCapacityException { if (network.getTrafficType() != TrafficType.Guest) { s_logger.trace("External firewall can only be used for add/remove guest networks."); return false; @@ -1158,7 +1153,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa Account account = _accountDao.findByIdIncludingRemoved(network.getAccountId()); boolean sharedSourceNat = false; - Map sourceNatCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat); + Map sourceNatCapabilities = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.SourceNat); if (sourceNatCapabilities != null) { String supportedSourceNatTypes = sourceNatCapabilities.get(Capability.SupportedSourceNatTypes).toLowerCase(); if (supportedSourceNatTypes.contains("zone")) { @@ -1566,7 +1561,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa String networkErrorMsg = accountErrorMsg + ", network ID = " + network.getId(); boolean sharedSourceNat = false; - Map sourceNatCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat); + Map sourceNatCapabilities = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.SourceNat); if (sourceNatCapabilities != null) { String supportedSourceNatTypes = sourceNatCapabilities.get(Capability.SupportedSourceNatTypes).toLowerCase(); if (supportedSourceNatTypes.contains("zone")) { @@ -1639,7 +1634,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa List networksForAccount = _networkDao.listBy(accountId, zoneId, Network.GuestType.Isolated); for (NetworkVO network : networksForAccount) { - if (!_networkMgr.networkIsConfiguredForExternalNetworking(zoneId, network.getNetworkOfferingId())) { + if (!_networkMgr.networkIsConfiguredForExternalNetworking(zoneId, network.getId())) { s_logger.debug("Network " + network.getId() + " is not configured for external networking, so skipping usage check."); continue; } diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index c98f8281f3a..f658319bcea 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -40,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; @@ -184,9 +185,9 @@ public interface NetworkManager extends NetworkService { @Deprecated boolean zoneIsConfiguredForExternalNetworking(long zoneId); - boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkOfferingId); + boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId); - Map getServiceCapabilities(Long networkOfferingId, Service service); + Map getNetworkServiceCapabilities(long networkId, Service service); boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException; @@ -216,7 +217,7 @@ public interface NetworkManager extends NetworkService { Long getPodIdForVlan(long vlanDbId); - boolean isProviderSupported(long networkOfferingId, Service service, Provider provider); + boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider); List listNetworkOfferingsForUpgrade(long networkId); @@ -228,7 +229,7 @@ public interface NetworkManager extends NetworkService { boolean isProviderAvailable(long physicalNetowrkId, String providerName); - boolean isServiceEnabled(long physicalNetworkId, long networkOfferingId, Service service); + boolean isServiceEnabledInNetwork(long physicalNetworkId, long networkId, Service service); List getNetworkTags(HypervisorType hType, Network network); @@ -240,4 +241,9 @@ public interface NetworkManager extends NetworkService { PhysicalNetworkServiceProvider addDefaultVirtualRouterToPhysicalNetwork(long physicalNetworkId); + boolean areServicesSupportedInNetwork(long networkId, Service... services); + + boolean isNetworkSystem(Network network); + + Map getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index a3a33e6f9a9..f48e8a50a87 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -116,6 +116,7 @@ import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.LoadBalancerDao; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkDomainDao; +import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.dao.PhysicalNetworkDao; import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; @@ -276,6 +277,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Inject PhysicalNetworkTrafficTypeDao _pNTrafficTypeDao; @Inject AgentManager _agentMgr; @Inject HostDao _hostDao; + @Inject NetworkServiceMapDao _ntwkSrvcDao; private final HashMap _systemNetworks = new HashMap(5); @@ -701,7 +703,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag txn.start(); boolean sharedSourceNat = false; - Map sourceNatCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat); + Map sourceNatCapabilities = getNetworkServiceCapabilities(network.getId(), Service.SourceNat); if (sourceNatCapabilities != null) { String supportedSourceNatTypes = sourceNatCapabilities.get(Capability.SupportedSourceNatTypes).toLowerCase(); if (supportedSourceNatTypes.contains("zone")) { @@ -1106,7 +1108,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isDefault, (domainId != null), predefined.getNetworkDomain(), offering.getGuestType(), isShared, plan.getDataCenterId(), plan.getPhysicalNetworkId()); - networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated)); + networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, getServicesAndProvidersForNetwork(offering))); if (domainId != null) { _networksDao.addDomainToNetwork(id, domainId); @@ -1387,8 +1389,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // associate a source NAT IP (if one isn't already associated with the network) boolean sharedSourceNat = false; - if (areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat)) { - Map sourceNatCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat); + if (areServicesSupportedInNetwork(network.getId(), Service.SourceNat)) { + Map sourceNatCapabilities = getNetworkServiceCapabilities(network.getId(), Service.SourceNat); if (sourceNatCapabilities != null) { String supportedSourceNatTypes = sourceNatCapabilities.get(Capability.SupportedSourceNatTypes).toLowerCase(); if (supportedSourceNatTypes.contains("zone")) { @@ -1397,7 +1399,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - if (network.getGuestType() == Network.GuestType.Isolated && areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat) && !sharedSourceNat) { + if (network.getGuestType() == Network.GuestType.Isolated && areServicesSupportedInNetwork(network.getId(), Service.SourceNat) && !sharedSourceNat) { List ips = _ipAddressDao.listByAssociatedNetwork(network.getId(), true); if (ips.isEmpty()) { @@ -1601,7 +1603,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Network associatedNetwork = getNetwork(ipVO.getAssociatedWithNetworkId()); - if (areServicesSupportedByNetworkOffering(associatedNetwork.getNetworkOfferingId(), Service.SourceNat)) { + if (areServicesSupportedInNetwork(associatedNetwork.getId(), Service.SourceNat)) { throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated."); } @@ -1736,7 +1738,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - //FIXME - need to check if all providers are supported by the physical network //FIXME - need to check that the traffic type is supported @@ -1904,7 +1905,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // If networkDomain is not specified, take it from the global configuration if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) { - Map dnsCapabilities = getServiceCapabilities(networkOfferingId, Service.Dns); + Map dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(networkOfferingId), Service.Dns); String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { if (networkDomain != null) { @@ -2127,10 +2128,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag //sort networks by sourceNatEnabled parameter if (sourceNatEnabled != null) { List supportedNetworks = new ArrayList(); - for (Network network : networksToReturn) { - NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); - boolean isSupported = areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat); + boolean isSupported = areServicesSupportedInNetwork(network.getId(), Service.SourceNat); if (isSupported == sourceNatEnabled.booleanValue()) { supportedNetworks.add(network); } @@ -2254,9 +2253,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } //don't allow to delete system network - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); - if (offering.isSystemOnly()) { - throw new InvalidParameterValueException("Network id=" + networkId + " is system and can't be removed"); + if (isNetworkSystem(network)) { + throw new InvalidParameterValueException("Network " + network + " is system and can't be removed"); } Account owner = _accountMgr.getAccount(network.getAccountId()); @@ -2713,22 +2711,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override - public Map> getNetworkCapabilities(long networkOfferingId) { + public Map> getNetworkCapabilities(long networkId) { Map> networkCapabilities = new HashMap>(); //list all services of this networkOffering - List servicesMap = _ntwkOfferingSrvcDao.getServices(networkOfferingId); - for(NetworkOfferingServiceMapVO instance : servicesMap ){ + List servicesMap = _ntwkSrvcDao.getServicesInNetwork(networkId); + for(NetworkServiceMapVO instance : servicesMap ){ Service service = Service.getService(instance.getService()); - //FIXME what if a service has multiple providers in the same networkOffering? - if(networkCapabilities.containsKey(service)){ - if(s_logger.isDebugEnabled()){ - s_logger.debug("Network Offering: "+ networkOfferingId +" has multiple Providers associated for this Service:"+service.getName()); - s_logger.debug("Returning the capabilities of the first Provider"); - } - continue; - } NetworkElement element = getElementImplementingProvider(instance.getProvider()); if(element != null){ Map> elementCapabilities = element.getCapabilities();; @@ -2742,32 +2732,51 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public Map getServiceCapabilities(Long networkOfferingId, Service service) { + public Map getNetworkServiceCapabilities(long networkId, Service service) { - if (!areServicesSupportedByNetworkOffering(networkOfferingId, service)) { - throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering id=" + networkOfferingId); + if (!areServicesSupportedInNetwork(networkId, service)) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the network id=" + networkId); } Map serviceCapabilities = new HashMap(); //get the Provider for this Service for this offering - List serviceProviderNames = _ntwkOfferingSrvcDao.getProvidersForService(networkOfferingId, service); + String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service); + + NetworkElement element = getElementImplementingProvider(provider); + if(element != null){ + Map> elementCapabilities = element.getCapabilities();; + + if (elementCapabilities == null || elementCapabilities.get(service) == null) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider); + } + serviceCapabilities = elementCapabilities.get(service); + } + + return serviceCapabilities; + } + + @Override + public Map getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service) { + + if (!areServicesSupportedByNetworkOffering(offering.getId(), service)) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering " + offering); + } + + Map serviceCapabilities = new HashMap(); + + //get the Provider for this Service for this offering + String provider = _ntwkOfferingSrvcDao.getProviderForServiceForNetworkOffering(offering.getId(), service); //FIXME we return the capabilities of the first provider of the service - what if we have multiple providers for same Service? - if(serviceProviderNames != null && !serviceProviderNames.isEmpty()){ - NetworkElement element = getElementImplementingProvider(serviceProviderNames.get(0)); - if(element != null){ - Map> elementCapabilities = element.getCapabilities();; - - if (elementCapabilities == null || elementCapabilities.get(service) == null) { - throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + serviceProviderNames.get(0)); - } - serviceCapabilities = elementCapabilities.get(service); - } - }else{ - if(s_logger.isDebugEnabled()){ - s_logger.debug("Network Offering: "+ networkOfferingId +" does not have any Providers associated for this Service:"+service.getName()); + NetworkElement element = getElementImplementingProvider(provider); + if(element != null){ + Map> elementCapabilities = element.getCapabilities();; + + if (elementCapabilities == null || elementCapabilities.get(service) == null) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider); } + serviceCapabilities = elementCapabilities.get(service); } return serviceCapabilities; @@ -2833,8 +2842,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (nics != null) { for (Nic nic : nics) { NetworkVO network = _networksDao.findByIdIncludingRemoved(nic.getNetworkId()); - NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); - if (no.isSystemOnly() == isSystem) { + + if (isNetworkSystem(network) == isSystem) { networks.add(network); } } @@ -3023,18 +3032,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkOfferingId) { + public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId) { DataCenterVO zone = _dcDao.findById(zoneId); - boolean usesJuniperForGatewayService = _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, Service.Gateway, Network.Provider.JuniperSRX); - boolean usesJuniperForFirewallService = _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, Service.Firewall, Network.Provider.JuniperSRX); - boolean usesNetscalarForLBService = _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, Service.Lb, Network.Provider.Netscaler); - boolean usesF5ForLBService = _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, Service.Lb, Network.Provider.F5BigIp); + boolean usesJuniperForGatewayService = _ntwkSrvcDao.isProviderSupportedInNetwork(networkId, Service.Gateway, Network.Provider.JuniperSRX); + boolean usesJuniperForFirewallService = _ntwkSrvcDao.isProviderSupportedInNetwork(networkId, Service.Firewall, Network.Provider.JuniperSRX); + boolean usesNetscalarForLBService = _ntwkSrvcDao.isProviderSupportedInNetwork(networkId, Service.Lb, Network.Provider.Netscaler); + boolean usesF5ForLBService = _ntwkSrvcDao.isProviderSupportedInNetwork(networkId, Service.Lb, Network.Provider.F5BigIp); if (zone.getNetworkType() == NetworkType.Advanced) { if (usesJuniperForGatewayService && usesJuniperForFirewallService) { return true; - } else if (_ntwkOfferingSrvcDao.areServicesSupported(networkOfferingId, Service.Gateway) && (usesF5ForLBService || usesNetscalarForLBService)) { + } else if (_ntwkSrvcDao.areServicesSupportedInNetwork(networkId, Service.Gateway) && (usesF5ForLBService || usesNetscalarForLBService)) { return true; } else { return false; @@ -3042,12 +3051,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } else { return usesJuniperForFirewallService; } - } @Override public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) { - return (_ntwkOfferingSrvcDao.areServicesSupported(networkOfferingId, services)); + return (_ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(networkOfferingId, services)); + } + + @Override + public boolean areServicesSupportedInNetwork(long networkId, Service... services) { + return (_ntwkSrvcDao.areServicesSupportedInNetwork(networkId, services)); } private boolean cleanupIpResources(long ipId, long userId, Account caller) { @@ -3126,8 +3139,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag List zoneNetworks = _networksDao.listByZone(zoneId); for (NetworkVO network : zoneNetworks) { - NetworkOfferingVO no = _networkOfferingDao.findById(network.getNetworkOfferingId()); - if (!no.isSystemOnly()) { + if (!isNetworkSystem(network)) { if (network.getGuestType() == Network.GuestType.Shared || !_networksDao.listBy(accountId, network.getId()).isEmpty()) { if ((type == null || type == network.getGuestType()) && (isDefault == null || isDefault.booleanValue() == network.isDefault)) { accountNetworks.add(network); @@ -3240,27 +3252,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag throw new InvalidParameterValueException("Can't update system networks"); } - //don't allow to modify network domain if the service is not supported - if (domainSuffix != null) { - // validate network domain - if (!NetUtils.verifyDomainName(domainSuffix)) { - throw new InvalidParameterValueException( - "Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', " - + "and the hyphen ('-'); can't start or end with \"-\""); - } - - - Map dnsCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.Dns); - String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); - if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { - throw new InvalidParameterValueException("Domain name change is not supported for network id=" + network.getNetworkOfferingId() + " in zone id=" + network.getDataCenterId()); - } - - network.setNetworkDomain(domainSuffix); - //have to restart the network - restartNetwork = true; - } - if (name != null) { network.setName(name); } @@ -3297,7 +3288,32 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } restartNetwork = true; } - } + } + + //don't allow to modify network domain if the service is not supported + if (domainSuffix != null) { + // validate network domain + if (!NetUtils.verifyDomainName(domainSuffix)) { + throw new InvalidParameterValueException( + "Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', " + + "and the hyphen ('-'); can't start or end with \"-\""); + } + + long offeringId = oldNetworkOfferingId; + if (networkOfferingId != null) { + offeringId = networkOfferingId; + } + + Map dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(offeringId), Service.Dns); + String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); + if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { + throw new InvalidParameterValueException("Domain name change is not supported by the network offering id=" + networkOfferingId); + } + + network.setNetworkDomain(domainSuffix); + //have to restart the network + restartNetwork = true; + } _networksDao.update(networkId, network); boolean success = true; @@ -3490,7 +3506,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public Map> listNetworkOfferingServices(long networkOfferingId) { Map> serviceProviderMap = new HashMap>(); - List map = _ntwkOfferingSrvcDao.getServices(networkOfferingId); + List map = _ntwkOfferingSrvcDao.listByNetworkOfferingId(networkOfferingId); for (NetworkOfferingServiceMapVO instance : map) { String service = instance.getService(); @@ -3508,8 +3524,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public boolean isProviderSupported(long networkOfferingId, Service service, Provider provider){ - return _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, service, provider); + public boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider){ + return _ntwkSrvcDao.isProviderSupportedInNetwork(networkId, service, provider); } protected boolean canUpgrade(long oldNetworkOfferingId, long newNetworkOfferingId) { @@ -4457,7 +4473,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), null); } - return isServiceEnabled(physicalNetworkId, network.getNetworkOfferingId(), Service.SecurityGroup); + return isServiceEnabledInNetwork(physicalNetworkId, network.getId(), Service.SecurityGroup); } @Override @@ -4734,20 +4750,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public boolean isServiceEnabled(long physicalNetworkId, long networkOfferingId, Service service) { - //check if the service is supported by the network offering - if (!areServicesSupportedByNetworkOffering(networkOfferingId, service)) { - s_logger.debug("Service " + service.getName() + " is not supported by the network offering id=" + networkOfferingId); + public boolean isServiceEnabledInNetwork(long physicalNetworkId, long networkId, Service service) { + //check if the service is supported in the network + if (!areServicesSupportedInNetwork(networkId, service)) { + s_logger.debug("Service " + service.getName() + " is not supported in the network id=" + networkId); return false; } - //get providers for the service and check if all of them are supported - List providers = _ntwkOfferingSrvcDao.getProvidersForService(networkOfferingId, service); - for (String provider : providers) { - if (!isProviderAvailable(physicalNetworkId, provider)) { - s_logger.debug("Provider " + provider + " is not enabled in physical network id=" + physicalNetworkId); - return false; - } + //get provider for the service and check if all of them are supported + String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service); + + if (!isProviderAvailable(physicalNetworkId, provider)) { + s_logger.debug("Provider " + provider + " is not enabled in physical network id=" + physicalNetworkId); + return false; } return true; @@ -4814,4 +4829,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } + @Override + public boolean isNetworkSystem(Network network) { + NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); + if (no.isSystemOnly()) { + return true; + } else { + return false; + } + } + + public Map getServicesAndProvidersForNetwork(NetworkOffering offering) { + Map svcProviders = new HashMap(); + List servicesMap = _ntwkOfferingSrvcDao.listByNetworkOfferingId(offering.getId()); + + for (NetworkOfferingServiceMapVO serviceMap : servicesMap) { + if (svcProviders.containsKey(serviceMap.getService())) { + //FIXME - right now we pick up the first provider from the list, need to add more logic based on provider load, etc + continue; + } + svcProviders.put(serviceMap.getService(), serviceMap.getProvider()); + } + + return svcProviders; + } + } diff --git a/server/src/com/cloud/network/NetworkServiceMapVO.java b/server/src/com/cloud/network/NetworkServiceMapVO.java new file mode 100644 index 00000000000..6cbf9fabb7b --- /dev/null +++ b/server/src/com/cloud/network/NetworkServiceMapVO.java @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.network; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.utils.db.GenericDao; + +@Entity +@Table(name="ntwk_service_map") +public class NetworkServiceMapVO { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + long id; + + @Column(name="network_id") + long networkId; + + @Column(name="service") + String service; + + @Column(name="provider") + String provider; + + @Column(name=GenericDao.CREATED_COLUMN) + Date created; + + public long getId() { + return id; + } + + public long getNetworkId() { + return networkId; + } + + public String getService() { + return service; + } + + public String getProvider() { + return provider; + } + + public Date getCreated() { + return created; + } + + public NetworkServiceMapVO() { + } + + public NetworkServiceMapVO(long networkId, Service service, Provider provider) { + this.networkId = networkId; + this.service = service.getName(); + this.provider = provider.getName(); + } + + public String toString() { + StringBuilder buf = new StringBuilder("[Network Service["); + return buf.append(networkId).append("-").append(service).append("-").append(provider).append("]").toString(); + } +} + + + + + diff --git a/server/src/com/cloud/network/dao/NetworkDao.java b/server/src/com/cloud/network/dao/NetworkDao.java index cf2bc182834..fd9a8a10b47 100644 --- a/server/src/com/cloud/network/dao/NetworkDao.java +++ b/server/src/com/cloud/network/dao/NetworkDao.java @@ -18,6 +18,7 @@ package com.cloud.network.dao; import java.util.List; +import java.util.Map; import com.cloud.network.Network; import com.cloud.network.NetworkAccountVO; @@ -36,7 +37,7 @@ public interface NetworkDao extends GenericDao { List listBy(long accountId, long dataCenterId, Network.GuestType type); - NetworkVO persist(NetworkVO network, boolean gc); + NetworkVO persist(NetworkVO network, boolean gc, Map serviceProviderMap); SearchBuilder createSearchBuilderForAccount(); diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java index 28d5dc26388..20a72a2b24d 100644 --- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -18,22 +18,23 @@ package com.cloud.network.dao; import java.util.List; +import java.util.Map; import java.util.Random; import javax.ejb.Local; import javax.persistence.TableGenerator; import com.cloud.network.Network; +import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.NetworkAccountDaoImpl; import com.cloud.network.NetworkAccountVO; import com.cloud.network.NetworkDomainVO; +import com.cloud.network.NetworkServiceMapVO; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; -import com.cloud.offerings.NetworkOfferingServiceMapVO; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; @@ -63,7 +64,7 @@ public class NetworkDaoImpl extends GenericDaoBase implements N NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class); NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class); NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class); - NetworkOfferingServiceMapDaoImpl _ntwkOffSvcMap = ComponentLocator.inject(NetworkOfferingServiceMapDaoImpl.class); + NetworkServiceMapDaoImpl _ntwkSvcMap = ComponentLocator.inject(NetworkServiceMapDaoImpl.class); final TableGenerator _tgMacAddress; Random _rand = new Random(System.currentTimeMillis()); @@ -116,9 +117,9 @@ public class NetworkDaoImpl extends GenericDaoBase implements N ZoneSecurityGroupSearch = createSearchBuilder(); ZoneSecurityGroupSearch.and("dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ); - SearchBuilder join1 = _ntwkOffSvcMap.createSearchBuilder(); + SearchBuilder join1 = _ntwkSvcMap.createSearchBuilder(); join1.and("service", join1.entity().getService(), Op.EQ); - ZoneSecurityGroupSearch.join("services", join1, ZoneSecurityGroupSearch.entity().getNetworkOfferingId(), join1.entity().getNetworkOfferingId(), JoinBuilder.JoinType.INNER); + ZoneSecurityGroupSearch.join("services", join1, ZoneSecurityGroupSearch.entity().getId(), join1.entity().getNetworkId(), JoinBuilder.JoinType.INNER); ZoneSecurityGroupSearch.done(); CountByOfferingId = createSearchBuilder(Long.class); @@ -133,9 +134,9 @@ public class NetworkDaoImpl extends GenericDaoBase implements N PhysicalNetworkSearch.done(); securityGroupSearch = createSearchBuilder(); - SearchBuilder join3 = _ntwkOffSvcMap.createSearchBuilder(); + SearchBuilder join3 = _ntwkSvcMap.createSearchBuilder(); join3.and("service", join3.entity().getService(), Op.EQ); - securityGroupSearch.join("services", join3, securityGroupSearch.entity().getNetworkOfferingId(), join3.entity().getNetworkOfferingId(), JoinBuilder.JoinType.INNER); + securityGroupSearch.join("services", join3, securityGroupSearch.entity().getId(), join3.entity().getNetworkId(), JoinBuilder.JoinType.INNER); securityGroupSearch.done(); _tgMacAddress = _tgs.get("macAddress"); @@ -185,13 +186,23 @@ public class NetworkDaoImpl extends GenericDaoBase implements N } @Override @DB - public NetworkVO persist(NetworkVO network, boolean gc) { + public NetworkVO persist(NetworkVO network, boolean gc, Map serviceProviderMap) { Transaction txn = Transaction.currentTxn(); txn.start(); + + //1) create network NetworkVO newNetwork = super.persist(network); + //2) add account to the network addAccountToNetwork(network.getId(), network.getAccountId(), true); + //3) add network to gc monitor table NetworkOpVO op = new NetworkOpVO(network.getId(), gc); _opDao.persist(op); + //4) add services/providers for the network + for (String service : serviceProviderMap.keySet()) { + NetworkServiceMapVO serviceMap = new NetworkServiceMapVO(newNetwork.getId(), Service.getService(service), Provider.getProvider(serviceProviderMap.get(service))); + _ntwkSvcMap.persist(serviceMap); + } + txn.commit(); return newNetwork; } @@ -326,13 +337,13 @@ public class NetworkDaoImpl extends GenericDaoBase implements N @Override public List listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName) { - SearchBuilder svcProviderMapSearch = _ntwkOffSvcMap.createSearchBuilder(); - NetworkOfferingServiceMapVO svcProviderEntry = svcProviderMapSearch.entity(); + SearchBuilder svcProviderMapSearch = _ntwkSvcMap.createSearchBuilder(); + NetworkServiceMapVO svcProviderEntry = svcProviderMapSearch.entity(); svcProviderMapSearch.and("Provider", svcProviderMapSearch.entity().getProvider(), SearchCriteria.Op.EQ); SearchBuilder networksSearch = createSearchBuilder(); networksSearch.and("physicalNetworkId", networksSearch.entity().getPhysicalNetworkId(), Op.EQ); - networksSearch.join("svcProviderMapSearch", svcProviderMapSearch, networksSearch.entity().getNetworkOfferingId(), svcProviderEntry.getNetworkOfferingId(), JoinBuilder.JoinType.INNER); + networksSearch.join("svcProviderMapSearch", svcProviderMapSearch, networksSearch.entity().getId(), svcProviderEntry.getNetworkId(), JoinBuilder.JoinType.INNER); SearchCriteria sc = networksSearch.create(); sc.setJoinParameters("svcProviderMapSearch", "Provider", providerName); diff --git a/server/src/com/cloud/network/dao/NetworkServiceMapDao.java b/server/src/com/cloud/network/dao/NetworkServiceMapDao.java new file mode 100644 index 00000000000..a9da728958d --- /dev/null +++ b/server/src/com/cloud/network/dao/NetworkServiceMapDao.java @@ -0,0 +1,20 @@ +package com.cloud.network.dao; + +import java.util.List; + +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.network.NetworkServiceMapVO; +import com.cloud.utils.db.GenericDao; + +/** + * NetworkServiceDao deals with searches and operations done on the + * ntwk_service_map table. + * + */ +public interface NetworkServiceMapDao extends GenericDao{ + boolean areServicesSupportedInNetwork(long networkId, Service... services); + boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider); + List getServicesInNetwork(long networkId); + String getProviderForServiceInNetwork(long networkid, Service service); +} diff --git a/server/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java b/server/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java new file mode 100644 index 00000000000..20856a7f65c --- /dev/null +++ b/server/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java @@ -0,0 +1,138 @@ +/** + * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.network.dao; + + +import java.util.ArrayList; +import java.util.List; + +import javax.ejb.Local; + +import com.cloud.exception.UnsupportedServiceException; +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.network.NetworkServiceMapVO; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Local(value=NetworkServiceMapDao.class) @DB(txn=false) +public class NetworkServiceMapDaoImpl extends GenericDaoBase implements NetworkServiceMapDao { + final SearchBuilder AllFieldsSearch; + final SearchBuilder MultipleServicesSearch; + + protected NetworkServiceMapDaoImpl() { + super(); + AllFieldsSearch = createSearchBuilder(); + AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), SearchCriteria.Op.EQ); + AllFieldsSearch.done(); + + MultipleServicesSearch = createSearchBuilder(); + MultipleServicesSearch.and("networkId", MultipleServicesSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); + MultipleServicesSearch.and("service", MultipleServicesSearch.entity().getService(), SearchCriteria.Op.IN); + MultipleServicesSearch.and("provider", MultipleServicesSearch.entity().getProvider(), SearchCriteria.Op.EQ); + MultipleServicesSearch.done(); + } + + @Override + public boolean areServicesSupportedInNetwork(long networkId, Service... services) { + SearchCriteria sc = MultipleServicesSearch.create(); + sc.setParameters("networkId", networkId); + + if (services != null) { + String[] servicesStr = new String[services.length]; + + int i = 0; + for (Service service : services) { + servicesStr[i] = service.getName(); + i++; + } + + sc.setParameters("service", (Object[])servicesStr); + } + + List networkServices = listBy(sc); + + if (services != null) { + if (networkServices.size() == services.length) { + return true; + } + } else if (!networkServices.isEmpty()) { + return true; + } + + return false; + } + + @Override + public boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + sc.setParameters("service", service.getName()); + sc.setParameters("provider", provider.getName()); + if (findOneBy(sc) != null) { + return true; + } else { + return false; + } + } + + protected List getServicesForProviderInNetwork(long networkId, Provider provider) { + List services = new ArrayList(); + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + sc.setParameters("provider", provider.getName()); + List map = listBy(sc); + for (NetworkServiceMapVO instance : map) { + services.add(instance.getService()); + } + + return services; + } + + @Override + public String getProviderForServiceInNetwork(long networkId, Service service) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + sc.setParameters("service", service.getName()); + NetworkServiceMapVO ntwkSvc = findOneBy(sc); + if (ntwkSvc == null) { + throw new UnsupportedServiceException("Service " + service + " is not supported in the network id=" + networkId); + } + + return ntwkSvc.getProvider(); + } + + @Override + public List getServicesInNetwork(long networkId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + return listBy(sc); + } + + + protected void deleteByNetworkId(long networkId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + remove(sc); + } + +} diff --git a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java index a77446a603e..933ba8a7801 100644 --- a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java +++ b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java @@ -31,7 +31,6 @@ import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientNetworkCapacityException; import com.cloud.exception.ResourceUnavailableException; @@ -43,9 +42,9 @@ import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.Inject; import com.cloud.vm.NicProfile; @@ -61,7 +60,7 @@ public class F5ExternalLoadBalancerElement extends AdapterBase implements LoadBa @Inject NetworkManager _networkManager; @Inject ExternalNetworkDeviceManager _externalNetworkManager; @Inject ConfigurationManager _configMgr; - @Inject NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao; + @Inject NetworkServiceMapDao _ntwkSrvcDao; private boolean canHandle(Network config) { DataCenter zone = _configMgr.getZone(config.getDataCenterId()); @@ -70,8 +69,8 @@ public class F5ExternalLoadBalancerElement extends AdapterBase implements LoadBa return false; } - return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getNetworkOfferingId()) && - _ntwkOfferingSrvcDao.isProviderSupported(config.getNetworkOfferingId(), Service.Lb, Network.Provider.F5BigIp)); + return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getId()) && + _ntwkSrvcDao.isProviderSupportedInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp)); } @Override diff --git a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java index effbb30f90c..41841c3ae01 100644 --- a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java +++ b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java @@ -80,7 +80,7 @@ public class JuniperSRXExternalFirewallElement extends AdapterBase implements So return false; } - return _networkManager.networkIsConfiguredForExternalNetworking(zone.getId(),config.getNetworkOfferingId()); + return _networkManager.networkIsConfiguredForExternalNetworking(zone.getId(),config.getId()); } @Override @@ -98,7 +98,7 @@ public class JuniperSRXExternalFirewallElement extends AdapterBase implements So } try { - return _externalNetworkManager.manageGuestNetworkWithExternalFirewall(true, network, offering); + return _externalNetworkManager.manageGuestNetworkWithExternalFirewall(true, network); } catch (InsufficientCapacityException capacityException) { // TODO: handle out of capacity exception return false; @@ -118,7 +118,6 @@ public class JuniperSRXExternalFirewallElement extends AdapterBase implements So @Override public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException { DataCenter zone = _configMgr.getZone(network.getDataCenterId()); - NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId()); //don't have to implement network is Basic zone if (zone.getNetworkType() == NetworkType.Basic) { @@ -130,7 +129,7 @@ public class JuniperSRXExternalFirewallElement extends AdapterBase implements So return false; } try { - return _externalNetworkManager.manageGuestNetworkWithExternalFirewall(false, network, offering); + return _externalNetworkManager.manageGuestNetworkWithExternalFirewall(false, network); } catch (InsufficientCapacityException capacityException) { // TODO: handle out of capacity exception return false; diff --git a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java index 3567b764826..e09bbec65eb 100644 --- a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java +++ b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java @@ -42,9 +42,9 @@ import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.Inject; import com.cloud.vm.NicProfile; @@ -60,7 +60,7 @@ public class NetscalerExternalLoadBalancerElement extends AdapterBase implements @Inject NetworkManager _networkManager; @Inject ExternalNetworkDeviceManager _externalNetworkManager; @Inject ConfigurationManager _configMgr; - @Inject NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao; + @Inject NetworkServiceMapDao _ntwkSrvcDao; private boolean canHandle(Network config) { DataCenter zone = _configMgr.getZone(config.getDataCenterId()); @@ -69,8 +69,8 @@ public class NetscalerExternalLoadBalancerElement extends AdapterBase implements return false; } - return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getNetworkOfferingId()) && - _ntwkOfferingSrvcDao.isProviderSupported(config.getNetworkOfferingId(), Service.Lb, Network.Provider.Netscaler)); + return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getId()) && + _ntwkSrvcDao.isProviderSupportedInNetwork(config.getId(), Service.Lb, Network.Provider.Netscaler)); } @Override diff --git a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java index cf9cbb3d25c..45b5c3338c2 100644 --- a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java +++ b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java @@ -45,7 +45,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen @Override public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(guestConfig.getGuestType(), offering.getId(), Service.Gateway)) { + if (!canHandle(guestConfig, Service.Gateway)) { return false; } @@ -60,7 +60,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Gateway)) { + if (canHandle(network, Service.Gateway)) { if (vm.getType() != VirtualMachine.Type.User) { return false; } diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index e5f86e84401..d92613f1f00 100644 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -37,7 +37,6 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.dao.HostDao; import com.cloud.network.Network; import com.cloud.network.Network.Capability; -import com.cloud.network.Network.GuestType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; @@ -100,10 +99,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Inject ConfigurationDao _configDao; @Inject VirtualRouterProviderDao _vrProviderDao; - protected boolean canHandle(GuestType networkType, long offeringId, Service service) { + protected boolean canHandle(Network network, Service service) { boolean result = false; - if (_networkMgr.isProviderSupported(offeringId, service, getProvider())) { + if (_networkMgr.isProviderSupportedInNetwork(network.getId(), service, getProvider())) { result = true; } @@ -115,7 +114,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(guestConfig.getGuestType(), offering.getId(), Service.Gateway)) { + if (!canHandle(guestConfig, Service.Gateway)) { return false; } @@ -130,7 +129,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Dhcp)) { + if (canHandle(network, Service.Dhcp)) { if (vm.getType() != VirtualMachine.Type.User) { return false; } @@ -160,7 +159,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean applyFWRules(Network config, List rules) throws ResourceUnavailableException { - if (canHandle(config.getGuestType(), config.getNetworkOfferingId(), Service.Firewall)) { + if (canHandle(config, Service.Firewall)) { List routers = _routerDao.listByNetworkAndRole(config.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + config.getId()); @@ -179,7 +178,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean applyLBRules(Network network, List rules) throws ResourceUnavailableException { - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Lb)) { + if (canHandle(network, Service.Lb)) { List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + network.getId()); @@ -206,7 +205,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl return null; } - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Vpn)) { + if (canHandle(network, Service.Vpn)) { return _routerMgr.applyVpnUsers(network, users, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle applyVpnUsers command"); @@ -222,7 +221,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl return true; } - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Vpn)) { + if (canHandle(network, Service.Vpn)) { return _routerMgr.startRemoteAccessVpn(network, vpn, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle createVpn command"); @@ -238,7 +237,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl return true; } - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Vpn)) { + if (canHandle(network, Service.Vpn)) { return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle removeVpn command"); @@ -248,7 +247,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean applyIps(Network network, List ipAddress) throws ResourceUnavailableException { - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Firewall)) { + if (canHandle(network, Service.Firewall)) { List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { @@ -315,7 +314,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean applyStaticNats(Network config, List rules) throws ResourceUnavailableException { - if (canHandle(config.getGuestType(), config.getNetworkOfferingId(), Service.StaticNat)) { + if (canHandle(config, Service.StaticNat)) { List routers = _routerDao.listByNetworkAndRole(config.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual router doesn't exist in the network " + config.getId()); @@ -411,7 +410,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Override public boolean applyPFRules(Network network, List rules) throws ResourceUnavailableException { - if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.PortForwarding)) { + if (canHandle(network, Service.PortForwarding)) { List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + network.getId()); diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java index 204a36ff19f..42ae353ae9c 100644 --- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java +++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java @@ -358,10 +358,10 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma if (purpose == Purpose.LoadBalancing) { if (!_elbEnabled) { - protocolCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.Lb); + protocolCapabilities = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.Lb); } } else { - protocolCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.Firewall); + protocolCapabilities = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.Firewall); } if (protocolCapabilities != null) { diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java index 9e29f328eec..e04f2ce2579 100644 --- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java @@ -92,11 +92,6 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(config.getNetworkOfferingId()); - if (!canHandle(offering)) { - return null; - } - if(vm.getHypervisorType() == HypervisorType.VMware && vm.getType() != VirtualMachine.Type.DomainRouter) { NicProfile nicProf = new NicProfile(Nic.ReservationStrategy.Create, null, null, null, null); String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java index fbc7c5df477..7fe76feffae 100644 --- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java @@ -165,11 +165,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru { public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { - DataCenter dc = _dcDao.findById(network.getDataCenterId()); - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); - if (!canHandle(offering, dc)) { - return null; - } + DataCenter dc = _dcDao.findById(network.getDataCenterId()); if (nic == null) { nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java index acceec4b7e4..fd41f81e62b 100644 --- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java @@ -79,7 +79,6 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru { @Override protected boolean canHandle(NetworkOffering offering, DataCenter dc) { // this guru handles system Direct pod based network - //FIXME - verify broadcast domain type here if (dc.getNetworkType() == NetworkType.Basic && offering.getTrafficType() == TrafficType.Guest) { return true; } else { @@ -99,11 +98,6 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru { if ("external".equalsIgnoreCase(dhcpStrategy)) { rsStrategy = ReservationStrategy.Create; } - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); - - if (!canHandle(offering, dc)) { - return null; - } if (nic != null && nic.getRequestedIp() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java index 33d4d4f95b8..74c21399476 100644 --- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java +++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java @@ -87,7 +87,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner); if (config == null) { return null; - } else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getNetworkOfferingId())) { + } else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) { config.setState(State.Allocated); } @@ -102,7 +102,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { return null; } - if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getNetworkOfferingId())) { + if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) { return super.implement(config, offering, dest, context); } @@ -175,7 +175,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { - if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getNetworkOfferingId()) && nic != null && nic.getRequestedIp() != null) { + if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); } @@ -185,7 +185,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { return null; } - if (_networkMgr.zoneIsConfiguredForExternalNetworking(config.getDataCenterId())) { + if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) { profile.setStrategy(ReservationStrategy.Start); profile.setIp4Address(null); profile.setGateway(null); @@ -203,7 +203,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { return; } - if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getNetworkOfferingId())) { + if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) { nic.setIp4Address(null); nic.setGateway(null); nic.setNetmask(null); @@ -220,7 +220,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { return; } DataCenter dc = _dcDao.findById(config.getDataCenterId()); - if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getNetworkOfferingId())) { + if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) { nic.setBroadcastUri(config.getBroadcastUri()); nic.setIsolationUri(config.getBroadcastUri()); nic.setDns1(dc.getDns1()); @@ -254,7 +254,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { } NetworkVO network = _networkDao.findById(nic.getNetworkId()); - if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getNetworkOfferingId())) { + if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) { return true; } else { return super.release(nic, vm, reservationId); diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java index 002d778b8fb..54e2fd3d526 100644 --- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java @@ -137,11 +137,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { - DataCenter dc = _dcDao.findById(network.getDataCenterId()); - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); - if (!canHandle(offering, dc)) { - return null; - } + DataCenter dc = _dcDao.findById(network.getDataCenterId()); if (nic != null && nic.getRequestedIp() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 3b145cc1b71..e20d00f3fa9 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -458,8 +458,7 @@ public class ElasticLoadBalancerManagerImpl implements try { - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(guestNetwork.getNetworkOfferingId()); - if (offering.isSystemOnly() || guestNetwork.getGuestType() == Network.GuestType.Shared) { + if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) { owner = _accountService.getSystemAccount(); } diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java index ec479710e81..9bc0e54e396 100755 --- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java +++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java @@ -421,7 +421,7 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager, _accountMgr.checkAccess(caller.getCaller(), null, ipAddr); // verify that lb service is supported by the network - if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Lb)) { + if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) { throw new InvalidParameterValueException("LB service is not supported in network id= " + networkId); } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index d953d0cd9d9..2346a1f4c2c 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1031,9 +1031,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian long dcId = dest.getDataCenter().getId(); DataCenterDeployment plan = new DataCenterDeployment(dcId); - boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest; + boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest; boolean publicNetwork = false; - if (_networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) { + if (_networkMgr.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SourceNat)) { publicNetwork = true; } if (isRedundant && !publicNetwork) { @@ -1142,9 +1142,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian networks.add(new Pair((NetworkVO) guestNetwork, gatewayNic)); networks.add(new Pair(controlConfig, null)); - //Router is the network element, we don't know the hypervisor type yet. - //Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up - List supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId()); + Long offering_id = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); if (offering_id == null) { offering_id = _offering.getId(); @@ -1170,6 +1168,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian throw new CloudRuntimeException("Cannot find virtual router provider " + typeString + " as service provider " + provider.getId()); } ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(offering_id); + + //Router is the network element, we don't know the hypervisor type yet. + //Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up + List supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId()); int retry = 0; for (HypervisorType hType : supportedHypervisors) { try { @@ -1282,8 +1284,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian @Override public List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, boolean isRedundant) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { - NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(guestNetwork.getNetworkOfferingId()); - if (offering.isSystemOnly() || guestNetwork.getGuestType() == Network.GuestType.Shared) { + if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) { owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); } diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index 3e406f7941a..a22b7d5d0d1 100755 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -343,7 +343,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { } Network network = _networkMgr.getNetwork(networkId); - if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Firewall)) { + if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Firewall)) { throw new InvalidParameterValueException("Unable to create static nat rule; Firewall service is not supported in network id=" + networkId); } diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 6a1866f34d7..c02b87d81f5 100755 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -139,7 +139,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag //Verify that vpn service is enabled for the network Network network = _networkMgr.getNetwork(ipAddr.getAssociatedWithNetworkId()); - if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Vpn)) { + if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Vpn)) { throw new InvalidParameterValueException("Vpn service is not supported in network id=" + ipAddr.getAssociatedWithNetworkId()); } diff --git a/server/src/com/cloud/offerings/NetworkOfferingServiceMapVO.java b/server/src/com/cloud/offerings/NetworkOfferingServiceMapVO.java index 13b32fa0a6b..f53656cd90f 100644 --- a/server/src/com/cloud/offerings/NetworkOfferingServiceMapVO.java +++ b/server/src/com/cloud/offerings/NetworkOfferingServiceMapVO.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved * * This software is licensed under the GNU General Public License v3 or later. * diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java index 4231b78b176..aafbdc52df3 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java @@ -19,7 +19,6 @@ package com.cloud.offerings.dao; import java.util.List; -import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.offerings.NetworkOfferingServiceMapVO; import com.cloud.utils.db.GenericDao; @@ -30,12 +29,10 @@ import com.cloud.utils.db.GenericDao; * */ public interface NetworkOfferingServiceMapDao extends GenericDao { - boolean areServicesSupported(long networkOfferingId, Service... services); - boolean isProviderSupported(long networkOfferingId, Service service, Provider provider); - List getServicesForProvider(long networkOfferingId, Provider provider); - List getProvidersForService(long networkOfferingid, Service service); - List getServices(long networkOfferingId); + boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services); + List listByNetworkOfferingId(long networkOfferingId); void deleteByOfferingId(long networkOfferingId); + String getProviderForServiceForNetworkOffering(long networkOfferingId, Service service); } diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java index 4109112191d..9dc89a5efca 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved * * This software is licensed under the GNU General Public License v3 or later. * @@ -15,20 +15,14 @@ * along with this program. If not, see . * */ - -/** - * - */ package com.cloud.offerings.dao; -import java.util.ArrayList; import java.util.List; import javax.ejb.Local; import com.cloud.exception.UnsupportedServiceException; -import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.offerings.NetworkOfferingServiceMapVO; import com.cloud.utils.db.DB; @@ -57,7 +51,7 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase sc = MultipleServicesSearch.create(); sc.setParameters("networkOfferingId", networkOfferingId); @@ -73,67 +67,21 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase offerings = listBy(sc); + List offeringServices = listBy(sc); if (services != null) { - if (offerings.size() == services.length) { + if (offeringServices.size() == services.length) { return true; } - } else if (!offerings.isEmpty()) { + } else if (!offeringServices.isEmpty()) { return true; } return false; } - - @Override - public boolean isProviderSupported(long networkOfferingId, Service service, Provider provider) { - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("networkOfferingId", networkOfferingId); - sc.setParameters("service", service.getName()); - sc.setParameters("provider", provider.getName()); - if (findOneBy(sc) != null) { - return true; - } else { - return false; - } - } - - - @Override - public List getServicesForProvider(long networkOfferingId, Provider provider) { - List services = new ArrayList(); - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("networkOfferingId", networkOfferingId); - sc.setParameters("provider", provider.getName()); - List map = listBy(sc); - for (NetworkOfferingServiceMapVO instance : map) { - services.add(instance.getService()); - } - - return services; - } - - @Override - public List getProvidersForService(long networkOfferingId, Service service) { - List providers = new ArrayList(); - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("networkOfferingId", networkOfferingId); - sc.setParameters("service", service.getName()); - List map = listBy(sc); - if (map.isEmpty()) { - throw new UnsupportedServiceException("Service " + service + " is not supported by the network offering id=" + networkOfferingId); - } - - for (NetworkOfferingServiceMapVO instance : map) { - providers.add(instance.getProvider()); - } - - return providers; - } @Override - public List getServices(long networkOfferingId) { + public List listByNetworkOfferingId(long networkOfferingId) { SearchCriteria sc = AllFieldsSearch.create(); sc.setParameters("networkOfferingId", networkOfferingId); return listBy(sc); @@ -145,4 +93,17 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase sc = AllFieldsSearch.create(); + sc.setParameters("networkOfferingId", networkOfferingId); + sc.setParameters("service", service.getName()); + NetworkOfferingServiceMapVO ntwkSvc = findOneBy(sc); + if (ntwkSvc == null) { + throw new UnsupportedServiceException("Service " + service + " is not supported by network offering id=" + networkOfferingId); + } + + return ntwkSvc.getProvider(); + } } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 72f456746e1..69c50b7bf73 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -38,7 +38,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Set; import java.util.UUID; import java.util.regex.Pattern; @@ -76,7 +75,6 @@ import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.VirtualRouterProviderDao; import com.cloud.network.guru.ControlNetworkGuru; import com.cloud.network.guru.DirectPodBasedNetworkGuru; import com.cloud.network.guru.PodBasedNetworkGuru; @@ -121,9 +119,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { private final DomainDao _domainDao; private final AccountDao _accountDao; private final ResourceCountDao _resourceCountDao; - private final NetworkOfferingServiceMapDao _offeringServiceMapDao; - private final VirtualRouterProviderDao _virtualRouterProviderDao; - + private final NetworkOfferingServiceMapDao _ntwkOfferingServiceMapDao; public ConfigurationServerImpl() { ComponentLocator locator = ComponentLocator.getLocator(Name); @@ -139,8 +135,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { _domainDao = locator.getDao(DomainDao.class); _accountDao = locator.getDao(AccountDao.class); _resourceCountDao = locator.getDao(ResourceCountDao.class); - _offeringServiceMapDao = locator.getDao(NetworkOfferingServiceMapDao.class); - _virtualRouterProviderDao = locator.getDao(VirtualRouterProviderDao.class); + _ntwkOfferingServiceMapDao = locator.getDao(NetworkOfferingServiceMapDao.class); } @Override @DB @@ -874,7 +869,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(deafultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service)); - _offeringServiceMapDao.persist(offService); + _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } @@ -890,7 +885,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { for (Service service : defaultSharedNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service)); - _offeringServiceMapDao.persist(offService); + _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } @@ -907,7 +902,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service)); - _offeringServiceMapDao.persist(offService); + _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } @@ -923,7 +918,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service)); - _offeringServiceMapDao.persist(offService); + _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } @@ -989,7 +984,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { network.setDns1(zone.getDns1()); network.setDns2(zone.getDns2()); network.setState(State.Implemented); - _networkDao.persist(network, false); + _networkDao.persist(network, false, getServicesAndProvidersForNetwork(networkOfferingId)); id++; } } @@ -1114,5 +1109,18 @@ public class ConfigurationServerImpl implements ConfigurationServer { } } + public Map getServicesAndProvidersForNetwork(long networkOfferingId) { + Map svcProviders = new HashMap(); + List servicesMap = _ntwkOfferingServiceMapDao.listByNetworkOfferingId(networkOfferingId); + + for (NetworkOfferingServiceMapVO serviceMap : servicesMap) { + if (svcProviders.containsKey(serviceMap.getService())) { + continue; + } + svcProviders.put(serviceMap.getService(), serviceMap.getProvider()); + } + + return svcProviders; + } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index fc4086998ec..f808faf14c9 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -128,6 +128,7 @@ import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.LoadBalancerDao; import com.cloud.network.dao.LoadBalancerVMMapDao; import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.lb.LoadBalancingRulesManager; import com.cloud.network.router.VirtualNetworkApplianceManager; @@ -141,7 +142,6 @@ import com.cloud.offering.NetworkOffering.Availability; import com.cloud.offering.ServiceOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; import com.cloud.org.Cluster; import com.cloud.org.Grouping; import com.cloud.projects.Project; @@ -350,7 +350,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager @Inject protected ProjectManager _projectMgr; @Inject - protected NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao; + protected NetworkServiceMapDao _ntwkSrvcDao; protected ScheduledExecutorService _executor = null; protected int _expungeInterval; @@ -2736,7 +2736,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager DataCenterVO dc = _dcDao.findById(vm.getDataCenterIdToDeployIn()); UserVmVO userVm = profile.getVirtualMachine(); //dc.getDhcpProvider().equalsIgnoreCase(Provider.ExternalDhcpServer.getName()) - if (_ntwkOfferingSrvcDao.isProviderSupported(guestNetwork.getNetworkOfferingId(), Service.Dhcp, Provider.ExternalDhcpServer)){ + if (_ntwkSrvcDao.isProviderSupportedInNetwork(guestNetwork.getId(), Service.Dhcp, Provider.ExternalDhcpServer)){ _nicDao.update(guestNic.getId(), guestNic); userVm.setPrivateIpAddress(guestNic.getIp4Address()); _vmDao.update(userVm.getId(), userVm); diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index ef17f8ac6a7..52b92b1885b 100644 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -459,7 +459,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } @Override - public boolean isProviderSupported(long networkOfferingId, Service service, Provider provider) { + public boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider) { // TODO Auto-generated method stub return false; } @@ -512,13 +512,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return null; } - @Override - public PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, boolean forcedShutdown, List enabledServices) throws ConcurrentOperationException, - ResourceUnavailableException { - // TODO Auto-generated method stub - return null; - } - @Override public boolean deleteNetworkServiceProvider(Long id) { // TODO Auto-generated method stub @@ -555,12 +548,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return 0; } - @Override - public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel) { - // TODO Auto-generated method stub - return null; - } - @Override public PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id) { // TODO Auto-generated method stub @@ -598,13 +585,13 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } @Override - public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkOfferingId) { + public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId) { // TODO Auto-generated method stub return false; } @Override - public Map getServiceCapabilities(Long networkOfferingId, Service service) { + public Map getNetworkServiceCapabilities(long networkId, Service service) { // TODO Auto-generated method stub return null; } @@ -646,7 +633,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } @Override - public boolean isServiceEnabled(long physicalNetworkId, long networkOfferingId, Service service) { + public boolean isServiceEnabledInNetwork(long physicalNetworkId, long networkId, Service service) { // TODO Auto-generated method stub return false; } @@ -680,4 +667,28 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS // TODO Auto-generated method stub return null; } + + @Override + public PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, List enabledServices) { + // TODO Auto-generated method stub + return null; + } + + @Override + public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String vlan) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean areServicesSupportedInNetwork(long networkId, Service... services) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isNetworkSystem(Network network) { + // TODO Auto-generated method stub + return false; + } } diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 3251fda5b41..8398d8735ea 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1731,6 +1731,18 @@ CREATE TABLE `ntwk_offering_service_map` ( UNIQUE (`network_offering_id`, `service`, `provider`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `ntwk_service_map` ( + `id` bigint unsigned NOT NULL auto_increment, + `network_id` bigint unsigned NOT NULL COMMENT 'network_id', + `service` varchar(255) NOT NULL COMMENT 'service', + `provider` varchar(255) COMMENT 'service provider', + `created` datetime COMMENT 'date created', + PRIMARY KEY (`id`), + CONSTRAINT `fk_ntwk_service_map__network_id` FOREIGN KEY(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE, + UNIQUE (`network_id`, `service`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + CREATE TABLE `cloud`.`physical_network` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this physical network belongs to',