summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/find_recalled_parts.py12
-rw-r--r--examples/part_data.txt4
-rwxr-xr-xmodules/hardware.py32
-rw-r--r--overlord/test_func.py3
4 files changed, 40 insertions, 11 deletions
diff --git a/examples/find_recalled_parts.py b/examples/find_recalled_parts.py
index f9ca4bb..fc1a3b1 100644
--- a/examples/find_recalled_parts.py
+++ b/examples/find_recalled_parts.py
@@ -7,7 +7,7 @@ import func.overlord.client as fc
bad = open("./part_data.txt").read().split()
-info = fc.Client("*").hardware.info()
+info = fc.Client("*").hardware.hal_info()
for (host,details) in info.iteritems():
@@ -15,10 +15,10 @@ for (host,details) in info.iteritems():
print "%s had an error : %s" % (host,str(details))
break
- for device in details["devices"]:
+ for (device, full_output) in details.iteritems():
for bad_value in bad:
- if device["Description"].find(bad_value) != -1:
- print "%s has flagged part: %s " % (host, device["Description"])
- break
-
+ if full_output.find(bad_value) != -1:
+ print "%s has flagged part: %s, matched %s" % (host, device, bad_value)
+ break
+
diff --git a/examples/part_data.txt b/examples/part_data.txt
index 3d2cf3a..ad888d9 100644
--- a/examples/part_data.txt
+++ b/examples/part_data.txt
@@ -7,6 +7,4 @@
C6270 GD785 M3006 X5329 Y5466 6P922 D2961 H3191 RD857 X5332 C2603 D5555 J1524 TD349
X5333 C5339 D6024 JD616 U5867 X5875 C5340 D6025 JD617 U5882 X5877
-#-RANDOM-STUFF-SO-GET-A-FALSE-POSITIVE
-SCSI
-
+#-RANDOM-STUFF-IF-YOU-NEED-A-FALSE-POSITIVE-LIKE-MAYBE-SCSI
diff --git a/modules/hardware.py b/modules/hardware.py
index 7c6deb4..5366b78 100755
--- a/modules/hardware.py
+++ b/modules/hardware.py
@@ -3,6 +3,7 @@
##
## Hardware profiler plugin
## requires the "smolt" client package be installed
+## but also relies on lspci for some things
##
## Copyright 2007, Red Hat, Inc
## Michael DeHaan <mdehaan@redhat.com>
@@ -23,6 +24,7 @@ sys.path.append("/usr/share/smolt/client")
import smolt
# our modules
+import sub_process
from modules import func_module
# =================================
@@ -30,10 +32,38 @@ from modules import func_module
class HardwareModule(func_module.FuncModule):
def __init__(self):
self.methods = {
- "info": self.info
+ "info" : self.info,
+ "hal_info" : self.hal_info
}
func_module.FuncModule.__init__(self)
+ def hal_info(self):
+ """
+ Returns the output of lshal, but split up into seperate devices
+ for easier parsing. Each device is a entry in the return hash.
+ """
+
+ cmd = sub_process.Popen(["/usr/bin/lshal"],shell=False,stdout=sub_process.PIPE)
+ data = cmd.communicate()[0]
+
+ data = data.split("\n")
+
+ results = {}
+ current = ""
+ label = data[0]
+ for d in data:
+ if d == '':
+ results[label] = current
+ current = ""
+ label = ""
+ else:
+ if label == "":
+ label = d
+ current = current + d
+
+ return results
+
+
def info(self,with_devices=True):
"""
Returns a struct of hardware information. By default, this pulls down
diff --git a/overlord/test_func.py b/overlord/test_func.py
index 1e0d72b..f3b1652 100644
--- a/overlord/test_func.py
+++ b/overlord/test_func.py
@@ -16,7 +16,8 @@ TEST_SMART = True
if TEST_GETATTR:
import func.overlord.client as func_client
- print func_client.Client("*").test.add(1,2)
+ print func_client.Client("*").hardware.pci_info()
+ #print func_client.Client("*").test.add(1,2)
#print func_client.Client("*").hardware.info()
#print func_client.Client("*").run("hardware","info",[])
#print func_client.Client(socket.gethostname(),noglobs=True).test.add("1","2")