Skip to content

Commit

Permalink
Differentiate iptables service according to IP family
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Reis <[email protected]>
  • Loading branch information
benjamreis committed Oct 1, 2024
1 parent fb52863 commit 0dee20d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/storage/glusterfs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from lib.common import exec_nofail, raise_errors, setup_formatted_and_mounted_disk, teardown_formatted_and_mounted_disk
from lib.netutil import is_ipv6

# explicit import for package-scope fixtures
from pkgfixtures import pool_with_saved_yum_state
Expand All @@ -14,12 +15,13 @@ def _setup_host_with_glusterfs(host):

host.yum_install(['glusterfs-server', 'xfsprogs'])

iptables = 'iptables' if is_ipv6(host.hostname_or_ip) else 'ip6tables'
for h in host.pool.hosts:
hostname_or_ip = h.hostname_or_ip
if hostname_or_ip != host.hostname_or_ip:
for port, proto in GLUSTERFS_PORTS:
host.ssh(
['iptables', '-I', 'INPUT', '-p', proto, '--dport', port, '-s', hostname_or_ip, '-j', 'ACCEPT'])
[iptables, '-I', 'INPUT', '-p', proto, '--dport', port, '-s', hostname_or_ip, '-j', 'ACCEPT'])

# Make rules reboot-persistent
for service in ['iptables', 'ip6tables']:
Expand All @@ -34,13 +36,14 @@ def _teardown_host_with_glusterfs(host):
# Remove any remaining gluster-related data to avoid issues in future test runs
errors += exec_nofail(lambda: host.ssh(['rm', '-rf', '/var/lib/glusterd']))

iptables = 'iptables' if is_ipv6(host.hostname_or_ip) else 'ip6tables'
for h in host.pool.hosts:
hostname_or_ip = h.hostname_or_ip
if hostname_or_ip != host.hostname_or_ip:
for port, proto in GLUSTERFS_PORTS:
errors += exec_nofail(
lambda: host.ssh(
['iptables', '-D', 'INPUT', '-p', proto, '--dport', port, '-s', hostname_or_ip, '-j', 'ACCEPT']
[iptables, '-D', 'INPUT', '-p', proto, '--dport', port, '-s', hostname_or_ip, '-j', 'ACCEPT']
)
)

Expand Down

0 comments on commit 0dee20d

Please sign in to comment.