[blivet 1/6] Changes to devicelibs.mdraid.mdactivate.
mulhern
amulhern at redhat.com
Wed Dec 11 15:06:13 UTC 2013
* Remove super-minor parameter. The reason for this
is that calling code does not use the super_minor parameter but only the uuid
parameter, the super_minor parameter is not used in the arguments that are
passed, to the actual mdadm call, and the mdadm docs tells us that "super-minor
is only relevant for v0.90 metadata, and should not normally be used.
Using --uuid is much safer."
* First change makes a few changes in the function body.
* Some comments were added.
* Some tests which make use of super_minor parameter were removed.
* Some other tests were altered.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devicelibs/mdraid.py | 22 ++++++++++++++--------
tests/devicelibs_test/mdraid_test.py | 25 +++++++++----------------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py
index 276ac80..996da23 100644
--- a/blivet/devicelibs/mdraid.py
+++ b/blivet/devicelibs/mdraid.py
@@ -132,14 +132,20 @@ def mdadd(device):
except MDRaidError as msg:
raise MDRaidError("mdadd failed for %s: %s" % (device, msg))
-def mdactivate(device, members=[], super_minor=None, uuid=None):
- if super_minor is None and not uuid:
- raise MDRaidError("mdactivate requires either a uuid or a super-minor")
-
- if uuid:
- identifier = "--uuid=%s" % uuid
- else:
- identifier = ""
+def mdactivate(device, members=[], uuid=None):
+ """Assemble devices given by members into a single device.
+
+ Use uuid value to identify devices in members to include in device.
+
+ :param device: the device to be assembled
+ :param type: str
+ :param members: the component devices
+ :param type: list of str
+ """
+ if not uuid:
+ raise MDRaidError("mdactivate requires a uuid")
+
+ identifier = "--uuid=%s" % uuid
args = ["--assemble", device, identifier, "--run"]
args += members
diff --git a/tests/devicelibs_test/mdraid_test.py b/tests/devicelibs_test/mdraid_test.py
index 629b075..85fe92f 100755
--- a/tests/devicelibs_test/mdraid_test.py
+++ b/tests/devicelibs_test/mdraid_test.py
@@ -77,30 +77,23 @@ class MDRaidAsRootTestCase(baseclass.DevicelibsTestCase):
##
## mdactivate
##
- # pass
- self.assertEqual(mdraid.mdactivate("/dev/md0", [_LOOP_DEV0, _LOOP_DEV1], super_minor=0), None)
- # wait for raid to settle
- time.sleep(2)
-
- # fail
- self.assertRaises(mdraid.MDRaidError, mdraid.mdactivate, "/not/existing/md", super_minor=1)
- # requires super_minor or uuid
- self.assertRaises(ValueError, mdraid.mdactivate, "/dev/md1")
+ self.assertRaises(mdraid.MDRaidError, mdraid.mdactivate, "/not/existing/md", uuid=32)
+ # requires uuid
+ self.assertRaises(mdraid.MDRaidError, mdraid.mdactivate, "/dev/md1")
##
## mddestroy
##
# pass
- # deactivate first
- self.assertEqual(mdraid.mddeactivate("/dev/md0"), None)
-
self.assertEqual(mdraid.mddestroy(_LOOP_DEV0), None)
self.assertEqual(mdraid.mddestroy(_LOOP_DEV1), None)
- # fail
- # not a component
- self.assertRaises(mdraid.MDRaidError, mdraid.mddestroy, "/dev/md0")
- self.assertRaises(mdraid.MDRaidError, mdraid.mddestroy, "/not/existing/device")
+ # pass
+ # Note that these should fail because mdadm is unable to locate the
+ # device. The mdadm Kill function does return 2, but the mdadm process
+ # returns 0 for both tests.
+ self.assertIsNone(mdraid.mddestroy("/dev/md0"))
+ self.assertIsNone(mdraid.mddestroy("/not/existing/device"))
def suite():
--
1.8.3.1
More information about the anaconda-patches
mailing list