mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Default gateway service to sourceNat service in the API
This commit is contained in:
		
							parent
							
								
									0a10e32d69
								
							
						
					
					
						commit
						337c07c0d1
					
				| @ -31,6 +31,7 @@ import com.cloud.api.response.ListResponse; | |||||||
| import com.cloud.api.response.ServiceResponse; | import com.cloud.api.response.ServiceResponse; | ||||||
| import com.cloud.exception.InvalidParameterValueException; | import com.cloud.exception.InvalidParameterValueException; | ||||||
| import com.cloud.network.Network; | import com.cloud.network.Network; | ||||||
|  | import com.cloud.network.Network.Service; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -101,6 +102,10 @@ public class ListSupportedNetworkServicesCmd extends BaseListCmd { | |||||||
|         ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>(); |         ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>(); | ||||||
|         List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>(); |         List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>(); | ||||||
|         for (Network.Service service : services) { |         for (Network.Service service : services) { | ||||||
|  |         	//skip gateway service | ||||||
|  |         	if (service == Service.Gateway) { | ||||||
|  |         		continue; | ||||||
|  |         	} | ||||||
|             ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service); |             ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service); | ||||||
|             servicesResponses.add(serviceResponse); |             servicesResponses.add(serviceResponse); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -35,10 +35,6 @@ public class ServiceResponse extends BaseResponse { | |||||||
|     @SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class) |     @SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class) | ||||||
|     private List<CapabilityResponse> capabilities; |     private List<CapabilityResponse> capabilities; | ||||||
| 
 | 
 | ||||||
