[virt-tools-list] [virt-manager PATCH] osinfo: warn when using deprecated osinfo IDs

Pino Toscano ptoscano at redhat.com
Tue Oct 2 11:53:26 UTC 2018


At some point in the future it could be a good idea to drop the _aliases
mapping altogether; it will be hard to do so, in case the users are not
informed that they are using a deprecated ID.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtinst/osdict.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 39422233..b78bcedd 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -192,7 +192,14 @@ class _OSDB(object):
                 return osobj
 
     def lookup_os(self, key):
-        key = self._aliases.get(key) or key
+        try:
+            mapped_key = self._aliases[key]
+            logging.warning(_("Using a deprecated Guest osinfo %s, "
+                              "%s will be used instead"),
+                            key, mapped_key)
+            key = mapped_key
+        except KeyError:
+            pass
         return self._all_variants.get(key)
 
     def lookup_os_by_media(self, location):
-- 
2.17.1




More information about the virt-tools-list mailing list