Skip to content

Commit

Permalink
Add interactive-defaults.ks to updates image
Browse files Browse the repository at this point in the history
The interactive-defaults is must have to enable testing of web ui on the
boot.iso because we don't have support for package based installations
there. This way we are serving the tarball for the VM which will be used
as payload to overcome this missing implementation.

Do not SSH the interactive-defaults.ks into the VM when it's running but
instead add the interactive-defaults.ks to the updates.img.
The SSH copy of interactive-defaults.ks works but not reliably. The
issue is that we are copying the interactive-defaults.ks to the running
installation and if the file will land too late it won't be taken by the
installer.

To avoid this issue add the interactive-defaults.ks content to the
updates image before the VM is started.
  • Loading branch information
jkonecny12 committed Oct 8, 2024
1 parent 8d9626d commit 1f42a31
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions test/machine_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import subprocess
import sys
import time
from tempfile import TemporaryDirectory

WEBUI_TEST_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.dirname(WEBUI_TEST_DIR)
Expand Down Expand Up @@ -83,10 +84,20 @@ def _serve_payload(self):

return payload_cached_name, http_payload_port

def _write_interactive_defaults_ks(self):
def _write_interactive_defaults_ks(self, updates_image):
payload_cached_name, http_payload_port = self._serve_payload()
content = f'liveimg --url="http://10.0.2.2:{http_payload_port}/{payload_cached_name}"'
Machine.execute(self, f'echo \'{content}\' > /usr/share/anaconda/interactive-defaults.ks')
defaults_path = "usr/share/anaconda/"
print("Adding interactive defaults to updates.img")
with TemporaryDirectory() as tmp_dir:
os.makedirs(f"{tmp_dir}/{defaults_path}")
# unpack initrd to the temporary directory
os.system(f"cd {tmp_dir} && gzip -dc {updates_image} | cpio -idu")
# add new interactive-defaults.ks (have to be available at start of the installer)
with open(f"{tmp_dir}/{defaults_path}/interactive-defaults.ks", "wt", encoding="utf-8") as f:
f.write(content)
# pack the updates.img again and replace the original one
os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image}")

def start(self):
update_img_file = os.path.join(ROOT_DIR, "updates.img")
Expand Down Expand Up @@ -118,6 +129,10 @@ def start(self):
else:
location = f"{iso_path}"

if not self.is_live():
# Configure the payload in interactive-defaults.ks
self._write_interactive_defaults_ks(update_img_file)

if self.efi:
boot_arg = "--boot uefi "
else:
Expand Down Expand Up @@ -153,9 +168,6 @@ def start(self):
if not self.is_live():
Machine.wait_boot(self, timeout_sec=300)

# Configure the payload in interactive-defaults.ks
self._write_interactive_defaults_ks()

for _ in range(30):
try:
Machine.execute(self, "journalctl -t anaconda | grep 'anaconda: ui.webui: cockpit web view has been started'")
Expand Down

0 comments on commit 1f42a31

Please sign in to comment.