summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--storage/devices.py17
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.