[virt-tools-list] [PATCH v2 virt-manager 1/2] virtinst: DistroInstaller uses libosinfo detection first

Cole Robinson crobinso at redhat.com
Wed Mar 26 12:30:41 UTC 2014


On 03/26/2014 07:19 AM, Giuseppe Scrivano wrote:
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
>  virtinst/distroinstaller.py | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/distroinstaller.py b/virtinst/distroinstaller.py
> index ec63ec3..1341314 100644
> --- a/virtinst/distroinstaller.py
> +++ b/virtinst/distroinstaller.py
> @@ -1,5 +1,5 @@
>  #
> -# Copyright 2006-2009, 2013 Red Hat, Inc.
> +# Copyright 2006-2009, 2013, 2014 Red Hat, Inc.
>  # Daniel P. Berrange <berrange at redhat.com>
>  #
>  # This program is free software; you can redistribute it and/or modify
> @@ -30,6 +30,7 @@ from virtinst import util
>  from virtinst import Installer
>  from virtinst import VirtualDisk
>  from virtinst import urlfetcher
> +from virtinst import osdict
>  
>  
>  def _is_url(conn, url):
> @@ -473,6 +474,14 @@ class DistroInstaller(Installer):
>  
>      def detect_distro(self, guest):
>          try:
> +            os = osdict.lookup_os_by_media(self.location)
> +            if os:
> +                logging.debug("installer.detect_distro returned=%s", os)
> +                return os
> +        except:
> +            pass
> +

Can you add a logging.debug("libosinfo detect failed", exc_info=True) in the
except: bit?

And actually, it looks like lookup_os_by_media will throw an exception when
libosinfo fails to detect a distro, because it doesn't handle None return value.

ACK otherwise, feel free to just fix it  in a follow up patch.

- Cole

> +        try:
>              ret = urlfetcher.detectMediaDistro(guest, self.location)
>              logging.debug("installer.detect_distro returned=%s", ret)
>              return ret
> 




More information about the virt-tools-list mailing list