def delete_entries(self, rules, namespace): rule_filters = (self._get_filter_from_rule(r) for r in rules) rule_filters = sorted(rule_filters) entries = nl_lib.list_entries(namespace) delete_entries = self._get_entries_to_delete(rule_filters, entries) if delete_entries: nl_lib.delete_entries(delete_entries, namespace)
def delete_entries(self, rules, namespace): rule_filters = (self._get_filter_from_rule(r) for r in rules) rule_filters = sorted(rule_filters) entries = nl_lib.list_entries(namespace) delete_entries = self._get_entries_to_delete(rule_filters, entries) if delete_entries: nl_lib.delete_entries(delete_entries, namespace)
def test_list_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name self._create_entries(namespace, CONNTRACK_CMDS) expected = ((4, 'icmp', 8, 0, '1.1.1.1', '2.2.2.2', 3333), (4, 'tcp', 1, 2, '1.1.1.1', '2.2.2.2'), (4, 'udp', 1, 2, '1.1.1.1', '2.2.2.2')) entries_list = nl_lib.list_entries(namespace=namespace) self.assertEqual(expected, entries_list)
def test_list_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name _create_entries(namespace, self.CONNTRACK_CMDS) expected = ( (4, 'icmp', 8, 0, '1.1.1.1', '2.2.2.2', 3333), (6, 'icmpv6', 128, 0, '10::10', '20::20', 3456), ) entries_list = nl_lib.list_entries(namespace=namespace) self.assertEqual(expected, entries_list)
def test_list_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name _create_entries(namespace, self.CONNTRACK_CMDS) expected = ( (4, 'icmp', 8, 0, '1.1.1.1', '2.2.2.2', 3333), (6, 'icmpv6', 128, 0, '10::10', '20::20', 3456), ) entries_list = nl_lib.list_entries(namespace=namespace) self.assertEqual(expected, entries_list)
def test_list_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name _create_entries(namespace, self.CONNTRACK_CMDS) expected = ( (4, 'icmp', 8, 0, '1.1.1.1', '2.2.2.2', 3333), (4, 'tcp', 1, 2, '1.1.1.1', '2.2.2.2'), (4, 'udp', 1, 2, '1.1.1.1', '2.2.2.2') ) entries_list = nl_lib.list_entries(namespace=namespace) self.assertEqual(expected, entries_list)
def _delete_entry(self, delete_entries, remain_entries): namespace = self.useFixture(net_helpers.NamespaceFixture()).name self._create_entries(namespace, CONNTRACK_CMDS) nl_lib.delete_entries(namespace=namespace, entries=delete_entries) entries_list = nl_lib.list_entries(namespace) self.assertEqual(remain_entries, entries_list)
def test_flush_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name self._create_entries(namespace, CONNTRACK_CMDS) nl_lib.flush_entries(namespace) entries_list = nl_lib.list_entries(namespace) self.assertEqual((), entries_list)
def _delete_entry(self, delete_entries, remain_entries): namespace = self.useFixture(net_helpers.NamespaceFixture()).name _create_entries(namespace, self.CONNTRACK_CMDS) nl_lib.delete_entries(namespace=namespace, entries=delete_entries) entries_list = nl_lib.list_entries(namespace) self.assertEqual(remain_entries, entries_list)
def test_flush_entries(self): namespace = self.useFixture(net_helpers.NamespaceFixture()).name _create_entries(namespace, self.CONNTRACK_CMDS) nl_lib.flush_entries(namespace) entries_list = nl_lib.list_entries(namespace) self.assertEqual((), entries_list)