[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 1/2] Give pre-existing mdraid arrays the proper name in the UI (#596227)



mdadm --examine reports mdraid set names as /dev/md/# rather then /dev/md#
for some sets.
---
 storage/devicetree.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 99adb06..ec1479e 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1614,7 +1614,11 @@ class DeviceTree(object):
             md_name = devicePathToName(md_info.get("device", ""))
             if md_name:
                 try:
-                    minor = int(md_name[2:])     # strip off leading "md"
+                    # md_name can be either md# or md/#
+                    if md_name.startswith("md/"):
+                        minor = int(md_name[3:])     # strip off leading "md/"
+                    else:
+                        minor = int(md_name[2:])     # strip off leading "md"
                 except (IndexError, ValueError):
                     minor = None
                     md_name = None
-- 
1.7.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]