summaryrefslogtreecommitdiff
path: root/virt-install
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2019-11-25 13:00:36 -0500
committerCole Robinson <crobinso@redhat.com>2019-11-25 14:03:49 -0500
commitc5da0d7b07da27b2102986b7b310f3be0dcb3968 (patch)
tree8cd62ed72bcf68bd30eada84a34541c1a58069ae /virt-install
parent226378d52289f43d4c59a7253b9493e68cc7a7c3 (diff)
downloadvirt-manager-c5da0d7b07da27b2102986b7b310f3be0dcb3968.tar.gz
virt-install: Don't pause for cloudinit pass if stdin is closed
Like if run in a script without any stdin open. Have the test suite actually hit this path Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virt-install')
-rwxr-xr-xvirt-install36
1 files changed, 26 insertions, 10 deletions
diff --git a/virt-install b/virt-install
index fc0ab0ac..0bec5f3e 100755
--- a/virt-install
+++ b/virt-install
@@ -630,6 +630,30 @@ class WaitHandler:
return (time_elapsed >= self._wait_secs) or cli.in_testsuite()
+def _print_cloudinit_passwd(installer):
+ passwd = installer.get_generated_password()
+ if not passwd:
+ return
+
+ print_stdout(_("Password for first root login is: %s") % passwd,
+ do_force=True, do_log=False)
+
+ stdins = [sys.stdin]
+ timeout = 10
+ if sys.stdin.closed or not sys.stdin.isatty():
+ if not cli.in_testsuite(): # pragma: no cover
+ return
+ stdins = []
+ timeout = .0001
+
+ sys.stdout.write(
+ _("Installation will continue in 10 seconds "
+ "(press Enter to skip)..."))
+ sys.stdout.flush()
+
+ select.select(stdins, [], [], timeout)
+
+
def start_install(guest, installer, options):
autoconsole = cli.parse_autoconsole(options, guest)
show_console_warnings(installer, autoconsole)
@@ -645,8 +669,7 @@ def start_install(guest, installer, options):
waithandler = WaitHandler(options.wait)
meter = cli.get_meter()
- log.debug("Guest.has_install_phase: %s",
- installer.has_install_phase())
+ log.debug("Guest.has_install_phase: %s", installer.has_install_phase())
# we've got everything -- try to start the install
print_stdout(_("\nStarting install..."))
@@ -662,14 +685,7 @@ 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: # pragma: no cover
- print_stdout(_("Password for first login is: %s") % passwd, do_log=False)
- print_stdout(
- _("Installation will continue in 10 seconds "
- "(press Enter to skip)"))
- timeout = 10
- select.select([sys.stdin], [], [], timeout)
+ _print_cloudinit_passwd(installer)
cli.connect_console(guest, domain, conscb,
waithandler.wait_for_console_to_exit,