mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-15243: Add service combination check at create network offering
This commit is contained in:
parent
70d0ff8b06
commit
46a12b378c
@ -18,6 +18,7 @@ package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -131,5 +132,5 @@ public interface NetworkElement extends Adapter {
|
||||
* @param services
|
||||
* @return true/false
|
||||
*/
|
||||
boolean verifyServicesCombination(List<String> services);
|
||||
boolean verifyServicesCombination(Set<Service> services);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ package com.cloud.network.element;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -132,7 +133,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -453,7 +453,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -528,7 +528,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ package com.cloud.network.element;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -591,15 +592,19 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
List<String> netscalerServices = new ArrayList<String>();
|
||||
netscalerServices.add(Service.Lb.getName());
|
||||
netscalerServices.add(Service.StaticNat.getName());
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
Set<Service> netscalerServices = new HashSet<Service>();
|
||||
netscalerServices.add(Service.Lb);
|
||||
netscalerServices.add(Service.StaticNat);
|
||||
|
||||
// NetScaler can only act as Lb and Static Nat service provider
|
||||
if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) {
|
||||
String servicesList = "";
|
||||
for (Service service : services) {
|
||||
servicesList += service.getName() + " ";
|
||||
}
|
||||
s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination "
|
||||
+ services + " is not supported.");
|
||||
+ servicesList + " is not supported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -781,4 +786,4 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ejb.Local;
|
||||
@ -297,7 +298,7 @@ public class NiciraNvpElement extends AdapterBase implements ConnectivityProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -514,5 +515,5 @@ public class NiciraNvpElement extends AdapterBase implements ConnectivityProvide
|
||||
}
|
||||
return new DeleteHostAnswer(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -130,7 +131,7 @@ public class OvsElement extends AdapterBase implements NetworkElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6355,14 +6355,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
l.add(service);
|
||||
}
|
||||
|
||||
for (String provider : providerSvcs.keySet()) {
|
||||
NetworkElement element = getElementImplementingProvider(provider);
|
||||
List<String> services = providerSvcs.get(provider);
|
||||
if (!element.verifyServicesCombination(services)) {
|
||||
throw new UnsupportedServiceException("Provider " + provider + " doesn't support services combination: " + services);
|
||||
}
|
||||
}
|
||||
|
||||
return svcProviders;
|
||||
}
|
||||
|
||||
@ -6459,11 +6451,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
+ provider.getName());
|
||||
}
|
||||
}
|
||||
List<String> serviceList = new ArrayList<String>();
|
||||
for (Service service : enabledServices) {
|
||||
// check if the service is provided by this Provider
|
||||
if (!element.getCapabilities().containsKey(service)) {
|
||||
throw new UnsupportedServiceException(provider.getName() + " Provider cannot provide service " + service.getName());
|
||||
}
|
||||
serviceList.add(service.getName());
|
||||
}
|
||||
if (!element.verifyServicesCombination(enabledServices)) {
|
||||
throw new UnsupportedServiceException("Provider " + provider.getName() + " doesn't support services combination: " + serviceList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -122,7 +123,7 @@ public class BareMetalElement extends AdapterBase implements NetworkElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.network.element;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -240,7 +241,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.network.element;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -146,7 +147,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.network.element;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -105,7 +106,7 @@ public class SecurityGroupElement extends AdapterBase implements NetworkElement
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -812,11 +812,16 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
if (!services.contains("SourceNat")) {
|
||||
if (services.contains("StaticNat") || services.contains("Firewall") || services.contains("Lb") || services.contains("PortForwarding") ||
|
||||
services.contains("Vpn")) {
|
||||
s_logger.warn("Virtual router can't enable services " + services + " without source NAT service");
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
if (!services.contains(Service.SourceNat)) {
|
||||
if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
|
||||
services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
|
||||
String servicesList = "[";
|
||||
for (Service service : services) {
|
||||
servicesList += service.getName() + " ";
|
||||
}
|
||||
servicesList += "]";
|
||||
s_logger.warn("Virtual router can't enable services " + servicesList + " without source NAT service");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user