Add support for multiple networks in the 'per account' source nat type setting in external network devices

Signed-off-by: Sheng Yang <sheng.yang@citrix.com>
This commit is contained in:
Will Stevens  2013-10-30 10:14:14 -07:00 committed by Sheng Yang
parent a6b6fa65fa
commit 8871cdc03a

View File

@ -434,17 +434,20 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
IPAddressVO sourceNatIp = null;
if (!sharedSourceNat) {
// Get the source NAT IP address for this account
// Get the source NAT IP address for this network
List<? extends IpAddress> sourceNatIps = _networkModel.listPublicIpsAssignedToAccount(network.getAccountId(),
zoneId, true);
if (sourceNatIps.size() != 1) {
String errorMsg = "External firewall was unable to find the source NAT IP address for account "
+ account.getAccountName();
for (IpAddress ipAddress : sourceNatIps) {
if (ipAddress.getAssociatedWithNetworkId().longValue() == network.getId()) {
sourceNatIp = _ipAddressDao.findById(ipAddress.getId());
break;
}
}
if (sourceNatIp == null) {
String errorMsg = "External firewall was unable to find the source NAT IP address for network " + network.getName();
s_logger.error(errorMsg);
return true;
} else {
sourceNatIp = _ipAddressDao.findById(sourceNatIps.get(0).getId());
}
}