[virt-tools-list] [virt-manager PATCH v3 8/9] osdict: Deal with medias' installer scripts

Fabiano Fidêncio fidencio at redhat.com
Thu Mar 7 12:52:57 UTC 2019


As medias may also have installer scripts associates to themselves and,
in this case, those should be considered instead the OS ones.

More than that, Libosinfo.Media provides an API that tells whether that
specific media supports installer scripts or not and this must be
checked as the first thing. In case no installer script is supported,
let's just error out and abort the installation.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 virtinst/osdict.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 0ef1617c..08176976 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -564,6 +564,28 @@ class _OsVariant(object):
             return installscripts[0]
 
         script_list = []
+
+        # In case we're dealing with a media installation, let's try to get
+        # the installer scripts from the media, in case any is set.
+        if media:
+            if not media.supports_installer_script():
+                raise RuntimeError(
+                    _("'%s' used media does not support unattended "
+                      "installation") % (self.name))
+
+            script_list = list(_OsinfoIter(media.get_install_script_list()))
+
+            # In case some script is set, but not one matching the specified
+            # profile, let's just error out as trying to use the OS' installer
+            # is too much error prone.
+            # However, if no script is found, let's just follow with the
+            # current code path and get the script from the installer, as some
+            # OSes only have the installer scripts set to the Libosinfo.Os
+            # itself.
+            if script_list:
+                installscript = _get_install_script(script_list)
+                return installscript
+
         if self._os:
             script_list = list(_OsinfoIter(self._os.get_install_script_list()))
 
-- 
2.20.1




More information about the virt-tools-list mailing list