Fixed the bug when port forwarding rules were not reset correctly on domR restart/start (multiple public ip addresses case)

This commit is contained in:
alena 2011-02-15 10:44:16 -08:00
parent d9dfd37bd4
commit 9c2db92b63
3 changed files with 12 additions and 10 deletions

View File

@ -36,7 +36,7 @@ public interface FirewallRulesDao extends GenericDao<FirewallRuleVO, Long> {
boolean releasePorts(long ipAddressId, String protocol, FirewallRule.Purpose purpose, int[] ports);
List<FirewallRuleVO> listByIpAndPurpose(long ipAddressId, FirewallRule.Purpose purpose);
List<? extends FirewallRule> listByIpAndPurpose(long ipAddressId, FirewallRule.Purpose purpose);
List<FirewallRuleVO> listByNetworkIdAndPurpose(long networkId, FirewallRule.Purpose purpose);

View File

@ -1023,7 +1023,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
}
s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + router.getId() + " start.");
s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + router + " start.");
if (!publicIps.isEmpty()) {
@ -1031,13 +1031,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
createAssociateIPCommands(router, publicIps, cmds, 0);
List<RemoteAccessVpn> vpns = new ArrayList<RemoteAccessVpn>();
List<? extends PortForwardingRule> pfRules = null;
List<? extends FirewallRule> staticNatFirewallRules = null;
List<PortForwardingRule> pfRules = new ArrayList<PortForwardingRule>();
List<FirewallRule> staticNatFirewallRules = new ArrayList<FirewallRule>();
for (PublicIpAddress ip : publicIps) {
pfRules = _pfRulesDao.listForApplication(ip.getId());
staticNatFirewallRules = _rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat);
pfRules.addAll(_pfRulesDao.listForApplication(ip.getId()));
staticNatFirewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat));
RemoteAccessVpn vpn = _vpnDao.findById(ip.getId());
if (vpn != null) {
vpns.add(vpn);

View File

@ -629,7 +629,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
@Override
public boolean applyStaticNatRules(long sourceIpId, boolean continueOnError, Account caller){
List<FirewallRuleVO> rules = _firewallDao.listByIpAndPurpose(sourceIpId, Purpose.StaticNat);
List<? extends FirewallRule> rules = _firewallDao.listByIpAndPurpose(sourceIpId, Purpose.StaticNat);
List<StaticNatRule> staticNatRules = new ArrayList<StaticNatRule>();
if (rules.size() == 0) {
@ -637,7 +637,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
return true;
}
for (FirewallRuleVO rule : rules) {
for (FirewallRule rule : rules) {
IpAddress sourceIp = _ipAddressDao.findById(rule.getSourceIpAddressId());
UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
@ -650,7 +650,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
throw new CloudRuntimeException("Unable to find ip address to map to in vm id=" + vm.getId());
}
staticNatRules.add(new StaticNatRuleImpl(rule, dstIp.addr()));
FirewallRuleVO ruleVO = _firewallDao.findById(rule.getId());
staticNatRules.add(new StaticNatRuleImpl(ruleVO, dstIp.addr()));
}
if (caller != null) {