bug 13100: Handle the multiply source nat for different network

The original method of testing source nat didn't consider the situation that
multiply source nat ip can be passed into the function because they belonged to
the different networks.

status 13100: resolved fixed
This commit is contained in:
Sheng Yang 2012-01-17 01:02:51 -08:00
parent 550a0f98a9
commit 200f8e4d14
1 changed files with 4 additions and 4 deletions

View File

@ -640,18 +640,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Map<PublicIp, Set<Service>> ipToServices = new HashMap<PublicIp, Set<Service>>();
if (publicIps != null && !publicIps.isEmpty()) {
boolean gotSNAT = false;
Set<Long> networkSNAT = new HashSet<Long>();
for (PublicIp ip : publicIps) {
Set<Service> services = ipToServices.get(ip);
if (services == null) {
services = new HashSet<Service>();
}
if (ip.isSourceNat()) {
if (!gotSNAT) {
if (!networkSNAT.contains(ip.getAssociatedWithNetworkId())) {
services.add(Service.SourceNat);
gotSNAT = true;
networkSNAT.add(ip.getAssociatedWithNetworkId());
} else {
throw new CloudRuntimeException("Multiply generic source NAT IPs provided!");
throw new CloudRuntimeException("Multiply generic source NAT IPs provided for network " + ip.getAssociatedWithNetworkId());
}
}
if (ip.isOneToOneNat()) {