Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Change handling systemd-resolved for F42. #7546

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tests/multihost/sssd/testlib/common/qe_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def service_sssd(self, action):
time.sleep(10)
return cmd.returncode
self.run_command('journalctl -xeu sssd.service', raiseonerr=False)
self.run_command('cat /var/log/sssd/sssd.log', raiseonerr=False)
madhuriupadhye marked this conversation as resolved.
Show resolved Hide resolved
raise SSSDException(f'Unable to {action} sssd', 1)

def yum_install(self, package):
Expand Down
47 changes: 30 additions & 17 deletions src/tests/multihost/sssd/testlib/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,40 @@ def service_ctrl(self, action, target_service):
target_service), 1)

def update_resolv_conf(self, ip_addr):
""" Update /etc/resolv.conf with Windows AD IP address
""" Set nameserver to specific ip address (Like AD server)

:param str ip_addr: IP Address to be added in resolv.conf
:param str ip_addr: IP Address to be set
:return: None
"""
self.multihost.log.info("Add ip addr %s in resolv.conf" % ip_addr)
nameserver = 'nameserver %s\n' % ip_addr
resolv_conf = self.multihost.get_file_contents('/etc/resolv.conf')
if isinstance(resolv_conf, bytes):
contents = resolv_conf.decode('utf-8')
self.multihost.log.info(f"Set dns to ip addr: {ip_addr}")
cmd = self.multihost.run_command(f'readlink /etc/resolv.conf', raiseonerr=False)
if 'stub-resolv.conf' in cmd.stdout_text:
# Try to change dns settings on a machine with systemd-resolved
self.set_dns_systemd_resolved(ip_addr)
else:
contents = resolv_conf
contents = nameserver + contents.replace(nameserver, '')
# Chattr will not work on symlink (like from systemd resolved)
# so we ignore result
self.multihost.run_command("chattr -i /etc/resolv.conf", raiseonerr=False)
self.multihost.put_file_contents('/etc/resolv.conf', contents)
self.multihost.run_command("chattr +i /etc/resolv.conf", raiseonerr=False)
# Try to change dns settings on a machine with systemd.resolved
change_stub = f"sed -ie 's/#\?DNS=.*/DNS={ip_addr}/' /etc/systemd/resolved.conf"
self.multihost.run_command(change_stub, raiseonerr=False)
nameserver = 'nameserver %s\n' % ip_addr
resolv_conf = self.multihost.get_file_contents('/etc/resolv.conf')
if isinstance(resolv_conf, bytes):
contents = resolv_conf.decode('utf-8')
else:
contents = resolv_conf
contents = nameserver + contents.replace(nameserver, '')
# Chattr will not work on symlink (like from systemd resolved)
# so we ignore result
self.multihost.run_command("chattr -i /etc/resolv.conf", raiseonerr=False)
self.multihost.put_file_contents('/etc/resolv.conf', contents)
self.multihost.run_command("chattr +i /etc/resolv.conf", raiseonerr=False)

def set_dns_systemd_resolved(self, ip_addr):
""" Configure systemd-resolved with an IP address

:param str ip_addr: IP Address to be used
:return: None
"""
self.multihost.log.info(f"Configuring systemd-resolved to use: {ip_addr}")
change_dns = rf"sed -ie 's/#\?DNS=.*/DNS={ip_addr}/'"
for x in ['/etc/systemd/resolved.conf', '/usr/lib/systemd/resolved.conf']:
self.multihost.run_command(f'{change_dns} {x}', raiseonerr=False)
self.multihost.run_command(
"systemctl restart systemd-resolved", raiseonerr=False
)
Expand Down
Loading