[virt-tools-list] [PATCH virt-manager 1/2] osdict: add new function lookup_os_by_media
Cole Robinson
crobinso at redhat.com
Tue Mar 25 21:35:42 UTC 2014
On 03/25/2014 09:45 AM, Giuseppe Scrivano wrote:
> "lookup_os_by_media" fetches the OS of the installation media by
> querying libosinfo.
>
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
> virtinst/osdict.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/virtinst/osdict.py b/virtinst/osdict.py
> index ded906b..9814384 100644
> --- a/virtinst/osdict.py
> +++ b/virtinst/osdict.py
> @@ -24,6 +24,8 @@ _allvariants = {}
> from datetime import datetime
> from gi.repository import Libosinfo as libosinfo # pylint: disable=E0611
>
> +loader = libosinfo.Loader()
> +loader.process_default_path()
>
> _aliases = {
> "altlinux" : "altlinux1.0",
> @@ -162,6 +164,14 @@ def get_recommended_resources(variant, arch):
> return v.get_recommended_resources(arch)
>
>
> +def lookup_os_by_media(location):
> + media = libosinfo.Media.create_from_location(location, None)
> + ret = loader.get_db().guess_os_from_media(media)
> + if len(ret) > 0:
> + return ret[0].get_short_id()
> + return None
> +
> +
> class _OSVariant(object):
> """
> Object tracking guest OS specific configuration bits.
> @@ -559,8 +569,6 @@ _add_type("unix", "UNIX")
> _add_type("other", "Other")
> _add_var("generic", "Generic", supported=True, parent="other")
>
> -loader = libosinfo.Loader()
> -loader.process_default_path()
> db = loader.get_db()
>
> oslist = db.get_os_list()
>
ACK, this can go in now if you want.
- Cole
More information about the virt-tools-list
mailing list