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
changes/32/518332/5
david shaughnessy 5 years ago committed by David Shaughnessy
parent 7af69eb662
commit c135c5672a
  1. 2
      neutron/agent/linux/openvswitch_firewall/iptables.py
  2. 12
      neutron/tests/unit/agent/linux/openvswitch_firewall/test_iptables.py

@ -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()

@ -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()

Loading…
Cancel
Save