File 0001-Test-cts-service-counts-as-enabled-only-if-it-s-expl-1.1.patch of Package pacemaker.19778

From 56db8d1aabbef3b539436ee7d697d2c8e66900dd Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Fri, 18 Jan 2019 17:02:06 +0100
Subject: [PATCH 1/2] Test: cts: service counts as enabled only if it's
 explicitly enabled

With "systemctl is-enabled", we should check if the service is
explicitly "enabled" instead of the return code. For example it returns
0 if the service is "static" or "indirect", but they don't really count
as "enabled".

This also functionizes the check part for further use.
---
 cts/environment.py | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/cts/environment.py b/cts/environment.py
index d7fa25939..67b0f6426 100644
--- a/cts/environment.py
+++ b/cts/environment.py
@@ -224,21 +224,26 @@ class Environment:
                 # default
                 self["syslogd"] = "rsyslog"
 
+    def service_is_enabled(self, node, service):
+        if self["have_systemd"]:
+            # Systemd
+
+            # With "systemctl is-enabled", we should check if the service is
+            # explicitly "enabled" instead of the return code. For example it returns
+            # 0 if the service is "static" or "indirect", but they don't really count
+            # as "enabled".
+            return not self.rsh(node, "systemctl is-enabled %s | grep enabled" % service)
+
+        else:
+            # SYS-V
+            return not self.rsh(node, "chkconfig --list | grep -e %s.*on" % service)
+
     def detect_at_boot(self):
         # Detect if the cluster starts at boot
         if not "at-boot" in self.data:
-            atboot = 0
-
-            if self["have_systemd"]:
-            # Systemd
-                atboot = atboot or not self.rsh(self.target, "systemctl is-enabled heartbeat.service")
-                atboot = atboot or not self.rsh(self.target, "systemctl is-enabled corosync.service")
-                atboot = atboot or not self.rsh(self.target, "systemctl is-enabled pacemaker.service")
-            else:
-                # SYS-V
-                atboot = atboot or not self.rsh(self.target, "chkconfig --list | grep -e corosync.*on -e heartbeat.*on -e pacemaker.*on")
-
-            self["at-boot"] = atboot
+            self["at-boot"] = self.service_is_enabled(self.target, "heartbeat") \
+                              or self.service_is_enabled(self.target, "corosync") \
+                              or self.service_is_enabled(self.target, "pacemaker")
 
     def detect_ip_offset(self):
         # Try to determin an offset for IPaddr resources
-- 
2.16.4

openSUSE Build Service is sponsored by