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

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