broken HybridIptablesHelper function override

When creating the hybrid firewall helper class the
_remove_conntrack_entries_from_port_deleted function is
overloaded, when overloaded it does not have a "self" parameter
and fails when it's called by the neutron agent.

This patch adds in the self parameter and adds a test to
ensure it is correctly overloaded.

Related-bug: 1721895

Change-Id: Ifc6c8510f70e9336fbf626db8bbacf206ad0d08c
This commit is contained in:
david shaughnessy 2017-11-07 13:25:13 +00:00 committed by David Shaughnessy
parent 7af69eb662
commit c135c5672a
2 changed files with 13 additions and 1 deletions

View File

@ -27,7 +27,7 @@ def get_iptables_driver_instance():
class HybridIptablesHelper(
iptables_firewall.OVSHybridIptablesFirewallDriver):
"""Don't remove conntrack when removing iptables rules."""
def _remove_conntrack_entries_from_port_deleted(port):
def _remove_conntrack_entries_from_port_deleted(self, port):
pass
return HybridIptablesHelper()

View File

@ -100,3 +100,15 @@ class TestHelper(base.BaseTestCase):
self.helper.hybrid_ports = {'qvoanother'}
self.helper.cleanup_port({'device': 'port'})
self.assertFalse(self.helper.iptables_driver.remove_port_filter.called)
class TestHybridIptablesHelper(base.BaseTestCase):
def test_overloaded_remove_conntrack(self):
with mock.patch.object(iptables_firewall.IptablesFirewallDriver,
'_remove_conntrack_entries_from_port_deleted') as rcefpd, \
mock.patch("neutron.agent.linux.ip_conntrack.IpConntrackManager"
"._populate_initial_zone_map"):
firewall = iptables.get_iptables_driver_instance()
firewall._remove_conntrack_entries_from_port_deleted(None)
rcefpd.assert_not_called()