[virt-tools-list] [virt-install PATCH v2 12/14] installertreemedia: Perform a unattended installation

Fabiano Fidêncio fidencio at redhat.com
Fri Feb 22 08:40:19 UTC 2019


In case the InstallerTreeMedia has any unattended_data set, let's just
generate the install script and have everything set up for performing a
unattended installation.

path is appended to the tmpfiles as it's the generated unattended script
and it has to be cleaned up when no longer needed.

cmdline is preppended to the args gotten from _prepare_kernel_url() in
order to be used during the first OS boot (and only there!).

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

diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
index 642946d9..2484e88c 100644
--- a/virtinst/installertreemedia.py
+++ b/virtinst/installertreemedia.py
@@ -14,6 +14,7 @@ from .devices import DeviceDisk
 from .initrdinject import perform_initrd_injections
 from .kernelupload import upload_kernel_initrd
 from .osdict import OSDB
+from .unattended import generate_install_script
 
 
 # Enum of the various install media types we can have
@@ -172,11 +173,24 @@ class InstallerTreeMedia(object):
         self._unattended_data = unattended_data
 
     def prepare(self, guest, meter):
+        cmdline = None
         if self._unattended_data:
-            pass
+            path, cmdline = generate_install_script(
+                    guest, self._unattended_data)
+
+            self.initrd_injections.append(path)
+            self._tmpfiles.append(path)
 
         fetcher = self._get_fetcher(guest, meter)
-        return self._prepare_kernel_url(guest, fetcher)
+        k, i, a = self._prepare_kernel_url(guest, fetcher)
+
+        # If a cmdline was set due to unattended installation, prepend the
+        # unattended kernel cmdline to the args returned by
+        #_prepare_kernel_url()
+        if cmdline:
+            a = "%s %s" % (cmdline, a)
+
+        return k, i, a
 
     def cleanup(self, guest):
         ignore = guest
-- 
2.20.1




More information about the virt-tools-list mailing list