[virt-tools-list] [PATCH 2/4] Use split_version method to get version and update

Charles Arnold carnold at suse.com
Mon May 7 21:39:36 UTC 2018


The while loop that follows is similar to rhel code but because the osinfo-db
short id for sles doesn't contain a '.0' for first time releases (eg, sles11,
sles12) we check sle with no update and don't add a '.0' to the string.

Signed-off-by: Charles Arnold <carnold at suse.com>

---
 virtinst/urldetect.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/virtinst/urldetect.py b/virtinst/urldetect.py
index 7140dae5..a1d02577 100644
--- a/virtinst/urldetect.py
+++ b/virtinst/urldetect.py
@@ -614,6 +614,19 @@ class SuseDistro(Distro):
         if re.search("openSUSE Tumbleweed", self.cache.treeinfo_name):
             return "opensusetumbleweed"
 
+        version, update = self.cache.split_version()
+        self._version_number = version
+
+        base = self._variant_prefix + str(version)
+        while update >= 0:
+            tryvar = base
+            # SLE doesn't use '.0' for initial releases in osinfo-db (sles11, sles12, etc)
+            if update > 0 or not base.startswith('sle'):
+                tryvar += ".%s" % update
+            if OSDB.lookup_os(tryvar):
+                return tryvar
+            update -= 1
+
     def _detect_version(self):
         var = self._detect_from_treeinfo()
         if not var:
-- 
2.16.3




More information about the virt-tools-list mailing list