[PATCH 11/19] Add a parser for 'multipath -d' output.

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

 



We need to find out about multipath topology from /sbin/multipath, which
unfortunately needs some parsing - it's fairly easy, though.
---
 storage/devicelibs/mpath.py |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/storage/devicelibs/mpath.py b/storage/devicelibs/mpath.py
index 733437d..4d1b262 100644
--- a/storage/devicelibs/mpath.py
+++ b/storage/devicelibs/mpath.py
@@ -1,5 +1,37 @@
 from ..udev import *
 
+def parseMultipathOutput(output):
+    # this function parses output from "multipath -d", so we can use its
+    # logic for our topology.  It returns a structure like:
+    # [ {'mpathb':['sdb','sdc']}, ... ]
+    mpaths = {}
+
+    name = None
+    devices = []
+
+    lines = output.split('\n')
+    for line in lines:
+        lexemes = line.split()
+        if not lexemes:
+            break
+        if lexemes[0] == 'create:':
+            if name and devices:
+                mpaths.append(mpath)
+                name = None
+                devices = []
+            name = lexemes[1]
+        elif lexemes[0].startswith('size='):
+            pass
+        elif lexemes[0] == '`-+-':
+            pass
+        elif lexemes[0] in ['|-','`-']:
+            devices.append(lexemes[2])
+    
+    if name and devices:
+        mpaths[name] = devices
+
+    return mpaths
+
 def identifyMultipaths(devices):
     # this function does a couple of things
     # 1) identifies multipath disks
-- 
1.6.5.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux