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

[PATCH 1/3] Add optional progress windows to devicelibs create functions.



---
 storage/devicelibs/lvm.py    |   22 +++++++++++-----------
 storage/devicelibs/mdraid.py |   14 +++++++-------
 storage/devicelibs/swap.py   |   10 +++++-----
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index 1f7e1c7..2cae3c9 100644
--- a/storage/devicelibs/lvm.py
+++ b/storage/devicelibs/lvm.py
@@ -157,11 +157,11 @@ def clampSize(size, pesize, roundup=None):
 
     return long(round(float(size)/float(pesize)) * pesize)
 
-def lvm(args):
-    rc = iutil.execWithRedirect("lvm", args,
-                                stdout = "/dev/tty5",
-                                stderr = "/dev/tty5",
-                                searchPath=1)
+def lvm(args, progress=None):
+    rc = iutil.execWithPulseProgress("lvm", args,
+                                     stdout = "/dev/tty5",
+                                     stderr = "/dev/tty5",
+                                     progress=progress)
     if not rc:
         return
 
@@ -172,13 +172,13 @@ def lvm(args):
 
     raise LVMError(msg)
 
-def pvcreate(device):
+def pvcreate(device, progress=None):
     args = ["pvcreate"] + \
             config_args + \
             [device]
 
     try:
-        lvm(args)
+        lvm(args, progress=progress)
     except LVMError as msg:
         raise LVMError("pvcreate failed for %s: %s" % (device, msg))
 
@@ -238,7 +238,7 @@ def pvinfo(device):
 
     return info
 
-def vgcreate(vg_name, pv_list, pe_size):
+def vgcreate(vg_name, pv_list, pe_size, progress=None):
     argv = ["vgcreate"]
     if pe_size:
         argv.extend(["-s", "%dm" % pe_size])
@@ -247,7 +247,7 @@ def vgcreate(vg_name, pv_list, pe_size):
     argv.extend(pv_list)
 
     try:
-        lvm(argv)
+        lvm(argv, progress=progress)
     except LVMError as msg:
         raise LVMError("vgcreate failed for %s: %s" % (vg_name, msg))
 
@@ -360,7 +360,7 @@ def lvorigin(vg_name, lv_name):
 
     return origin
 
-def lvcreate(vg_name, lv_name, size):
+def lvcreate(vg_name, lv_name, size, progress=None):
     args = ["lvcreate"] + \
             ["-L", "%dm" % size] + \
             ["-n", lv_name] + \
@@ -368,7 +368,7 @@ def lvcreate(vg_name, lv_name, size):
             [vg_name]
 
     try:
-        lvm(args)
+        lvm(args, progress=progress)
     except LVMError as msg:
         raise LVMError("lvcreate failed for %s/%s: %s" % (vg_name, lv_name, msg))
 
diff --git a/storage/devicelibs/mdraid.py b/storage/devicelibs/mdraid.py
index 73099c4..1a0565c 100644
--- a/storage/devicelibs/mdraid.py
+++ b/storage/devicelibs/mdraid.py
@@ -119,11 +119,11 @@ def get_raid_max_spares(raidlevel, nummembers):
 
     raise ValueError, "invalid raid level %d" % raidlevel
 
-def mdadm(args):
-    rc = iutil.execWithRedirect("mdadm", args,
-                                stdout = "/dev/tty5",
-                                stderr = "/dev/tty5",
-                                searchPath=1)
+def mdadm(args, progress=None):
+    rc = iutil.execWithPulseProgress("mdadm", args,
+                                     stdout = "/dev/tty5",
+                                     stderr = "/dev/tty5",
+                                     progress=progress)
     if not rc:
         return
 
@@ -134,7 +134,7 @@ def mdadm(args):
 
     raise MDRaidError(msg)
 
-def mdcreate(device, level, disks, spares=0):
+def mdcreate(device, level, disks, spares=0, progress=None):
     argv = ["--create", device, "--run", "--level=%s" % level]
     raid_devs = len(disks) - spares
     argv.append("--raid-devices=%d" % raid_devs)
@@ -143,7 +143,7 @@ def mdcreate(device, level, disks, spares=0):
     argv.extend(disks)
     
     try:
-        mdadm(argv)
+        mdadm(argv, progress=progress)
     except MDRaidError as msg:
         raise MDRaidError("mdcreate failed for %s: %s" % (device, msg))
 
diff --git a/storage/devicelibs/swap.py b/storage/devicelibs/swap.py
index bd07f19..d83c730 100644
--- a/storage/devicelibs/swap.py
+++ b/storage/devicelibs/swap.py
@@ -31,7 +31,7 @@ import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 
 
-def mkswap(device, label=''):
+def mkswap(device, label='', progress=None):
     # We use -f to force since mkswap tends to refuse creation on lvs with
     # a message about erasing bootbits sectors on whole disks. Bah.
     argv = ["-f"]
@@ -39,10 +39,10 @@ def mkswap(device, label=''):
         argv.extend(["-L", label])
     argv.append(device)
 
-    rc = iutil.execWithRedirect("mkswap", argv,
-                                stderr = "/dev/tty5",
-                                stdout = "/dev/tty5",
-                                searchPath=1)
+    rc = iutil.execWithPulseProgress("mkswap", argv,
+                                     stderr = "/dev/tty5",
+                                     stdout = "/dev/tty5",
+                                     progress=progress)
 
     if rc:
         raise SwapError("mkswap failed for '%s'" % device)
-- 
1.6.0.6


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