Skip to content

Commit

Permalink
Tests: Handle dns with systemd resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-vavra-cz committed Sep 6, 2023
1 parent a550c63 commit 8e0f662
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tests/multihost/sssd/testlib/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def update_resolv_conf(self, ip_addr):
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)
self.multihost.run_command(
"systemctl restart systemd-resolved", raiseonerr=False
)

def update_etc_hosts(self, ip_addr, hostname):
""" Update /etc/hosts with ipaddress and hostname
Expand Down Expand Up @@ -402,7 +408,6 @@ def realm_join(self, domainname, admin_password,
f'--server-software={server_software} ' \
f'--membership-software={membership_software} -v'
print(realm_cmd)
self.multihost.run_command("cat /etc/krb5.conf", raiseonerr=False)
cmd = self.multihost.run_command(realm_cmd, stdin_text=admin_password,
raiseonerr=False)
if cmd.returncode == 124:
Expand All @@ -412,6 +417,8 @@ def realm_join(self, domainname, admin_password,
self.service_ctrl('stop', 'realmd')
raise SSSDException(f"realm join timed out! {cmd.stderr_text}")
elif cmd.returncode != 0:
self.multihost.run_command("cat /etc/krb5.conf", raiseonerr=False)
self.multihost.run_command("resolvectl dns", raiseonerr=False)
raise SSSDException("Error: %s" % cmd.stderr_text)
else:
return cmd.stderr_text
Expand Down

0 comments on commit 8e0f662

Please sign in to comment.