[virt-manager PATCH 9/9] osdict: Use identify_tree()

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

 



Let's use identify_tree(), which is part of libosinfo v1.6.0 release,
instead of using guess_os_from_tree().

The API has been implemented on libosinfo in order to be consistent with
what was already done for medias.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 virtinst/osdict.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 3b71ac31..f09bcc29 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -260,10 +260,17 @@ class _OSDB(object):
                 "location=%s : %s", location, str(e))
             return None
 
-        osobj, treeobj = self._os_loader.get_db().guess_os_from_tree(tree)
-        if not osobj:
-            return None  # pragma: no cover
-        return osobj.get_short_id(), _OsTree(treeobj)
+        db = self._os_loader.get_db()
+        if hasattr(db, "identify_tree"):
+            # osinfo_db_identify_tree is part of libosinfo 1.6.0
+            if not db.identify_tree(tree):
+                return None  # pragma: no cover
+            return tree.get_os().get_short_id(), _OsTree(tree)
+        else:
+            osobj, treeobj = self._os_loader.get_db().guess_os_from_tree(tree)
+            if not osobj:
+                return None  # pragma: no cover
+            return osobj.get_short_id(), _OsTree(treeobj)
 
     def list_os(self):
         """
-- 
2.21.0

_______________________________________________
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