[blivet:master 10/14] Extend mdadm() to capture output in the same way as btrfs()
mulhern
amulhern at redhat.com
Wed Jul 16 16:56:41 UTC 2014
Use it in mdexamine()
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devicelibs/mdraid.py | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py
index b8e8615..2f0ac86 100644
--- a/blivet/devicelibs/mdraid.py
+++ b/blivet/devicelibs/mdraid.py
@@ -78,10 +78,18 @@ def get_raid_superblock_size(size, version=None):
log.info("Using %s superBlockSize", headroom)
return headroom
-def mdadm(args):
- ret = util.run_program(["mdadm"] + args)
- if ret:
- raise MDRaidError("running mdadm " + " ".join(args) + " failed")
+def mdadm(args, capture=False):
+ if capture:
+ exec_func = util.capture_output
+ else:
+ exec_func = util.run_program
+
+ argv = ["mdadm"] + args
+
+ ret = exec_func(argv)
+ if ret and not capture:
+ raise MDRaidError(ret)
+ return ret
def mdcreate(device, level, disks, spares=0, metadataVer=None, bitmap=False):
""" Create an mdarray from a list of devices.
@@ -244,10 +252,8 @@ def mdexamine(device):
:rtype: a dict of strings
:returns: a dict containing labels and values extracted from output
"""
- _vars = util.capture_output(["mdadm",
- "--examine", "--export", device]).split()
- _bvars = util.capture_output(["mdadm",
- "--examine", "--brief", device]).split()
+ _vars = mdadm(["--examine", "--export", device], capture=True).split()
+ _bvars = mdadm(["--examine", "--brief", device], capture=True).split()
info = {}
if len(_bvars) > 1 and _bvars[1].startswith("/dev/md"):
--
1.9.3
More information about the anaconda-patches
mailing list