Blame SOURCES/sos-bz1416535-pacemaker-user-logs.patch

b939f5
From 17809273cecd83c068931e5d7e73d126d98e6ac1 Mon Sep 17 00:00:00 2001
b939f5
From: "Bryn M. Reeves" <bmr@redhat.com>
b939f5
Date: Tue, 9 May 2017 14:34:13 +0100
b939f5
Subject: [PATCH 1/2] [pacemaker] Collect /etc/default/pacemaker for
b939f5
 Debian/Ubuntu
b939f5
b939f5
Make /etc/default/pacemaker the default location for the Pacemaker
b939f5
defaults file, and have the RedHatPlugin override this to the
b939f5
/etc/sysconfig/pacemaker location as required.
b939f5
b939f5
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
b939f5
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
b939f5
---
b939f5
 sos/plugins/pacemaker.py | 14 ++++++++++++--
b939f5
 1 file changed, 12 insertions(+), 2 deletions(-)
b939f5
b939f5
diff --git a/sos/plugins/pacemaker.py b/sos/plugins/pacemaker.py
b939f5
index 0dac1da..74de433 100644
b939f5
--- a/sos/plugins/pacemaker.py
b939f5
+++ b/sos/plugins/pacemaker.py
b939f5
@@ -17,12 +17,13 @@ from datetime import datetime, timedelta
b939f5
 import re
b939f5
 
b939f5
 
b939f5
-class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
b939f5
+class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
b939f5
     """HA Cluster resource manager"""
b939f5
 
b939f5
     plugin_name = "pacemaker"
b939f5
     profiles = ("cluster", )
b939f5
     packages = ["pacemaker"]
b939f5
+    defaults = "/etc/default/pacemaker"
b939f5
 
b939f5
     option_list = [
b939f5
         ("crm_from", "specify the start time for crm_report", "fast", False),
b939f5
@@ -32,7 +33,7 @@ class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
b939f5
     def setup(self):
b939f5
         self.add_copy_spec([
b939f5
             "/var/lib/pacemaker/cib/cib.xml",
b939f5
-            "/etc/sysconfig/pacemaker",
b939f5
+            self.defaults,
b939f5
             "/var/log/pacemaker.log",
b939f5
             "/var/log/pcsd/pcsd.log"
b939f5
         ])
b939f5
@@ -76,4 +77,13 @@ class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
b939f5
             r"\1********"
b939f5
         )
b939f5
 
b939f5
+
b939f5
+class RedHatPacemaker(Pacemaker, RedHatPlugin):
b939f5
+    """ Handle alternate location of pacemaker defaults file.
b939f5
+    """
b939f5
+    def setup(self):
b939f5
+        self.defaults = "/etc/sysconfig/pacemaker"
b939f5
+        super(RedHatPacemaker, self).setup()
b939f5
+
b939f5
+
b939f5
 # vim: et ts=4 sw=4
b939f5
-- 
b939f5
2.7.4
b939f5
b939f5
b939f5
From 15b01889292ee3fca68ea76523be93af3be138f6 Mon Sep 17 00:00:00 2001
b939f5
From: Pavel Moravec <pmoravec@redhat.com>
b939f5
Date: Wed, 3 May 2017 09:48:29 +0200
b939f5
Subject: [PATCH 2/2] [pacemaker] Collect user-defined logfile
b939f5
b939f5
/etc/sysconfig/pacemaker or /etc/default/pacemaker can specify pacemaker's
b939f5
logfile that sos should collect.
b939f5
b939f5
Resolves: #1002.
b939f5
b939f5
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
b939f5
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
b939f5
---
b939f5
 sos/plugins/pacemaker.py | 17 +++++++++++++++++
b939f5
 1 file changed, 17 insertions(+)
b939f5
b939f5
diff --git a/sos/plugins/pacemaker.py b/sos/plugins/pacemaker.py
b939f5
index 74de433..9393831 100644
b939f5
--- a/sos/plugins/pacemaker.py
b939f5
+++ b/sos/plugins/pacemaker.py
b939f5
@@ -15,6 +15,7 @@
b939f5
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
b939f5
 from datetime import datetime, timedelta
b939f5
 import re
b939f5
+import os.path
b939f5
 
b939f5
 
b939f5
 class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
b939f5
@@ -45,6 +46,7 @@ class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
b939f5
             "pcs status",
b939f5
             "pcs property list --all"
b939f5
         ])
b939f5
+
b939f5
         # crm_report needs to be given a --from "YYYY-MM-DD HH:MM:SS" start
b939f5
         # time in order to collect data.
b939f5
         crm_from = (datetime.today() -
b939f5
@@ -70,6 +72,21 @@ class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
b939f5
                             (crm_scrub, crm_dest, crm_from),
b939f5
                             chroot=self.tmp_in_sysroot())
b939f5
 
b939f5
+        # collect user-defined logfiles, matching pattern:
b939f5
+        # PCMK_loggfile=filename
b939f5
+        # specified in the pacemaker defaults file.
b939f5
+        pattern = '^\s*PCMK_logfile=[\'\"]?(\S+)[\'\"]?\s*(\s#.*)?$'
b939f5
+        if os.path.isfile(self.defaults):
b939f5
+            with open(self.defaults) as f:
b939f5
+                for line in f:
b939f5
+                    if re.match(pattern, line):
b939f5
+                        # remove trailing and leading quote marks, in case the
b939f5
+                        # line is e.g. PCMK_logfile="/var/log/pacemaker.log"
b939f5
+                        logfile = re.search(pattern, line).group(1)
b939f5
+                        for regexp in [r'^"', r'"$', r'^\'', r'\'$']:
b939f5
+                            logfile = re.sub(regexp, '', logfile)
b939f5
+                        self.add_copy_spec(logfile)
b939f5
+
b939f5
     def postproc(self):
b939f5
         self.do_cmd_output_sub(
b939f5
             "pcs config",
b939f5
-- 
b939f5
2.7.4
b939f5