From 200f8e4d14b1434dfc064fee4c5c167d96394ecd Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 17 Jan 2012 01:02:51 -0800 Subject: [PATCH] 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 --- server/src/com/cloud/network/NetworkManagerImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index f225ff39ff1..3bf308b3371 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -640,18 +640,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Map> ipToServices = new HashMap>(); if (publicIps != null && !publicIps.isEmpty()) { - boolean gotSNAT = false; + Set networkSNAT = new HashSet(); for (PublicIp ip : publicIps) { Set services = ipToServices.get(ip); if (services == null) { services = new HashSet(); } 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()) {