Blob Blame History Raw
From ec270ec272eb6986b4967df63e74ee60656e1e12 Mon Sep 17 00:00:00 2001
Message-Id: <ec270ec272eb6986b4967df63e74ee60656e1e12@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
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

From: Fabiano FidĂȘncio <fidencio@redhat.com>

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 <fidencio@redhat.com>
(cherry picked from commit d6d97c658771f75d2a1fdfeeac02ee7bfb106b88)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749865

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 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 9fb477bd..9058b39e 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 af6c75bf..009d03e1 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 a53e4249..ad2a7f2d 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -600,7 +600,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:
-- 
2.23.0