summaryrefslogtreecommitdiff
path: root/roles/sane_debian_system/subplot.py
diff options
context:
space:
mode:
Diffstat (limited to 'roles/sane_debian_system/subplot.py')
-rw-r--r--roles/sane_debian_system/subplot.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/roles/sane_debian_system/subplot.py b/roles/sane_debian_system/subplot.py
new file mode 100644
index 0000000..f45eb2b
--- /dev/null
+++ b/roles/sane_debian_system/subplot.py
@@ -0,0 +1,48 @@
+import logging
+
+
+def host_has_package_installed(ctx, package=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["dpkg", "--status", package])
+ assert_eq(exit, 0)
+ installed = False
+ for line in output.decode("UTF8").splitlines():
+ if line.startswith("Status:") and " installed" in line:
+ installed = True
+ break
+ assert installed
+
+
+def host_directory_is_empty(ctx, pathname=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["find", "/etc/apt/sources.list.d"])
+ assert_eq(exit, 0)
+ for line in output.decode("UTF8").splitlines():
+ assert "/etc/apt/sources.list.d/" not in line
+
+
+def host_hostname_is(ctx, hostname=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["hostname"])
+ 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]])