Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL path for reanaconda #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions reanaconda/reanaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

import docopt

from urllib.error import HTTPError

QEMU_SENSIBLE_ARGUMENTS = [
'-enable-kvm', '-machine', 'q35', '-cpu', 'host', '-smp', '2', '-m', '2G',
'-object', 'rng-random,id=rng0,filename=/dev/urandom',
Expand All @@ -63,6 +65,18 @@
CMDLINE_KICKSTART = 'inst.ks=http://10.0.2.22/kickstart'


def check_dependencies():
ok = True
if not shutil.which("qemu-system-x86_64"):
print("'qemu-system-x86_64' needs to be installed!", file=sys.stderr)
ok = False
if not shutil.which("qemu-img"):
print("'qemu-img' needs to be installed!", file=sys.stderr)
ok = False

return ok


class DaemonHTTPServer(http.server.HTTPServer, socketserver.ThreadingMixIn):
daemon_threads = True

Expand Down Expand Up @@ -200,8 +214,7 @@ def prime(qemu_args, append, fetch_from=None):
'reanaconda/disk.img', '20G'])

if fetch_from:
_download(f'{fetch_from}/isolinux/vmlinuz', 'reanaconda/vmlinuz')
_download(f'{fetch_from}/isolinux/initrd.img', 'reanaconda/initrd.img')
_fetch_boot_files(fetch_from)
qemu_args += ['-kernel', 'reanaconda/vmlinuz',
'-initrd', 'reanaconda/initrd.img']
append += f' inst.stage2={fetch_from}'
Expand Down Expand Up @@ -229,6 +242,16 @@ def cb():
saving_done.wait()
print('exiting')

def _fetch_boot_files(url):
try:
_download(f'{url}/images/pxeboot/vmlinuz', 'reanaconda/vmlinuz')
_download(f'{url}/images/pxeboot/initrd.img', 'reanaconda/initrd.img')
except HTTPError as ex:
print(f"Can't download {url}: {ex}")
print(f"Trying older isolinux/ path instead")
_download(f'{url}/isolinux/vmlinuz', 'reanaconda/vmlinuz')
_download(f'{url}/isolinux/initrd.img', 'reanaconda/initrd.img')


def updates(updates_img, kickstart=None):
if not os.path.isdir('reanaconda'):
Expand All @@ -250,6 +273,9 @@ def cleanup():


if __name__ == '__main__':
# early quit if dependencies are not installed in the system
check_dependencies()

if len(sys.argv) < 2 or '--help' in sys.argv:
print(__doc__)
sys.exit(1)
Expand Down