summaryrefslogtreecommitdiffstats
path: root/storage/devicelibs
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2010-01-14 23:17:42 -0500
committerPeter Jones <pjones@redhat.com>2010-01-20 16:55:30 -0500
commita7cd186fb14ecd1429799f06820e2e4f214d97be (patch)
tree64a5cb527e6532c97e8e006d557cbc8b797174ec /storage/devicelibs
parente841139cf9486aa1f1ca50c15e2086c323d5370e (diff)
downloadanaconda-a7cd186fb14ecd1429799f06820e2e4f214d97be.tar.gz
anaconda-a7cd186fb14ecd1429799f06820e2e4f214d97be.tar.xz
anaconda-a7cd186fb14ecd1429799f06820e2e4f214d97be.zip
Add a parser for 'multipath -d' output.
We need to find out about multipath topology from /sbin/multipath, which unfortunately needs some parsing - it's fairly easy, though.
Diffstat (limited to 'storage/devicelibs')
-rw-r--r--storage/devicelibs/mpath.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/storage/devicelibs/mpath.py b/storage/devicelibs/mpath.py
index 67c60f0c8..322df8e40 100644
--- a/storage/devicelibs/mpath.py
+++ b/storage/devicelibs/mpath.py
@@ -1,5 +1,52 @@
from ..udev import *
+def parseMultipathOutput(output):
+ # this function parses output from "multipath -d", so we can use its
+ # logic for our topology.
+ # The input looks like:
+ # create: mpathb (1ATA ST3120026AS 5M) undef ATA,ST3120026AS
+ # size=112G features='0' hwhandler='0' wp=undef
+ # `-+- policy='round-robin 0' prio=1 status=undef
+ # `- 2:0:0:0 sda 8:0 undef ready running
+ # create: mpatha (36006016092d21800703762872c60db11) undef DGC,RAID 5
+ # size=10G features='1 queue_if_no_path' hwhandler='1 emc' wp=undef
+ # `-+- policy='round-robin 0' prio=2 status=undef
+ # |- 6:0:0:0 sdb 8:16 undef ready running
+ # `- 7:0:0:0 sdc 8:32 undef ready running
+ #
+ # (In anaconda, the first one there won't be included because we blacklist
+ # "ATA" as a vendor.)
+ #
+ # It returns a structure like:
+ # [ {'mpatha':['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