[virt-tools-list] [virt-manager PATCH 1/3] osdict: expand the "unknown" check for any distro

Cole Robinson crobinso at redhat.com
Thu Oct 18 21:28:22 UTC 2018


On 10/18/2018 07:43 AM, Fabiano Fidêncio wrote:
> Currently osinfo-db has "unknown" entries for fedora, opensuse and
> asianux. Considering this list may grow even more at some point, let's
> just make the check more generic and use it for all of them instead of
> keeping it for fedora only.
> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>   virtinst/osdict.py | 22 +++++++++++++++-------
>   1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/virtinst/osdict.py b/virtinst/osdict.py
> index 28e076da..92fe9522 100644
> --- a/virtinst/osdict.py
> +++ b/virtinst/osdict.py
> @@ -208,11 +208,15 @@ class _OSDB(object):
>               return None
>   
>           osname = ret[0].get_short_id()
> -        if osname == "fedora-unknown":
> -            osname = self.latest_fedora_version()
> -            logging.debug("Detected location=%s as os=fedora-unknown. "
> -                "Converting that to the latest fedora OS version=%s",
> -                location, osname)
> +        if osname.endswith("-unknown"):
> +            # We want to get whatever the name is apart from unknown, instead
> +            # of getting the distro, as some enterprise distros may have more
> +            # than one "unknown" entry and we'd like to match the correct one.
> +            osdistro = osname.split("-unknown")[0]
> +            osname = self.latest_os_version(osdistro)
> +            logging.debug("Detected location=%s as os=%s-unknown. "
> +                "Converting that to the latest %s OS version=%s",
> +                osdistro, osdistro, location, osname)
>   
>           return osname
>   
> @@ -236,8 +240,12 @@ class _OSDB(object):
>               return None
>           return oses[0]
>   
> -    def latest_fedora_version(self):
> -        return self.latest_regex("fedora[0-9]+")
> +    def latest_os_version(self, osdistro):
> +        regex = osdistro + "[0-9]+"
> +        if osdistro[-1].isdigit():
> +            regex = osdistro + "\.[0-9]+"
> +
> +        return self.latest_regex(regex)

On F29 ./setup.py pylint complains here:

virtinst/osdict.py:255: [W605] invalid escape sequence '\.'

Stick r in front of it to fix it: r"\.[0-9]+"

More importantly this still leaves two uses of latest_fedora_version in 
the code, one in the test suite and one in virtinst/urldetect.py. I know 
I said on IRC to not worry about the test_urls test suite but it will 
help reproduce here:

   ./setup.py test_urls

or to narrow it a bit

   ./setup.py test_urls --only fedora

- Cole




More information about the virt-tools-list mailing list