Skip to content

Commit

Permalink
Merge pull request #463 from jkonecny12/main-add-interactive-defaults…
Browse files Browse the repository at this point in the history
…-to-updates-image

Add interactive-defaults.ks to updates image
  • Loading branch information
KKoukiou authored Oct 9, 2024
2 parents 1e25fb2 + 48378d0 commit f34b479
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ $(UPDATES_IMG): prepare-test-deps
test/prepare-updates-img

create-updates.img: bots
-rm $(UPDATES_IMG)
-rm *updates.img
make $(UPDATES_IMG)

test/reference: test/common
Expand Down
36 changes: 24 additions & 12 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,22 +84,36 @@ 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, updates_image_edited):
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_edited}")

def start(self):
update_img_file = os.path.join(ROOT_DIR, "updates.img")
if not os.path.exists(update_img_file):
raise FileNotFoundError("Missing updates.img file")

self.http_updates_img_port = self._serve_updates_img()

self.payload_path = os.path.join(BOTS_DIR, "./images/fedora-rawhide-anaconda-payload")
if not os.path.exists(self.payload_path):
raise FileNotFoundError(f"Missing payload file {self.payload_path}; use 'make payload'.")

update_img_global_file = os.path.join(ROOT_DIR, "updates.img")
update_img_file = os.path.join(ROOT_DIR, self.label + "-updates.img")
if not os.path.exists(update_img_global_file):
raise FileNotFoundError("Missing updates.img file")

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

self.http_updates_img_port = self._serve_updates_img()

iso_path = f"{os.getcwd()}/bots/images/{self.image}"
extra_args = ""
Expand Down Expand Up @@ -136,7 +151,7 @@ def start(self):
"--noautoconsole "
f"--graphics vnc,listen={self.ssh_address} "
"--extra-args "
f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/updates.img' "
f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/{self.label}-updates.img' "
"--network none "
f"--qemu-commandline="
"'-netdev user,id=hostnet0,"
Expand All @@ -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 f34b479

Please sign in to comment.