From d6d97c658771f75d2a1fdfeeac02ee7bfb106b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 Sep 2019 18:19:09 +0200 Subject: [PATCH] osdict: Choose the most appropriate tree when a profile is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As some OSes, as Fedora, have variants (which we rely to be standardised on osinfo-db side), let's select the most appropriate variant according to the selected profile of the unattended installation. Signed-off-by: Fabiano FidĂȘncio --- tests/osdict.py | 4 ++++ virt-install | 14 +++++++++----- virtinst/osdict.py | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/osdict.py b/tests/osdict.py index 8ffcbb34..034f22ce 100644 --- a/tests/osdict.py +++ b/tests/osdict.py @@ -61,6 +61,10 @@ class TestOSDB(unittest.TestCase): # Most generic tree URL assert "Everything" in f29.get_location("x86_64") + # Specific tree + assert "Server" in f29.get_location("x86_64", "jeos") + assert "Workstation" in f29.get_location("x86_64", "desktop") + # Has tree URLs, but none for arch try: f26.get_location("ia64") diff --git a/virt-install b/virt-install index 8efa4960..022f947d 100755 --- a/virt-install +++ b/virt-install @@ -386,9 +386,9 @@ def show_warnings(options, guest, installer, osdata): # Guest building helpers # ########################## -def get_location_for_os(guest, osname): +def get_location_for_os(guest, osname, profile=None): osinfo = virtinst.OSDB.lookup_os(osname, raise_error=True) - location = osinfo.get_location(guest.os.arch) + location = osinfo.get_location(guest.os.arch, profile) print_stdout(_("Using {osname} --location {url}").format( osname=osname, url=location)) return location @@ -399,6 +399,7 @@ def build_installer(options, guest, installdata): location = None location_kernel = None location_initrd = None + unattended_data = None extra_args = options.extra_args install_bootdev = installdata.bootdev @@ -413,8 +414,12 @@ def build_installer(options, guest, installdata): else: extra_args = [installdata.kernel_args] + if options.unattended: + unattended_data = cli.parse_unattended(options.unattended) + if install_os: - location = get_location_for_os(guest, install_os) + profile = unattended_data.profile if unattended_data else None + location = get_location_for_os(guest, install_os, profile) elif options.location: (location, location_kernel, @@ -443,8 +448,7 @@ def build_installer(options, guest, installdata): install_kernel_args=install_kernel_args, no_install=no_install) - if options.unattended: - unattended_data = cli.parse_unattended(options.unattended) + if unattended_data: installer.set_unattended_data(unattended_data) if extra_args: installer.set_extra_args(extra_args) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index eb26ddb9..a077170b 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -628,7 +628,11 @@ class _OsVariant(object): return None fallback_tree = None - if not profile: + if profile == "jeos": + profile = "Server" + elif profile == "desktop": + profile = "Workstation" + elif not profile: profile = "Everything" for tree in treelist: