diff options
Diffstat (limited to 'roles/sane_debian_system/subplot.py')
-rw-r--r-- | roles/sane_debian_system/subplot.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/roles/sane_debian_system/subplot.py b/roles/sane_debian_system/subplot.py index 8262479..f45eb2b 100644 --- a/roles/sane_debian_system/subplot.py +++ b/roles/sane_debian_system/subplot.py @@ -1,3 +1,6 @@ +import logging + + def host_has_package_installed(ctx, package=None): assert_eq = globals()["assert_eq"] qemu = ctx["qemu"] @@ -27,3 +30,19 @@ def host_hostname_is(ctx, hostname=None): assert_eq(exit, 0) actual = output.decode("UTF8").splitlines()[-1] assert_eq(actual, hostname) + + +def host_hostname_has_address(ctx, hostname=None, addr=None): + assert_eq = globals()["assert_eq"] + + logging.debug(f"host_hostname_has_address:") + qemu = ctx["qemu"] + output, exit = qemu.ssh(["cat", "/etc/hosts"]) + assert_eq(exit, 0) + logging.debug(f" /etc/hosts: {output!r}") + actual = output.decode("UTF8") + logging.debug(f" /etc/hosts: {actual!r}") + wordlines = [line.split() for line in actual.splitlines()] + matches = [words for words in wordlines if len(words) == 2 and words[1] == hostname] + logging.debug(f" matches: {matches!r}") + assert_eq(matches, [[addr, hostname]]) |