[virt-tools-list] [PATCH 4/4] Make SuseDistro a base class for other Suse classes

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


Remove the PRETTY_NAME for SuseDistro so it isn't included in the allstores.

Add appropriate identifiers to the other Suse classes so that they
are included in allstores.

If cache.treeinfo_family_regex fails to find the family but there is
a .treeinfo file, self.cache.suse_content is set to -1 when a failed
attempt is made to find a content file. Check for -1 in the __init__
function so we will pull the kernel from the location in .treeinfo file.

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

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

diff --git a/virtinst/urldetect.py b/virtinst/urldetect.py
index 64fd48a0..2e68e9a7 100644
--- a/virtinst/urldetect.py
+++ b/virtinst/urldetect.py
@@ -500,13 +500,13 @@ class CentOSDistro(RHELDistro):
 
 
 class SuseDistro(Distro):
-    PRETTY_NAME = "SUSE"
+    PRETTY_NAME = None
     _suse_regex = []
+    urldistro = None
 
     @classmethod
     def is_valid(cls, cache):
-        famregex = ".*SUSE.*"
-        if cache.treeinfo_family_regex(famregex):
+        if cache.treeinfo_family_regex(cls.famregex):
             return True
 
         if not cache.suse_content:
@@ -531,7 +531,7 @@ class SuseDistro(Distro):
     def __init__(self, *args, **kwargs):
         Distro.__init__(self, *args, **kwargs)
 
-        if not self.cache.suse_content:
+        if not self.cache.suse_content or self.cache.suse_content == -1:
             # This means we matched on treeinfo
             k, b = self.cache.get_treeinfo_media(self.type)
             self._kernel_paths = k
@@ -641,18 +641,27 @@ class SuseDistro(Distro):
 
 
 class SLESDistro(SuseDistro):
+    PRETTY_NAME = "SLES"
     urldistro = "sles"
+    _variant_prefix = "sles"
     _suse_regex = [".*SUSE Linux Enterprise Server*", ".*SUSE SLES*"]
+    famregex = ".*SUSE Linux Enterprise.*"
 
 
 class SLEDDistro(SuseDistro):
+    PRETTY_NAME = "SLED"
     urldistro = "sled"
+    _variant_prefix = "sled"
     _suse_regex = [".*SUSE Linux Enterprise Desktop*"]
+    famregex = ".*SUSE Linux Enterprise.*"
 
 
 class OpensuseDistro(SuseDistro):
+    PRETTY_NAME = "openSUSE"
     urldistro = "opensuse"
+    _variant_prefix = "opensuse"
     _suse_regex = [".*openSUSE.*"]
+    famregex = ".*openSUSE.*"
 
 
 class DebianDistro(Distro):
-- 
2.16.3




More information about the virt-tools-list mailing list