[virt-manager PATCH 11/12] unattended: Deal with multiple install scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Windows(es) may provide more than one installer script. Those scripts
are used to perform pre/post installation of drivers.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 virtinst/installer.py          | 16 ++++++++++------
 virtinst/installertreemedia.py | 18 ++++++++++--------
 virtinst/osdict.py             |  5 ++---
 virtinst/unattended.py         | 30 ++++++++++++++++++------------
 4 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/virtinst/installer.py b/virtinst/installer.py
index 642d14b3..7816b45e 100644
--- a/virtinst/installer.py
+++ b/virtinst/installer.py
@@ -230,17 +230,21 @@ class Installer(object):
         elif self._unattended_data:
             osguess = OSDB.guess_os_by_iso(self.cdrom)
             osmedia = OsMedia(osguess[1])
-            script = unattended.prepare_install_script(
+            paths = []
+            scripts = unattended.prepare_install_script(
                     guest, self._unattended_data, self.cdrom, osmedia)
-            path, _ = unattended.generate_install_script(script)
-            logging.debug("Generated unattended script: %s", path)
-            logging.debug("Generated script contents:\n%s",
-                    open(path).read())
+            for script in scripts:
+                path, _ = unattended.generate_install_script(script)
+                logging.debug("Generated unattended script: %s", path)
+                logging.debug("Generated script contents:\n%s",
+                        open(path).read())
+                paths.append(path)
 
             cdrom = perform_cdrom_injections()
             self._add_unattended_cdrom_device(guest, cdrom)
 
-            self._unattended_files.extend([path, cdrom])
+            self._unattended_files.extend(paths)
+            self._unattended_files.append(cdrom)
 
     def _cleanup(self, guest):
         if self._treemedia:
diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
index adfc0aca..12a79735 100644
--- a/virtinst/installertreemedia.py
+++ b/virtinst/installertreemedia.py
@@ -184,17 +184,19 @@ class InstallerTreeMedia(object):
 
         if self._unattended_data:
             location = self.location if self._media_type == MEDIA_URL else None
-            script = unattended.prepare_install_script(
+            path = []
+            scripts = unattended.prepare_install_script(
                     guest, self._unattended_data, location, cache.os_media)
-            path, cmdline = unattended.generate_install_script(script)
+            for script in scripts:
+                path, cmdline = unattended.generate_install_script(script)
 
-            logging.debug("Generated unattended cmdline: %s", cmdline)
-            logging.debug("Generated unattended script: %s", path)
-            logging.debug("Generated script contents:\n%s",
-                    open(path).read())
+                logging.debug("Generated unattended cmdline: %s", cmdline)
+                logging.debug("Generated unattended script: %s", path)
+                logging.debug("Generated script contents:\n%s",
+                        open(path).read())
 
-            self.initrd_injections.append(path)
-            self._tmpfiles.append(path)
+                self.initrd_injections.append(path)
+                self._tmpfiles.append(path)
 
         k, i, a = self._prepare_kernel_url(guest, fetcher)
 
diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 31446380..db7f38ae 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -620,9 +620,8 @@ class _OsVariant(object):
 
             # Some OSes (as Windows) have more than one installer script,
             # depending on the OS version and profile chosen, to be used to
-            # perform the unattended installation. Let's just deal with
-            # multiple installer scripts when its actually needed, though.
-            return installscripts[0]
+            # perform the unattended installation.
+            return installscripts
 
         script_list = []
 
diff --git a/virtinst/unattended.py b/virtinst/unattended.py
index 573289c2..b772d538 100644
--- a/virtinst/unattended.py
+++ b/virtinst/unattended.py
@@ -246,22 +246,28 @@ def prepare_install_script(guest, unattended_data, url=None, os_media=None):
 
         return "network" if os_media.requires_internet() else "media"
 
-    rawscript = guest.osinfo.get_install_script(unattended_data.profile,
+    scripts = []
+
+    rawscripts = guest.osinfo.get_install_script(unattended_data.profile,
             os_media)
-    script = OSInstallScript(rawscript, guest.osinfo)
 
-    # For all tree based installations we're going to perform initrd injection
-    # and install the systems via network.
-    injection_method = "cdrom" if guest.osinfo.is_windows() else "initrd"
-    script.set_preferred_injection_method(injection_method)
+    for rawscript in rawscripts:
+        script = OSInstallScript(rawscript, guest.osinfo)
+
+        # For all tree based installations we're going to perform initrd
+        # injection and install the systems via network.
+        injection_method = "cdrom" if guest.osinfo.is_windows() else "initrd"
+        script.set_preferred_injection_method(injection_method)
+
+        installationsource = _get_installation_source(os_media)
+        script.set_installation_source(installationsource)
 
-    installationsource = _get_installation_source(os_media)
-    script.set_installation_source(installationsource)
+        config = _make_installconfig(script, guest.osinfo, unattended_data,
+                guest.os.arch, guest.name, url)
+        script.set_config(config)
+        scripts.append(script)
 
-    config = _make_installconfig(script, guest.osinfo, unattended_data,
-            guest.os.arch, guest.name, url)
-    script.set_config(config)
-    return script
+    return scripts
 
 
 def generate_install_script(script):
-- 
2.21.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux