File tweak-for-suse.patch of Package vdsm

Index: vdsm-4.50.5.1~git0.c3596b5a/lib/vdsm/gluster/api.py
===================================================================
--- vdsm-4.50.5.1~git0.c3596b5a.orig/lib/vdsm/gluster/api.py
+++ vdsm-4.50.5.1~git0.c3596b5a/lib/vdsm/gluster/api.py
@@ -71,6 +71,13 @@ GLUSTER_DEB_PACKAGES = (
     ('glusterfs-rdma', 'libglusterfs0'),
     ('glusterfs-server', 'glusterfs-server'))
 
+GLUSTER_SUSE_PACKAGES = (
+    ('glusterfs', ('glusterfs',)),
+    ('glusterfs-fuse', ('glusterfs',)),
+    ('glusterfs-geo-replication', ('glusterfs',)),
+    ('glusterfs-rdma', ('glusterfs',)),
+    ('glusterfs-server', ('glusterfs',)))
+
 
 def exportAsVerb(func):
     @wraps(func)
Index: vdsm-4.50.5.1~git0.c3596b5a/lib/vdsm/osinfo.py
===================================================================
--- vdsm-4.50.5.1~git0.c3596b5a.orig/lib/vdsm/osinfo.py
+++ vdsm-4.50.5.1~git0.c3596b5a/lib/vdsm/osinfo.py
@@ -36,6 +36,7 @@ except ImportError:
 try:
     from vdsm.gluster.api import GLUSTER_RPM_PACKAGES
     from vdsm.gluster.api import GLUSTER_DEB_PACKAGES
+    from vdsm.gluster.api import GLUSTER_SUSE_PACKAGES
     glusterEnabled = True
 except ImportError:
     glusterEnabled = False
@@ -54,6 +55,7 @@ class OSName:
     FEDORA = 'Fedora'
     RHEVH = 'RHEV Hypervisor'
     DEBIAN = 'Debian'
+    SUSE = 'SUSE'
 
 
 class KdumpStatus(object):
@@ -102,6 +104,17 @@ def _release_name():
     elif os.path.exists('/etc/debian_version'):
         return OSName.DEBIAN
     else:
+        OS_RELEASE = "/etc/os-release"
+        SLES_STR = "SLES"
+        OPENSUSE_STR = "openSUSE"
+        if os.path.exists(OS_RELEASE):
+            with open(OS_RELEASE, "r") as f:
+                for line in f:
+                    if line.startswith("NAME"):
+                        (name, value) = line.split("=")
+                        value = value.strip("\"'")
+                        if value.startswith(SLES_STR) or value.startswith(OPENSUSE_STR):
+                            return OSName.SUSE
         return OSName.UNKNOWN
 
 
@@ -281,6 +294,7 @@ def package_versions():
             'qemu-kvm': 'qemu-kvm',
             'spice-server': 'libspice-server1',
             'vdsm': 'vdsmd',
+            'lvm2': 'lvm2',
         }
 
         if glusterEnabled:
@@ -297,6 +311,43 @@ def package_versions():
             except Exception:
                 logging.error('', exc_info=True)
 
+    elif _release_name() == OSName.SUSE:
+        KEY_PACKAGES = {
+            'glusterfs-cli': ('glusterfs',),
+            'librbd1': ('librbd1',),
+            'libvirt': ('libvirt', 'libvirt-daemon-kvm'),
+            'mom': ('mom',),
+            'ovirt-hosted-engine-ha': ('ovirt-hosted-engine-ha',),
+            'openvswitch': ('openvswitch', 'ovirt-openvswitch'),
+            'nmstate': ('nmstate',),
+            'qemu-img': ('qemu-img',),
+            'qemu-kvm': ('qemu',),
+            'spice-server': ('libspice-server1',),
+            'vdsm': ('vdsm',),
+            'lvm2': ('lvm2', 'lvm2-libs'),
+        }
+
+        if glusterEnabled:
+            KEY_PACKAGES.update(GLUSTER_SUSE_PACKAGES)
+
+        try:
+            ts = rpm.TransactionSet()
+
+            for pkg, names in six.iteritems(KEY_PACKAGES):
+                try:
+                    mi = next(itertools.chain(
+                        *[ts.dbMatch('name', name) for name in names]))
+                except StopIteration:
+                    logging.debug("rpm package %s not found",
+                                  KEY_PACKAGES[pkg])
+                else:
+                    pkgs[pkg] = {
+                        'version': mi['version'],
+                        'release': mi['release'],
+                    }
+        except Exception:
+            logging.error('', exc_info=True)
+
     return pkgs
 
 
openSUSE Build Service is sponsored by