diff options
author | David Cantrell <dcantrell@redhat.com> | 2009-07-10 09:58:35 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2009-07-13 14:07:34 -1000 |
commit | edf45a43a2dd6142de1ca407b9e344b427c8e4c3 (patch) | |
tree | 3ace6c029b87c44cde4f6efce9c563abe1615958 /storage | |
parent | 7e220fa8a708acbdd8c4fb4865d9bf589bd065bd (diff) | |
download | anaconda-edf45a43a2dd6142de1ca407b9e344b427c8e4c3.tar.gz anaconda-edf45a43a2dd6142de1ca407b9e344b427c8e4c3.tar.xz anaconda-edf45a43a2dd6142de1ca407b9e344b427c8e4c3.zip |
Add deviceNameToDiskByPath().
This function takes a device name (e.g., sda) and returns the link name
that it matches in /dev/disk/by-path. Used to help people with many
similar named devices (hundreds of DASDs, for example).
Diffstat (limited to 'storage')
-rw-r--r-- | storage/devices.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/storage/devices.py b/storage/devices.py index e2367105f..d8b437800 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -143,6 +143,23 @@ def devicePathToName(devicePath): return name +def deviceNameToDiskByPath(deviceName=None): + bypath = '/dev/disk/by-path' + + if not deviceName: + return "" + + if not os.path.isdir(bypath): + return "" + + for path in os.listdir(bypath): + target = os.path.basename(os.readlink(bypath + '/' + path)) + if target == deviceName: + return path + + return "" + + class Device(object): """ A generic device. |