mirror of https://github.com/apache/cloudstack.git
Keep Service/Provider map per network as well as per networkOffering (to handle the case when there are multiple providers defined for the same service in the network offering, and only one is picked when the network is created)
This commit is contained in:
parent
810f9e4034
commit
3a845d2d75
|
|
@ -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 ///////////////////////
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -575,8 +575,8 @@ public class ApiDBUtils {
|
|||
return _networkDao.findById(id);
|
||||
}
|
||||
|
||||
public static Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkOfferingId, long zoneId) {
|
||||
return _networkMgr.getNetworkCapabilities(networkOfferingId);
|
||||
public static Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId, long zoneId) {
|
||||
return _networkMgr.getNetworkCapabilities(networkId);
|
||||
}
|
||||
|
||||
public static long getPublicNetworkIdByZone(long zoneId) {
|
||||
|
|
|
|||
|
|
@ -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<? extends Vlan> 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<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(networkOffering.getId(), network.getDataCenterId());
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(network.getId(), network.getDataCenterId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
if (serviceCapabilitiesMap != null) {
|
||||
for (Service service : serviceCapabilitiesMap.keySet()) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<? extends FirewallRule> rules) throws ResourceUnavailableException;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Network.Capability, String> sourceNatCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat);
|
||||
Map<Network.Capability, String> 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<Network.Capability, String> sourceNatCapabilities = _networkMgr.getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat);
|
||||
Map<Network.Capability, String> 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<NetworkVO> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Capability, String> getServiceCapabilities(Long networkOfferingId, Service service);
|
||||
Map<Capability, String> 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<Long> 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<String> 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<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
|
|
@ -701,7 +703,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
txn.start();
|
||||
|
||||
boolean sharedSourceNat = false;
|
||||
Map<Network.Capability, String> sourceNatCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat);
|
||||
Map<Network.Capability, String> 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<Network.Capability, String> sourceNatCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat);
|
||||
if (areServicesSupportedInNetwork(network.getId(), Service.SourceNat)) {
|
||||
Map<Network.Capability, String> 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<IPAddressVO> 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<Network.Capability, String> dnsCapabilities = getServiceCapabilities(networkOfferingId, Service.Dns);
|
||||
Map<Network.Capability, String> 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<Network> supportedNetworks = new ArrayList<Network>();
|
||||
|
||||
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<Service, Map<Capability, String>> getNetworkCapabilities(long networkOfferingId) {
|
||||
public Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId) {
|
||||
|
||||
Map<Service, Map<Capability, String>> networkCapabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
//list all services of this networkOffering
|
||||
List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingSrvcDao.getServices(networkOfferingId);
|
||||
for(NetworkOfferingServiceMapVO instance : servicesMap ){
|
||||
List<NetworkServiceMapVO> 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<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();;
|
||||
|
|
@ -2742,32 +2732,51 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<Capability, String> getServiceCapabilities(Long networkOfferingId, Service service) {
|
||||
public Map<Capability, String> 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<Capability, String> serviceCapabilities = new HashMap<Capability, String>();
|
||||
|
||||
//get the Provider for this Service for this offering
|
||||
List<String> serviceProviderNames = _ntwkOfferingSrvcDao.getProvidersForService(networkOfferingId, service);
|
||||
String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service);
|
||||
|
||||
NetworkElement element = getElementImplementingProvider(provider);
|
||||
if(element != null){
|
||||
Map<Service, Map<Capability, String>> 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<Capability, String> 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<Capability, String> serviceCapabilities = new HashMap<Capability, String>();
|
||||
|
||||
//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<Service, Map<Capability, String>> 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<Service, Map<Capability, String>> 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<NetworkVO> 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<Network.Capability, String> 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<Network.Capability, String> 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<String, Set<String>> listNetworkOfferingServices(long networkOfferingId) {
|
||||
Map<String, Set<String>> serviceProviderMap = new HashMap<String, Set<String>>();
|
||||
List<NetworkOfferingServiceMapVO> map = _ntwkOfferingSrvcDao.getServices(networkOfferingId);
|
||||
List<NetworkOfferingServiceMapVO> 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<String> 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<String, String> getServicesAndProvidersForNetwork(NetworkOffering offering) {
|
||||
Map<String, String> svcProviders = new HashMap<String, String>();
|
||||
List<NetworkOfferingServiceMapVO> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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<NetworkVO, Long> {
|
|||
|
||||
List<NetworkVO> listBy(long accountId, long dataCenterId, Network.GuestType type);
|
||||
|
||||
NetworkVO persist(NetworkVO network, boolean gc);
|
||||
NetworkVO persist(NetworkVO network, boolean gc, Map<String, String> serviceProviderMap);
|
||||
|
||||
SearchBuilder<NetworkAccountVO> createSearchBuilderForAccount();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<NetworkVO, Long> 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<NetworkVO, Long> implements N
|
|||
|
||||
ZoneSecurityGroupSearch = createSearchBuilder();
|
||||
ZoneSecurityGroupSearch.and("dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ);
|
||||
SearchBuilder<NetworkOfferingServiceMapVO> join1 = _ntwkOffSvcMap.createSearchBuilder();
|
||||
SearchBuilder<NetworkServiceMapVO> 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<NetworkVO, Long> implements N
|
|||
PhysicalNetworkSearch.done();
|
||||
|
||||
securityGroupSearch = createSearchBuilder();
|
||||
SearchBuilder<NetworkOfferingServiceMapVO> join3 = _ntwkOffSvcMap.createSearchBuilder();
|
||||
SearchBuilder<NetworkServiceMapVO> 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<NetworkVO, Long> implements N
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public NetworkVO persist(NetworkVO network, boolean gc) {
|
||||
public NetworkVO persist(NetworkVO network, boolean gc, Map<String, String> 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<NetworkVO, Long> implements N
|
|||
|
||||
@Override
|
||||
public List<NetworkVO> listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName) {
|
||||
SearchBuilder<NetworkOfferingServiceMapVO> svcProviderMapSearch = _ntwkOffSvcMap.createSearchBuilder();
|
||||
NetworkOfferingServiceMapVO svcProviderEntry = svcProviderMapSearch.entity();
|
||||
SearchBuilder<NetworkServiceMapVO> svcProviderMapSearch = _ntwkSvcMap.createSearchBuilder();
|
||||
NetworkServiceMapVO svcProviderEntry = svcProviderMapSearch.entity();
|
||||
svcProviderMapSearch.and("Provider", svcProviderMapSearch.entity().getProvider(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchBuilder<NetworkVO> 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<NetworkVO> sc = networksSearch.create();
|
||||
sc.setJoinParameters("svcProviderMapSearch", "Provider", providerName);
|
||||
|
|
|
|||
|
|
@ -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<NetworkServiceMapVO, Long>{
|
||||
boolean areServicesSupportedInNetwork(long networkId, Service... services);
|
||||
boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider);
|
||||
List<NetworkServiceMapVO> getServicesInNetwork(long networkId);
|
||||
String getProviderForServiceInNetwork(long networkid, Service service);
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
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<NetworkServiceMapVO, Long> implements NetworkServiceMapDao {
|
||||
final SearchBuilder<NetworkServiceMapVO> AllFieldsSearch;
|
||||
final SearchBuilder<NetworkServiceMapVO> 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<NetworkServiceMapVO> 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<NetworkServiceMapVO> 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<NetworkServiceMapVO> 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<String> getServicesForProviderInNetwork(long networkId, Provider provider) {
|
||||
List<String> services = new ArrayList<String>();
|
||||
SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("provider", provider.getName());
|
||||
List<NetworkServiceMapVO> map = listBy(sc);
|
||||
for (NetworkServiceMapVO instance : map) {
|
||||
services.add(instance.getService());
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderForServiceInNetwork(long networkId, Service service) {
|
||||
SearchCriteria<NetworkServiceMapVO> 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<NetworkServiceMapVO> getServicesInNetwork(long networkId) {
|
||||
SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
protected void deleteByNetworkId(long networkId) {
|
||||
SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<? extends VirtualMachine> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<? extends VirtualMachine> 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<? extends FirewallRule> rules) throws ResourceUnavailableException {
|
||||
if (canHandle(config.getGuestType(), config.getNetworkOfferingId(), Service.Firewall)) {
|
||||
if (canHandle(config, Service.Firewall)) {
|
||||
List<DomainRouterVO> 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<LoadBalancingRule> rules) throws ResourceUnavailableException {
|
||||
if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Lb)) {
|
||||
if (canHandle(network, Service.Lb)) {
|
||||
List<DomainRouterVO> 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<? extends PublicIpAddress> ipAddress) throws ResourceUnavailableException {
|
||||
if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Firewall)) {
|
||||
if (canHandle(network, Service.Firewall)) {
|
||||
|
||||
List<DomainRouterVO> 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<? extends StaticNat> rules) throws ResourceUnavailableException {
|
||||
if (canHandle(config.getGuestType(), config.getNetworkOfferingId(), Service.StaticNat)) {
|
||||
if (canHandle(config, Service.StaticNat)) {
|
||||
List<DomainRouterVO> 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<PortForwardingRule> rules) throws ResourceUnavailableException {
|
||||
if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.PortForwarding)) {
|
||||
if (canHandle(network, Service.PortForwarding)) {
|
||||
List<DomainRouterVO> 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());
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -92,11 +92,6 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> 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());
|
||||
|
|
|
|||
|
|
@ -165,11 +165,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> 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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<? extends VirtualMachine> 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);
|
||||
|
|
|
|||
|
|
@ -137,11 +137,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> 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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, NicProfile>((NetworkVO) guestNetwork, gatewayNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(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<HypervisorType> 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<HypervisorType> 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<DomainRouterVO> deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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<NetworkOfferingServiceMapVO, Long> {
|
||||
boolean areServicesSupported(long networkOfferingId, Service... services);
|
||||
boolean isProviderSupported(long networkOfferingId, Service service, Provider provider);
|
||||
List<String> getServicesForProvider(long networkOfferingId, Provider provider);
|
||||
List<String> getProvidersForService(long networkOfferingid, Service service);
|
||||
List<NetworkOfferingServiceMapVO> getServices(long networkOfferingId);
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
List<NetworkOfferingServiceMapVO> listByNetworkOfferingId(long networkOfferingId);
|
||||
void deleteByOfferingId(long networkOfferingId);
|
||||
String getProviderForServiceForNetworkOffering(long networkOfferingId, Service service);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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<NetworkOffe
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean areServicesSupported(long networkOfferingId, Service... services) {
|
||||
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
|
||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
|
||||
|
|
@ -73,67 +67,21 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
|||
sc.setParameters("service", (Object[])servicesStr);
|
||||
}
|
||||
|
||||
List<NetworkOfferingServiceMapVO> offerings = listBy(sc);
|
||||
List<NetworkOfferingServiceMapVO> 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<NetworkOfferingServiceMapVO> 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<String> getServicesForProvider(long networkOfferingId, Provider provider) {
|
||||
List<String> services = new ArrayList<String>();
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
sc.setParameters("provider", provider.getName());
|
||||
List<NetworkOfferingServiceMapVO> map = listBy(sc);
|
||||
for (NetworkOfferingServiceMapVO instance : map) {
|
||||
services.add(instance.getService());
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProvidersForService(long networkOfferingId, Service service) {
|
||||
List<String> providers = new ArrayList<String>();
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
sc.setParameters("service", service.getName());
|
||||
List<NetworkOfferingServiceMapVO> 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<NetworkOfferingServiceMapVO> getServices(long networkOfferingId) {
|
||||
public List<NetworkOfferingServiceMapVO> listByNetworkOfferingId(long networkOfferingId) {
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
return listBy(sc);
|
||||
|
|
@ -145,4 +93,17 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
|||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderForServiceForNetworkOffering(long networkOfferingId, Service service) {
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, String> getServicesAndProvidersForNetwork(long networkOfferingId) {
|
||||
Map<String, String> svcProviders = new HashMap<String, String>();
|
||||
List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingServiceMapDao.listByNetworkOfferingId(networkOfferingId);
|
||||
|
||||
for (NetworkOfferingServiceMapVO serviceMap : servicesMap) {
|
||||
if (svcProviders.containsKey(serviceMap.getService())) {
|
||||
continue;
|
||||
}
|
||||
svcProviders.put(serviceMap.getService(), serviceMap.getProvider());
|
||||
}
|
||||
|
||||
return svcProviders;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<String> 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<Capability, String> getServiceCapabilities(Long networkOfferingId, Service service) {
|
||||
public Map<Capability, String> 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<String> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue