use of com.cloud.network.Network.Capability in project cloudstack by apache.
the class ConfigurationManagerImpl method validateSourceNatServiceCapablities.
void validateSourceNatServiceCapablities(final Map<Capability, String> sourceNatServiceCapabilityMap) {
if (sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) {
if (sourceNatServiceCapabilityMap.keySet().size() > 2) {
throw new InvalidParameterValueException("Only " + Capability.SupportedSourceNatTypes.getName() + " and " + Capability.RedundantRouter + " capabilities can be sepcified for source nat service");
}
for (final Map.Entry<Capability, String> srcNatPair : sourceNatServiceCapabilityMap.entrySet()) {
final Capability capability = srcNatPair.getKey();
final String value = srcNatPair.getValue();
if (capability == Capability.SupportedSourceNatTypes) {
final boolean perAccount = value.contains("peraccount");
final boolean perZone = value.contains("perzone");
if (perAccount && perZone || !perAccount && !perZone) {
throw new InvalidParameterValueException("Either peraccount or perzone source NAT type can be specified for " + Capability.SupportedSourceNatTypes.getName());
}
} else if (capability == Capability.RedundantRouter) {
final boolean enabled = value.contains("true");
final 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 source nat service");
}
}
}
}
use of com.cloud.network.Network.Capability in project cloudstack by apache.
the class ConfigurationManagerImpl method validateStaticNatServiceCapablities.
void validateStaticNatServiceCapablities(final Map<Capability, String> staticNatServiceCapabilityMap) {
if (staticNatServiceCapabilityMap != null && !staticNatServiceCapabilityMap.isEmpty()) {
boolean eipEnabled = false;
boolean associatePublicIP = true;
for (final Capability capability : staticNatServiceCapabilityMap.keySet()) {
final String value = staticNatServiceCapabilityMap.get(capability).toLowerCase();
if (!(value.contains("true") ^ value.contains("false"))) {
throw new InvalidParameterValueException("Unknown specified value (" + value + ") for " + capability);
}
if (capability == Capability.ElasticIp) {
eipEnabled = value.contains("true");
} else if (capability == Capability.AssociatePublicIP) {
associatePublicIP = value.contains("true");
} else {
throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " and " + Capability.AssociatePublicIP.getName() + " capabilitiy can be sepcified for static nat service");
}
}
if (!eipEnabled && associatePublicIP) {
throw new InvalidParameterValueException("Capability " + Capability.AssociatePublicIP.getName() + " can only be set when capability " + Capability.ElasticIp.getName() + " is true");
}
}
}
use of com.cloud.network.Network.Capability in project cloudstack by apache.
the class ConfigurationManagerImpl method validateLoadBalancerServiceCapabilities.
void validateLoadBalancerServiceCapabilities(final Map<Capability, String> lbServiceCapabilityMap) {
if (lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) {
if (lbServiceCapabilityMap.keySet().size() > 3 || !lbServiceCapabilityMap.containsKey(Capability.SupportedLBIsolation)) {
throw new InvalidParameterValueException("Only " + Capability.SupportedLBIsolation.getName() + ", " + Capability.ElasticLb.getName() + ", " + Capability.InlineMode.getName() + " capabilities can be sepcified for LB service");
}
for (final Capability cap : lbServiceCapabilityMap.keySet()) {
final String value = lbServiceCapabilityMap.get(cap);
if (cap == Capability.SupportedLBIsolation) {
final boolean dedicatedLb = value.contains("dedicated");
final boolean sharedLB = value.contains("shared");
if (dedicatedLb && sharedLB || !dedicatedLb && !sharedLB) {
throw new InvalidParameterValueException("Either dedicated or shared isolation can be specified for " + Capability.SupportedLBIsolation.getName());
}
} else if (cap == Capability.ElasticLb) {
final boolean enabled = value.contains("true");
final boolean disabled = value.contains("false");
if (!enabled && !disabled) {
throw new InvalidParameterValueException("Unknown specified value for " + Capability.ElasticLb.getName());
}
} else if (cap == Capability.InlineMode) {
final boolean enabled = value.contains("true");
final boolean disabled = value.contains("false");
if (!enabled && !disabled) {
throw new InvalidParameterValueException("Unknown specified value for " + Capability.InlineMode.getName());
}
} else if (cap == Capability.LbSchemes) {
final boolean internalLb = value.contains("internal");
final boolean publicLb = value.contains("public");
if (!internalLb && !publicLb) {
throw new InvalidParameterValueException("Unknown specified value for " + Capability.LbSchemes.getName());
}
} else {
throw new InvalidParameterValueException("Only " + Capability.SupportedLBIsolation.getName() + ", " + Capability.ElasticLb.getName() + ", " + Capability.InlineMode.getName() + ", " + Capability.LbSchemes.getName() + " capabilities can be sepcified for LB service");
}
}
}
}
Aggregations