[virt-tools-list] [virt-manager PATCH][RFC] cloudinit: Move random password printing and sleeping to virt-install

Athina Plaskasoviti athina.plaskasoviti at gmail.com
Mon Jul 22 10:34:23 UTC 2019


Added a 10 second delay when printing random password for first login,
which can be bypassed when pressing Enter.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
 virt-install                  | 10 ++++++++++
 virtinst/install/installer.py |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/virt-install b/virt-install
index 4c05a7b4..117e801a 100755
--- a/virt-install
+++ b/virt-install
@@ -9,6 +9,7 @@ import argparse
 import atexit
 import sys
 import time
+from select import select
 
 import libvirt
 
@@ -664,6 +665,15 @@ def start_install(guest, installer, options):
         if options.destroy_on_exit:
             atexit.register(_destroy_on_exit, domain)
 
+        passwd = installer.get_generated_password()
+        if options.cloud_init and passwd:
+            print_stdout(_("Password for first login is: %s") % passwd)
+            print_stdout(
+                _("Installation will continue in 10 seconds, "
+                "else press Enter to continue"))
+            timeout = 10
+            select([sys.stdin], [], [], timeout)
+
         cli.connect_console(guest, domain, conscb,
                 waithandler.wait_for_console_to_exit,
                 options.destroy_on_exit)
diff --git a/virtinst/install/installer.py b/virtinst/install/installer.py
index b6d4d134..a61f7766 100644
--- a/virtinst/install/installer.py
+++ b/virtinst/install/installer.py
@@ -418,6 +418,11 @@ class Installer(object):
         self._tmpfiles.append(iso)
         self._add_unattended_install_cdrom_device(guest, iso)
 
+    def get_generated_password(self):
+        if self._cloudinit_data:
+            ret = self._cloudinit_data.generate_password()
+            return ret
+
 
     ##########################
     # guest install handling #
-- 
2.20.1




More information about the virt-tools-list mailing list