From 253b2dfbc04c94f5f8a7c201e1f8a1afd960b37c Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Fri, 20 Jun 2014 19:22:28 +0100
Subject: [PATCH 4/4] [hardware] call hardware.py directly instead of invoking
 python

Import and call the up2date_client hardware module directly rather
than forking and execing the python interpreter.
---
 sos/plugins/hardware.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/sos/plugins/hardware.py b/sos/plugins/hardware.py
index 16cbb27..c2df571 100644
--- a/sos/plugins/hardware.py
+++ b/sos/plugins/hardware.py
@@ -14,6 +14,7 @@
 
 import sos.plugintools
 import os
+import sys
 
 class hardware(sos.plugintools.PluginBase):
     """hardware related information
@@ -39,7 +40,17 @@ class hardware(sos.plugintools.PluginBase):
         self.addCopySpec("/sys/bus/scsi")
         self.addCopySpec("/sys/state")
         self.addCopySpec("/var/log/mcelog")
-        self.collectExtOutput("python /usr/share/rhn/up2date_client/hardware.py", suggest_filename="hardware.py")
+        sys.path.append("/usr/share/rhn/")
+        try:
+            from up2date_client import hardware
+            buf = ""
+            for hw in hardware.Hardware():
+                for k in hw.keys():
+                    buf = buf + "'%s' : '%s'\n" % (k, hw[k])
+                buf = buf + '\n'
+            self.writeTextToCommand("hardware.py", buf)
+        except:
+            pass
         self.collectExtOutput("""/bin/echo -e "lspci:\n" ; /sbin/lspci ; /bin/echo -e "\nlspci -nvv:\n" ; /sbin/lspci -nvv ; /bin/echo -e "\nlspci -tv:\n" ; /sbin/lspci -tv""", suggest_filename = "lspci", symlink = "lspci")
 
         self.collectExtOutput("/usr/sbin/dmidecode", symlink = "dmidecode")
-- 
1.9.3

