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

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

 



On 7/22/19 6:34 AM, Athina Plaskasoviti wrote:
> 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@xxxxxxxxx>
> ---
>  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
>  

I prefer just 'import select' and use select.select later

>  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 will also log, which we don't want to do here. So please
add an extra option to print_stdout, like dolog=True, and use
dolog=False here.

> +            print_stdout(
> +                _("Installation will continue in 10 seconds, "
> +                "else press Enter to continue"))

_("Installation will continue in 10 seconds (press Enter to skip)")

> +            timeout = 10
> +            select([sys.stdin], [], [], timeout)
> +

Ah, neat trick with select for handling input and 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
> +

You drop 'ret' and just 'return' the value here

>  
>      ##########################
>      # guest install handling #
> 

Also it looks like the test suite isn't covering this code which we need
to fix. But if you add testing it will probably pause. Might need to
protect the select call with 'if sys.stdin.isatty()'

Thanks,
Cole

_______________________________________________
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