diff options
| author | alex <alex@pdp7.net> | 2026-12-05 22:09:29 +0100 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2026-12-06 13:23:04 +0100 |
| commit | dd2a87b5291acdf9c207d5e20eee603c6a1ab4ae (patch) | |
| tree | 92d699d7f2faee09ae0dfd337cef02b17d8284c9 /workstation/test.py | |
| parent | 6e6fc68fee5783e391d8b921ca44b90aeb67223c (diff) | |
WIP
Somewhat blocked by https://bugzilla.redhat.com/show_bug.cgi?id=2521543
Diffstat (limited to 'workstation/test.py')
| -rwxr-xr-x | workstation/test.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/workstation/test.py b/workstation/test.py new file mode 100755 index 00000000..467c0fb5 --- /dev/null +++ b/workstation/test.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +import os +import pathlib +import subprocess +import time + + +INSTANCE_NAME="workstation-test" +USER="alex" + +THIS_REPO = pathlib.Path(__file__).parent.parent +THIS_UID = os.getuid() + + +def _(*args, check=True, input=None): + return subprocess.run(args, check=check, input=input, text=True) + + +_("incus", "launch", + "images:debian/13", + INSTANCE_NAME, + "--ephemeral", + "--vm", + "-c", "limits.cpu=4", + "-c", "limits.memory=6GiB", + "-d", "root,size=50GiB") + +while _("incus", "exec", INSTANCE_NAME, "uptime", check=False).returncode != 0: + print("waiting...") + time.sleep(1) + +_("incus", "config", "device", "add", INSTANCE_NAME, "here", "disk", f"source={THIS_REPO}", "path=/here") +_("incus", "exec", INSTANCE_NAME, "--", "apt", "full-upgrade", "-U") +_("incus", "exec", INSTANCE_NAME, "--", "apt", "install", "-y", "python3") +_("incus", "exec", INSTANCE_NAME, "--", "/here/workstation/root-setup.py") +_("incus", "exec", INSTANCE_NAME, "--", "adduser", USER, "--disabled-password", "--comment", "") +_("incus", "exec", INSTANCE_NAME, "--", "passwd", USER, "--stdin", input=USER) + +# Comment out to test with real repo +_("incus", "exec", INSTANCE_NAME, "--", "mount", "/here/", f"/home/{USER}/git/alexpdp7/", "-o", f"bind,X-mount.idmap={THIS_UID}:1000:1") + +_("incus", "exec", INSTANCE_NAME, "--", "sudo", "-u", USER, "/here/workstation/user-setup.py") |
