Browse Source

Merge "Fix "_get_sg_members" method" into stable/victoria

changes/26/785926/1
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
e709b00f3e
2 changed files with 18 additions and 1 deletions
  1. +2
    -1
      neutron/agent/linux/iptables_firewall.py
  2. +16
    -0
      neutron/tests/unit/agent/linux/test_iptables_firewall.py

+ 2
- 1
neutron/agent/linux/iptables_firewall.py View File

@ -992,7 +992,8 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
self._clean_deleted_remote_sg_members_conntrack_entries()
def _get_sg_members(self, sg_info, sg_id, ethertype):
return set(sg_info.get(sg_id, {}).get(ethertype, []))
ip_mac_addresses = sg_info.get(sg_id, {}).get(ethertype, [])
return set([ip_mac[0] for ip_mac in ip_mac_addresses])
def filter_defer_apply_off(self):
if self._defer_apply:


+ 16
- 0
neutron/tests/unit/agent/linux/test_iptables_firewall.py View File

@ -2086,6 +2086,22 @@ class IptablesFirewallTestCase(BaseIptablesFirewallTestCase):
mock.call.add_rule('sg-chain', '-j ACCEPT')]
self.v4filter_inst.assert_has_calls(calls)
def test__get_sg_members(self):
sg_info = {_uuid(): {constants.IPv4: [['ip1', None]],
constants.IPv6: []},
_uuid(): {constants.IPv4: [['ip2', None], ['ip3', None]],
constants.IPv6: [['ip4', None]]},
}
sg_ids = list(sg_info.keys())
self.assertEqual({'ip1'}, self.firewall._get_sg_members(
sg_info, sg_ids[0], constants.IPv4))
self.assertEqual(set([]), self.firewall._get_sg_members(
sg_info, sg_ids[0], constants.IPv6))
self.assertEqual({'ip2', 'ip3'}, self.firewall._get_sg_members(
sg_info, sg_ids[1], constants.IPv4))
self.assertEqual({'ip4'}, self.firewall._get_sg_members(
sg_info, sg_ids[1], constants.IPv6))
class IptablesFirewallEnhancedIpsetTestCase(BaseIptablesFirewallTestCase):
def setUp(self):


Loading…
Cancel
Save