Blob Blame History Raw
From bf1dd84ad4049246d79a63f3448b1e855d159a5d Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 19 Jun 2014 10:49:17 +0100
Subject: [PATCH] [kpatch] new plugin

Based on a suggestion from Marc Milgram in rhbz#1110918.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/kpatch.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 sos/plugins/kpatch.py

diff --git a/sos/plugins/kpatch.py b/sos/plugins/kpatch.py
new file mode 100644
index 0000000..7909926
--- /dev/null
+++ b/sos/plugins/kpatch.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2014 Red Hat, Inc. Bryn M. Reeves <bmr@redhat.com>
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from sos.plugins import Plugin, RedHatPlugin
+import re
+
+
+class Kpatch(Plugin, RedHatPlugin):
+    """Kpatch information
+    """
+
+    plugin_name = 'kpatch'
+
+    packages = ('kpatch',)
+
+    def setup(self):
+        kpatch_list = self.get_cmd_output_now("kpatch list")
+        kpatches = open(kpatch_list, "r").read().splitlines()
+        for patch in kpatches:
+            if not re.match("^kpatch-.*\(.*\)", patch):
+                continue
+            (module, version) = patch.split()
+            self.add_cmd_output("kpatch info " + module)
+
+
+# vim: et ts=4 sw=4
-- 
1.9.3

From 6b43c42078604b0551923c2801108848e97ba3b9 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Tue, 14 Oct 2014 15:43:20 +0100
Subject: [PATCH] [kpatch] do not try to read kpatch data if it could not be
 run

Everything the kpatch plugin does requires the list of available
kpatch patches obtained from 'kpatch list'. If this fails return
immediately from the setup method.

Fixes #417.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/kpatch.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sos/plugins/kpatch.py b/sos/plugins/kpatch.py
index 7909926..6ef557e 100644
--- a/sos/plugins/kpatch.py
+++ b/sos/plugins/kpatch.py
@@ -27,6 +27,8 @@ class Kpatch(Plugin, RedHatPlugin):
 
     def setup(self):
         kpatch_list = self.get_cmd_output_now("kpatch list")
+        if not kpatch_list:
+            return
         kpatches = open(kpatch_list, "r").read().splitlines()
         for patch in kpatches:
             if not re.match("^kpatch-.*\(.*\)", patch):
-- 
1.9.3