|     public String getName() { |  | ||||||
|         return name; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setName(String name) { |     public void setName(String name) { | ||||||
|         this.name = name; |         this.name = name; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -2348,6 +2348,10 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>(); |         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>(); | ||||||
|         for (String service : serviceProviderMap.keySet()) { |         for (String service : serviceProviderMap.keySet()) { | ||||||
|             ServiceResponse svcRsp = new ServiceResponse(); |             ServiceResponse svcRsp = new ServiceResponse(); | ||||||
|  |             //skip gateway service | ||||||
|  |             if (service.equalsIgnoreCase(Service.Gateway.getName())) { | ||||||
|  |             	continue; | ||||||
|  |             } | ||||||
|             svcRsp.setName(service); |             svcRsp.setName(service); | ||||||
|             List<ProviderResponse> providers = new ArrayList<ProviderResponse>(); |             List<ProviderResponse> providers = new ArrayList<ProviderResponse>(); | ||||||
|             for (String provider : serviceProviderMap.get(service)) { |             for (String provider : serviceProviderMap.get(service)) { | ||||||
| @ -2452,6 +2456,10 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         if (serviceCapabilitiesMap != null) { |         if (serviceCapabilitiesMap != null) { | ||||||
|             for (Service service : serviceCapabilitiesMap.keySet()) { |             for (Service service : serviceCapabilitiesMap.keySet()) { | ||||||
|                 ServiceResponse serviceResponse = new ServiceResponse(); |                 ServiceResponse serviceResponse = new ServiceResponse(); | ||||||
|  |                 //skip gateway service | ||||||
|  |                 if (service == Service.Gateway) { | ||||||
|  |                 	continue; | ||||||
|  |                 } | ||||||
|                 serviceResponse.setName(service.getName()); |                 serviceResponse.setName(service.getName()); | ||||||
| 
 | 
 | ||||||
|                 // set list of capabilities for the service |                 // set list of capabilities for the service | ||||||
|  | |||||||
| @ -2917,7 +2917,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         for (String serviceName : cmd.getSupportedServices()) { |         for (String serviceName : cmd.getSupportedServices()) { | ||||||
|         	//validate if the service is supported |         	//validate if the service is supported | ||||||
|         	Service service = Network.Service.getService(serviceName); |         	Service service = Network.Service.getService(serviceName); | ||||||
|         	if (service == null) { |         	if (service == null || service == Service.Gateway) { | ||||||
|         		throw new InvalidParameterValueException("Invalid service " + serviceName); |         		throw new InvalidParameterValueException("Invalid service " + serviceName); | ||||||
|         	} |         	} | ||||||
|         	 |         	 | ||||||
| @ -2934,6 +2934,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         	serviceProviderMap.put(service, defaultProviders); |         	serviceProviderMap.put(service, defaultProviders); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  |         //add gateway provider (if sourceNat provider is enabled) | ||||||
|  |         Set<Provider> sourceNatServiceProviders = serviceProviderMap.get(Service.SourceNat); | ||||||
|  |         if (sourceNatServiceProviders != null && !sourceNatServiceProviders.isEmpty()) { | ||||||
|  |         	serviceProviderMap.put(Service.Gateway, sourceNatServiceProviders); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         // populate providers |         // populate providers | ||||||
|         Map<String, List<String>> svcPrv = cmd.getServiceProviders(); |         Map<String, List<String>> svcPrv = cmd.getServiceProviders(); | ||||||
|         if (svcPrv != null) { |         if (svcPrv != null) { | ||||||
| @ -2957,6 +2963,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  |         //validate  | ||||||
|  | 
 | ||||||
|         // verify the LB service capabilities specified in the network offering |         // verify the LB service capabilities specified in the network offering | ||||||
|         Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb); |         Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb); | ||||||
|         if (!serviceProviderMap.containsKey(Service.Lb) && lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) { |         if (!serviceProviderMap.containsKey(Service.Lb) && lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) { | ||||||
| @ -2971,17 +2979,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         } |         } | ||||||
|         validateSourceNatServiceCapablities(sourceNatServiceCapabilityMap); |         validateSourceNatServiceCapablities(sourceNatServiceCapabilityMap); | ||||||
|          |          | ||||||
|         // verify the Gateway service capabilities specified in the network offering |  | ||||||
|         Map<Capability, String> gwServiceCapabilityMap = cmd.getServiceCapabilities(Service.Gateway); |  | ||||||
|         if (!serviceProviderMap.containsKey(Service.Gateway) && gwServiceCapabilityMap != null && !gwServiceCapabilityMap.isEmpty()) { |  | ||||||
|             throw new InvalidParameterValueException("Capabilities for Gateway service can be specifed only when Gateway service is enabled for network offering."); |  | ||||||
|         } |  | ||||||
|         validateGatewayServiceCapablities(gwServiceCapabilityMap); |  | ||||||
|          |  | ||||||
|         Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>(); |         Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>(); | ||||||
|         serviceCapabilityMap.put(Service.Lb, lbServiceCapabilityMap); |         serviceCapabilityMap.put(Service.Lb, lbServiceCapabilityMap); | ||||||
|         serviceCapabilityMap.put(Service.SourceNat, sourceNatServiceCapabilityMap); |         serviceCapabilityMap.put(Service.SourceNat, sourceNatServiceCapabilityMap); | ||||||
|         serviceCapabilityMap.put(Service.Gateway, gwServiceCapabilityMap); |  | ||||||
|          |          | ||||||
|         return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, networkRate, serviceProviderMap, false, |         return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, networkRate, serviceProviderMap, false, | ||||||
|                 guestType, false, serviceOfferingId, serviceCapabilityMap); |                 guestType, false, serviceOfferingId, serviceCapabilityMap); | ||||||
| @ -3003,28 +3003,27 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
| 
 | 
 | ||||||
|     void validateSourceNatServiceCapablities(Map<Capability, String> sourceNatServiceCapabilityMap) { |     void validateSourceNatServiceCapablities(Map<Capability, String> sourceNatServiceCapabilityMap) { | ||||||
|         if (sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) { |         if (sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) { | ||||||
|             if (sourceNatServiceCapabilityMap.keySet().size() > 1 || !sourceNatServiceCapabilityMap.containsKey(Capability.SupportedSourceNatTypes)) { |             if (sourceNatServiceCapabilityMap.keySet().size() > 2) { | ||||||
|                 throw new InvalidParameterValueException("Only Supported Source NAT type capability can be sepcified for firewall service"); |         		throw new InvalidParameterValueException("Only " + Capability.SupportedSourceNatTypes.getName() + " and " + Capability.RedundantRouter + " capabilities can be sepcified for firewall service"); | ||||||
|             } |             } | ||||||
|             String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes); |  | ||||||
|             boolean perAccount = sourceNatType.contains("peraccount"); |  | ||||||
|             boolean perZone = sourceNatType.contains("perzone"); |  | ||||||
|             if ((perAccount && perZone) || (!perAccount && !perZone)) { |  | ||||||
|                 throw new InvalidParameterValueException("Either perAccount or perZone source NAT type can be specified for " + Capability.SupportedSourceNatTypes.getName()); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|              |              | ||||||
|     void validateGatewayServiceCapablities(Map<Capability, String> gwServiceCapabilityMap) { |             for (Capability capability : sourceNatServiceCapabilityMap.keySet()) { | ||||||
|         if (gwServiceCapabilityMap != null && !gwServiceCapabilityMap.isEmpty()) { |             	String value = sourceNatServiceCapabilityMap.get(capability); | ||||||
|             if (gwServiceCapabilityMap.keySet().size() > 1 || !gwServiceCapabilityMap.containsKey(Capability.RedundantRouter)) { |             	if (capability == Capability.SupportedSourceNatTypes) { | ||||||
|                 throw new InvalidParameterValueException("Only redundant router capability can be sepcified for gateway service"); |             		 boolean perAccount = value.contains("peraccount"); | ||||||
|             } |                      boolean perZone = value.contains("perzone"); | ||||||
|             String param = gwServiceCapabilityMap.get(Capability.RedundantRouter); |                      if ((perAccount && perZone) || (!perAccount && !perZone)) { | ||||||
|             boolean enabled = param.contains("true"); |                          throw new InvalidParameterValueException("Either perAccount or perZone source NAT type can be specified for " + Capability.SupportedSourceNatTypes.getName()); | ||||||
|             boolean disabled = param.contains("false"); |                      } | ||||||
|             if (!enabled && !disabled) { |             	} else if (capability == Capability.RedundantRouter) { | ||||||
|                 throw new InvalidParameterValueException("Unknown specified value for " + Capability.RedundantRouter.getName()); |             		boolean enabled = value.contains("true"); | ||||||
|  |                     boolean disabled = value.contains("false"); | ||||||
|  |                     if (!enabled && !disabled) { | ||||||
|  |                         throw new InvalidParameterValueException("Unknown specified value for " + Capability.RedundantRouter.getName()); | ||||||
|  |                     } | ||||||
|  |             	} else { | ||||||
|  |             		throw new InvalidParameterValueException("Only " + Capability.SupportedSourceNatTypes.getName() + " and " + Capability.RedundantRouter + " capabilities can be sepcified for firewall service"); | ||||||
|  |             	} | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -3046,17 +3045,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|             dedicatedLb = isolationCapability.contains("dedicated"); |             dedicatedLb = isolationCapability.contains("dedicated"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Map<Capability, String> fwServiceCapabilityMap = serviceCapabilityMap.get(Service.Firewall); |         Map<Capability, String> sourceNatServiceCapabilityMap = serviceCapabilityMap.get(Service.SourceNat); | ||||||
|         boolean sharedSourceNat = false; |         boolean sharedSourceNat = false; | ||||||
|         if ((fwServiceCapabilityMap != null) && (!fwServiceCapabilityMap.isEmpty())) {  |  | ||||||
|             String sourceNatType = fwServiceCapabilityMap.get(Capability.SupportedSourceNatTypes.getName()); |  | ||||||
|             sharedSourceNat = sourceNatType.contains("perzone"); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         Map<Capability, String> gwServiceCapabilityMap = serviceCapabilityMap.get(Service.Gateway); |  | ||||||
|         boolean redundantRouter = false; |         boolean redundantRouter = false; | ||||||
|         if ((gwServiceCapabilityMap != null) && (!gwServiceCapabilityMap.isEmpty())) {  |         if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {  | ||||||
|             String param = gwServiceCapabilityMap.get(Capability.RedundantRouter); |             String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes.getName()); | ||||||
|  |             sharedSourceNat = sourceNatType.contains("perzone"); | ||||||
|  |             String param = sourceNatServiceCapabilityMap.get(Capability.RedundantRouter); | ||||||
|             if (param != null) { |             if (param != null) { | ||||||
|                 redundantRouter = param.contains("true"); |                 redundantRouter = param.contains("true"); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -246,5 +246,5 @@ public interface NetworkManager extends NetworkService { | |||||||
| 
 | 
 | ||||||
| 	boolean getAllowSubdomainAccessGlobal(); | 	boolean getAllowSubdomainAccessGlobal(); | ||||||
| 	 | 	 | ||||||
| 	boolean isProviderInNetwork(Provider provider, long networkId); | 	boolean isProviderForNetwork(Provider provider, long networkId); | ||||||
| } | } | ||||||
|  | |||||||
| @ -3114,24 +3114,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId) { |     public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId) { | ||||||
|         DataCenterVO zone = _dcDao.findById(zoneId); |     	boolean netscalerInNetwork = isProviderForNetwork(Network.Provider.Netscaler, networkId); | ||||||
|  |     	boolean juniperInNetwork = isProviderForNetwork(Network.Provider.JuniperSRX, networkId); | ||||||
|  |     	boolean f5InNetwork = isProviderForNetwork(Network.Provider.F5BigIp, networkId); | ||||||
|     	 |     	 | ||||||
|         boolean usesJuniperForGatewayService = _ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Service.Gateway, Network.Provider.JuniperSRX); |     	if (netscalerInNetwork || juniperInNetwork || f5InNetwork) { | ||||||
|         boolean usesJuniperForFirewallService = _ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Service.Firewall, Network.Provider.JuniperSRX); |     		return true; | ||||||
|         boolean usesNetscalarForLBService = _ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Service.Lb, Network.Provider.Netscaler); |     	} else { | ||||||
|         boolean usesF5ForLBService = _ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Service.Lb, Network.Provider.F5BigIp); |     		return false; | ||||||
|          |     	} | ||||||
|         if (zone.getNetworkType() == NetworkType.Advanced) { |  | ||||||
|             if (usesJuniperForGatewayService && usesJuniperForFirewallService) { |  | ||||||
|                 return true; |  | ||||||
|             } else if (_ntwkSrvcDao.areServicesSupportedInNetwork(networkId, Service.Gateway) && (usesF5ForLBService || usesNetscalarForLBService)) { |  | ||||||
|                 return true; |  | ||||||
|             } else { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|         } else { |  | ||||||
|             return usesJuniperForFirewallService; |  | ||||||
|         } |  | ||||||
|     }     |     }     | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @ -4169,17 +4160,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|             } |             } | ||||||
|              |              | ||||||
|             //validate Services |             //validate Services | ||||||
|  |             boolean addGatewayService = false; | ||||||
|             for(String serviceName : enabledServices){ |             for(String serviceName : enabledServices){ | ||||||
|                 Network.Service service = Network.Service.getService(serviceName); |                 Network.Service service = Network.Service.getService(serviceName); | ||||||
|                 if(service == null){ |                 if (service == null || service == Service.Gateway){ | ||||||
|                     throw new InvalidParameterValueException("Invalid Network Service specified=" + serviceName); |                     throw new InvalidParameterValueException("Invalid Network Service specified=" + serviceName); | ||||||
|  |                 } else if (service == Service.SourceNat) { | ||||||
|  |                 	addGatewayService = true; | ||||||
|                 } |                 } | ||||||
|                 services.add(service); |                 services.add(service); | ||||||
|             } |             } | ||||||
|  |              | ||||||
|  |             if (addGatewayService) { | ||||||
|  |             	services.add(Service.Gateway); | ||||||
|  |             } | ||||||
|  |              | ||||||
|         }else{ |         }else{ | ||||||
|             //enable all the default services supported by this element. |             //enable all the default services supported by this element. | ||||||
|             services = new ArrayList<Service>(element.getCapabilities().keySet());  |             services = new ArrayList<Service>(element.getCapabilities().keySet());  | ||||||
|              |  | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         Transaction txn = Transaction.currentTxn(); |         Transaction txn = Transaction.currentTxn(); | ||||||
| @ -5032,7 +5030,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public boolean isProviderInNetwork(Provider provider, long networkId) { |     public boolean isProviderForNetwork(Provider provider, long networkId) { | ||||||
|     	if (_ntwkSrvcDao.isProviderForNetwork(networkId, provider) == null) { |     	if (_ntwkSrvcDao.isProviderForNetwork(networkId, provider) == null) { | ||||||
|     		return true; |     		return true; | ||||||
|     	} else { |     	} else { | ||||||
|  | |||||||
| @ -99,13 +99,12 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan | |||||||
|     @Inject NetworkDao _networkDao; |     @Inject NetworkDao _networkDao; | ||||||
| 
 | 
 | ||||||
|     private boolean canHandle(Network config) { |     private boolean canHandle(Network config) { | ||||||
|         DataCenter zone = _configMgr.getZone(config.getDataCenterId()); |  | ||||||
|         if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) { |         if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) { | ||||||
|             s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType()); |             s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType()); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getId()) &&  |         return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) &&  | ||||||
|                 _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp)); |                 _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -111,7 +111,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan | |||||||
|             return false; |             return false; | ||||||
|         }    |         }    | ||||||
|          |          | ||||||
|         return _networkManager.networkIsConfiguredForExternalNetworking(zone.getId(),config.getId())&&  |         return _networkManager.isProviderForNetwork(getProvider(), config.getId()) &&  | ||||||
|         _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.JuniperSRX); |         _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.JuniperSRX); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -243,21 +243,16 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan | |||||||
|    |    | ||||||
|         // Set capabilities for Firewall service |         // Set capabilities for Firewall service | ||||||
|         Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();    |         Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();    | ||||||
|          |  | ||||||
|         // Specifies that NAT rules can be made for either TCP or UDP traffic |  | ||||||
|         firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp");  |         firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp");  | ||||||
|          |  | ||||||
|         firewallCapabilities.put(Capability.MultipleIps, "true"); |         firewallCapabilities.put(Capability.MultipleIps, "true"); | ||||||
|          |  | ||||||
|         // Specifies that this element can measure network usage on a per public IP basis |  | ||||||
|         firewallCapabilities.put(Capability.TrafficStatistics, "per public ip"); |         firewallCapabilities.put(Capability.TrafficStatistics, "per public ip"); | ||||||
|  |         capabilities.put(Service.Firewall, firewallCapabilities); | ||||||
|          |          | ||||||
|         // Specifies supported VPN types |         // Set VPN capabilities | ||||||
|         Map<Capability, String> vpnCapabilities = new HashMap<Capability, String>(); |         Map<Capability, String> vpnCapabilities = new HashMap<Capability, String>(); | ||||||
|         vpnCapabilities.put(Capability.SupportedVpnTypes, "ipsec"); |         vpnCapabilities.put(Capability.SupportedVpnTypes, "ipsec"); | ||||||
|         capabilities.put(Service.Vpn, vpnCapabilities); |         capabilities.put(Service.Vpn, vpnCapabilities); | ||||||
|          |          | ||||||
|         capabilities.put(Service.Firewall, firewallCapabilities); |  | ||||||
|         capabilities.put(Service.Gateway, null); |         capabilities.put(Service.Gateway, null); | ||||||
|          |          | ||||||
|         Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>(); |         Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>(); | ||||||
|  | |||||||
| @ -23,7 +23,9 @@ import java.util.ArrayList; | |||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  | 
 | ||||||
| import javax.ejb.Local; | import javax.ejb.Local; | ||||||
|  | 
 | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| 
 | 
 | ||||||
| import com.cloud.agent.AgentManager; | import com.cloud.agent.AgentManager; | ||||||
| @ -34,7 +36,6 @@ import com.cloud.api.commands.ListNetscalerLoadBalancerNetworksCmd; | |||||||
| import com.cloud.api.commands.ListNetscalerLoadBalancersCmd; | import com.cloud.api.commands.ListNetscalerLoadBalancersCmd; | ||||||
| import com.cloud.api.response.NetscalerLoadBalancerResponse; | import com.cloud.api.response.NetscalerLoadBalancerResponse; | ||||||
| import com.cloud.configuration.ConfigurationManager; | import com.cloud.configuration.ConfigurationManager; | ||||||
| import com.cloud.dc.DataCenter; |  | ||||||
| import com.cloud.dc.dao.DataCenterDao; | import com.cloud.dc.dao.DataCenterDao; | ||||||
| import com.cloud.deploy.DeployDestination; | import com.cloud.deploy.DeployDestination; | ||||||
| import com.cloud.exception.ConcurrentOperationException; | import com.cloud.exception.ConcurrentOperationException; | ||||||
| @ -46,18 +47,18 @@ import com.cloud.host.dao.HostDao; | |||||||
| import com.cloud.network.ExternalLoadBalancerDeviceManager; | import com.cloud.network.ExternalLoadBalancerDeviceManager; | ||||||
| import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl; | import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl; | ||||||
| import com.cloud.network.ExternalLoadBalancerDeviceVO; | import com.cloud.network.ExternalLoadBalancerDeviceVO; | ||||||
| import com.cloud.network.Network; |  | ||||||
| import com.cloud.network.NetworkExternalLoadBalancerVO; |  | ||||||
| import com.cloud.network.NetworkVO; |  | ||||||
| import com.cloud.network.PhysicalNetworkVO; |  | ||||||
| import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState; | import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState; | ||||||
| import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice; | import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice; | ||||||
|  | import com.cloud.network.Network; | ||||||
| import com.cloud.network.Network.Capability; | import com.cloud.network.Network.Capability; | ||||||
| import com.cloud.network.Network.Provider; | import com.cloud.network.Network.Provider; | ||||||
| import com.cloud.network.Network.Service; | import com.cloud.network.Network.Service; | ||||||
|  | import com.cloud.network.NetworkExternalLoadBalancerVO; | ||||||
| import com.cloud.network.NetworkManager; | import com.cloud.network.NetworkManager; | ||||||
|  | import com.cloud.network.NetworkVO; | ||||||
| import com.cloud.network.Networks.TrafficType; | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.PhysicalNetworkServiceProvider; | import com.cloud.network.PhysicalNetworkServiceProvider; | ||||||
|  | import com.cloud.network.PhysicalNetworkVO; | ||||||
| import com.cloud.network.dao.ExternalLoadBalancerDeviceDao; | import com.cloud.network.dao.ExternalLoadBalancerDeviceDao; | ||||||
| import com.cloud.network.dao.NetworkDao; | import com.cloud.network.dao.NetworkDao; | ||||||
| import com.cloud.network.dao.NetworkExternalLoadBalancerDao; | import com.cloud.network.dao.NetworkExternalLoadBalancerDao; | ||||||
| @ -92,13 +93,12 @@ public class NetscalerExternalLoadBalancerElement extends ExternalLoadBalancerDe | |||||||
|     @Inject NetworkDao _networkDao; |     @Inject NetworkDao _networkDao; | ||||||
| 
 | 
 | ||||||
|     private boolean canHandle(Network config) { |     private boolean canHandle(Network config) { | ||||||
|         DataCenter zone = _configMgr.getZone(config.getDataCenterId()); |  | ||||||
|         if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) { |         if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) { | ||||||
|             s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType()); |             s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType()); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         return (_networkManager.networkIsConfiguredForExternalNetworking(zone.getId(), config.getId()) &&  |         return  (_networkManager.isProviderForNetwork(getProvider(), config.getId()) &&  | ||||||
|                 _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.Netscaler)); |                 _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.Netscaler)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -109,7 +109,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl | |||||||
|         } |         } | ||||||
|          |          | ||||||
|         if (service == null) { |         if (service == null) { | ||||||
|         	if (!_networkMgr.isProviderInNetwork(getProvider(), network.getId())) { |         	if (!_networkMgr.isProviderForNetwork(getProvider(), network.getId())) { | ||||||
|         		s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); |         		s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); | ||||||
|         		return false; |         		return false; | ||||||
|         	} |         	} | ||||||
| @ -307,12 +307,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl | |||||||
|         capabilities.put(Service.UserData, null); |         capabilities.put(Service.UserData, null); | ||||||
|         capabilities.put(Service.Dhcp, null); |         capabilities.put(Service.Dhcp, null); | ||||||
|          |          | ||||||
|         Map<Capability, String> gatewayCapabilities = new HashMap<Capability, String>(); |         capabilities.put(Service.Gateway, null); | ||||||
|         gatewayCapabilities.put(Capability.RedundantRouter, "true"); |  | ||||||
|         capabilities.put(Service.Gateway, gatewayCapabilities); |  | ||||||
|          |          | ||||||
|         Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>(); |         Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>(); | ||||||
|         sourceNatCapabilities.put(Capability.SupportedSourceNatTypes, "per account"); |         sourceNatCapabilities.put(Capability.SupportedSourceNatTypes, "per account"); | ||||||
|  |         sourceNatCapabilities.put(Capability.RedundantRouter, "true"); | ||||||
|         capabilities.put(Service.SourceNat, sourceNatCapabilities); |         capabilities.put(Service.SourceNat, sourceNatCapabilities); | ||||||
|          |          | ||||||
|         capabilities.put(Service.StaticNat, null); |         capabilities.put(Service.StaticNat, null); | ||||||
|  | |||||||
| @ -34,13 +34,12 @@ import com.cloud.event.EventUtils; | |||||||
| import com.cloud.event.EventVO; | import com.cloud.event.EventVO; | ||||||
| import com.cloud.exception.InsufficientAddressCapacityException; | import com.cloud.exception.InsufficientAddressCapacityException; | ||||||
| import com.cloud.exception.InsufficientVirtualNetworkCapcityException; | import com.cloud.exception.InsufficientVirtualNetworkCapcityException; | ||||||
| import com.cloud.network.ExternalNetworkDeviceManager; |  | ||||||
| import com.cloud.network.Network; | import com.cloud.network.Network; | ||||||
| import com.cloud.network.PhysicalNetworkVO; |  | ||||||
| import com.cloud.network.Network.State; | import com.cloud.network.Network.State; | ||||||
| import com.cloud.network.NetworkManager; | import com.cloud.network.NetworkManager; | ||||||
| import com.cloud.network.NetworkVO; | import com.cloud.network.NetworkVO; | ||||||
| import com.cloud.network.Networks.BroadcastDomainType; | import com.cloud.network.Networks.BroadcastDomainType; | ||||||
|  | import com.cloud.network.PhysicalNetworkVO; | ||||||
| import com.cloud.network.dao.NetworkDao; | import com.cloud.network.dao.NetworkDao; | ||||||
| import com.cloud.network.dao.PhysicalNetworkDao; | import com.cloud.network.dao.PhysicalNetworkDao; | ||||||
| import com.cloud.network.ovs.OvsNetworkManager; | import com.cloud.network.ovs.OvsNetworkManager; | ||||||
|  | |||||||
| @ -698,7 +698,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean isProviderInNetwork(Provider provider, long networkId) { | 	public boolean isProviderForNetwork(Provider provider, long networkId) { | ||||||
| 		// TODO Auto-generated method stub | 		// TODO Auto-generated method stub | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user