summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2009-01-08 16:03:23 +0000
committerBill Peck <bpeck@redhat.com>2009-01-08 16:03:23 +0000
commitcc1d066866fb5563a687f6fa9071869cfaea056c (patch)
treeefe325f0d6625648fa05f2f0b8a4732438c64090
parent5330b8c111c068e0aa15ee1ef60540aeaa17487d (diff)
record the boot disk drivers
-rwxr-xr-xTasks/distribution/inventory/getdriver.sh66
-rwxr-xr-xTasks/distribution/inventory/push-inventory.py15
2 files changed, 81 insertions, 0 deletions
diff --git a/Tasks/distribution/inventory/getdriver.sh b/Tasks/distribution/inventory/getdriver.sh
new file mode 100755
index 0000000..aba103f
--- /dev/null
+++ b/Tasks/distribution/inventory/getdriver.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Find all modules and drivers for a given class device.
+#
+
+if [ $# != "1" ] ; then
+ echo
+ echo "Script to display the drivers and modules for a specified sysfs class device"
+ echo "usage: $0 <CLASS_NAME>"
+ echo
+ echo "example usage:"
+ echo " $0 sda"
+ echo "Will show all drivers and modules for the sda block device."
+ echo
+ exit 1
+fi
+
+DEV=$1
+
+if test -e "$1"; then
+ DEVPATH=$1
+else
+ # find sysfs device directory for device
+ DEVPATH=$(find /sys/class -name "$1" | head -1)
+ test -z "$DEVPATH" && DEVPATH=$(find /sys/block -name "$1" | head -1)
+ test -z "$DEVPATH" && DEVPATH=$(find /sys/bus -name "$1" | head -1)
+ if ! test -e "$DEVPATH"; then
+ exit 1
+ fi
+fi
+
+if test -L "$DEVPATH"; then
+ # resolve class device link to device directory
+ DEVPATH=$(readlink -f $DEVPATH)
+fi
+
+if test -d "$DEVPATH"; then
+ # resolve old-style "device" link to the parent device
+ PARENT="$DEVPATH";
+ while test "$PARENT" != "/"; do
+ if test -L "$PARENT/device"; then
+ DEVPATH=$(readlink -f $PARENT/device)
+ break
+ fi
+ PARENT=$(dirname $PARENT)
+ done
+fi
+
+while test "$DEVPATH" != "/"; do
+ DRIVERPATH=
+ DRIVER=
+ MODULEPATH=
+ MODULE=
+ if test -e $DEVPATH/driver; then
+ DRIVERPATH=$(readlink -f $DEVPATH/driver)
+ DRIVER=$(basename $DRIVERPATH)
+ echo $DRIVER
+ if test -e $DRIVERPATH/module; then
+ MODULEPATH=$(readlink -f $DRIVERPATH/module)
+ MODULE=$(basename $MODULEPATH)
+ echo $MODULE
+ fi
+ fi
+
+ DEVPATH=$(dirname $DEVPATH)
+done
diff --git a/Tasks/distribution/inventory/push-inventory.py b/Tasks/distribution/inventory/push-inventory.py
index c8ab8eb..019dfc4 100755
--- a/Tasks/distribution/inventory/push-inventory.py
+++ b/Tasks/distribution/inventory/push-inventory.py
@@ -22,6 +22,7 @@ import os
import commands
import pprint
import math
+import re
sys.path.append('.')
sys.path.append("/usr/lib/anaconda")
@@ -56,6 +57,7 @@ def read_inventory():
data['PCIID'] = []
data['USBID'] = []
data['DISK'] = []
+ data['BOOTDISK'] = []
data['DISKSPACE'] = 0
data['NR_DISKS'] = 0
@@ -98,6 +100,19 @@ def read_inventory():
for module in modules:
data['MODULE'].append(module.split()[0])
+ # Find Active Storage Driver(s)
+ bootdisk = None
+ bootregex = re.compile(r'/dev/([^ ]+) on /boot')
+ disks = commands.getstatusoutput('/bin/mount')[1].split('\n')[1:]
+ for disk in disks:
+ if bootregex.search(disk):
+ bootdisk = bootregex.search(disk).group(1)
+
+ if bootdisk:
+ drivers = commands.getstatusoutput('./getdriver.sh %s' % bootdisk)[1].split('\n')[1:]
+ for driver in drivers:
+ data['BOOTDISK'].append(driver)
+
# Find Active Network interface
iface = None
for line in commands.getstatusoutput('route -n')[1].split('\n'):