summaryrefslogtreecommitdiffstats
path: root/raid.py
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-12-28 21:03:45 +0000
committerErik Troan <ewt@redhat.com>1999-12-28 21:03:45 +0000
commitb7ef719e9d03a64316e388a55038a4350c8173bf (patch)
tree6861cbde7b06d28a475f0fac328bbb24585dd8ac /raid.py
parent9ce3251edc7ab07686bb914cfb370268e870d4a6 (diff)
downloadanaconda-b7ef719e9d03a64316e388a55038a4350c8173bf.tar.gz
anaconda-b7ef719e9d03a64316e388a55038a4350c8173bf.tar.xz
anaconda-b7ef719e9d03a64316e388a55038a4350c8173bf.zip
*** empty log message ***
Diffstat (limited to 'raid.py')
-rw-r--r--raid.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/raid.py b/raid.py
new file mode 100644
index 000000000..98c90e0a3
--- /dev/null
+++ b/raid.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+
+import _balkan
+import isys
+import os
+
+def scanForRaid(drives):
+ for d in drives:
+ isys.makeDevInode(d, "/tmp/" + d)
+ parts = _balkan.readTable('/tmp/' + d)
+ os.remove("/tmp/" + d)
+ raidSets = {}
+ raidDevices = {}
+ for i in range(0, len(parts) - 1):
+ (type, start, size) = parts[i]
+ if type != 7: continue
+
+ dev = "%s%d" % (d, i + 1)
+
+ (major, minor, raidSet, level, nrDisks, totalDisks, mdMinor) = \
+ isys.raidsb(dev)
+
+ if raidSets.has_key(raidSet):
+ (knownLevel, knownDisks, knownMinor, knownDevices) = \
+ raidSets[raidSet]
+ if knownLevel != level or knownDisks != totalDisks or \
+ knownMinor != mdMinor:
+ # Raise hell
+ pass
+ knownDevices.append(dev)
+ else:
+ raidSets[raidSet] = (level, totalDisks, mdMinor, [dev,])
+
+ if raidDevices.has_key(mdMinor):
+ if (raidDevices[mdMinor] != raidSet):
+ # Raise hell
+ pass
+ else:
+ raidDevices[mdMinor] = raidSet
+
+ raidList = []
+ for key in raidSets.keys():
+ (level, totalDisks, mdMinor, devices) = raidSets[key]
+ if len(devices) != totalDisks:
+ # raise hell
+ pass
+ raidList.append((mdMinor, devices))
+
+ return raidList
+
+def startAllRaid(driveList):
+ mdList = []
+ for (mdDevice, deviceList) in scanForRaid(['sda']):
+ devName = "md%d" % (mdDevice,)
+ isys.raidstart(devName, deviceList[0])
+ mdList.append(devName)
+ return mdList
+
+def stopAllRaid(mdList):
+ for dev in mdList:
+ isys.raidstop(dev)