mirror of https://github.com/apache/cloudstack.git
CS-15243: Add service combination check at create network offering
This commit is contained in:
parent
acd9f4887f
commit
20f4b6a386
|
|
@ -14,6 +14,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;
|
||||
|
|
@ -133,5 +134,5 @@ public interface NetworkElement extends Adapter {
|
|||
* @param services
|
||||
* @return true/false
|
||||
*/
|
||||
boolean verifyServicesCombination(List<String> services);
|
||||
boolean verifyServicesCombination(Set<Service> services);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6748,14 +6748,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;
|
||||
}
|
||||
|
||||
|
|
@ -6852,11 +6844,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
+ provider.getName(), null);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ package com.cloud.network.element;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -118,7 +119,7 @@ public class BareMetalElement extends AdapterBase implements NetworkElement {
|
|||
}
|
||||
|
||||
@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.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
|||
}
|
||||
|
||||
@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.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -233,7 +234,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
|
|||
}
|
||||
|
||||
@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.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, Junip
|
|||
}
|
||||
|
||||
@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;
|
||||
|
|
@ -543,15 +544,19 @@ StaticNatServiceProvider {
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ package com.cloud.network.element;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -126,7 +127,7 @@ public class OvsElement extends AdapterBase implements NetworkElement {
|
|||
}
|
||||
|
||||
@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.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ public class SecurityGroupElement extends AdapterBase implements NetworkElement
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -869,11 +869,16 @@ LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServ
|
|||
}
|
||||
|
||||
@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…
Reference in New Issue