diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-06-07 05:20:21 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-06-07 05:20:21 +0000 |
commit | 203944488d72290e911b0d40c700f4d354884c46 (patch) | |
tree | f99c2a87a71a0edfe1f4a301d897ddb27f7718ab /lvm.py | |
parent | 600c6ec38c2b6f56466c22cc56fd8d2a3f1a51c5 (diff) | |
download | anaconda-203944488d72290e911b0d40c700f4d354884c46.tar.gz anaconda-203944488d72290e911b0d40c700f4d354884c46.tar.xz anaconda-203944488d72290e911b0d40c700f4d354884c46.zip |
add more helper stuff
Diffstat (limited to 'lvm.py')
-rw-r--r-- | lvm.py | 80 |
1 files changed, 66 insertions, 14 deletions
@@ -15,37 +15,89 @@ import iutil import os,sys import string +output = "/tmp/lvmout" + def vgscan(): """Runs vgscan.""" rc = iutil.execWithRedirect("/usr/sbin/vgscan", ["vgscan", "-v"], - stdout = "/tmp/lvmout", - stderr = "/tmp/lvmout", + stdout = output, + stderr = output, searchPath = 1) if rc: raise SystemError, "vgscan failed" -def vgactivate(): - """Activate volume groups by running vgchange -ay.""" +def vgactivate(volgroup = None): + """Activate volume groups by running vgchange -ay. + + volgroup - optional single volume group to activate + """ - rc = iutil.execWithRedirect("/usr/sbin/vgchange", - ["vgchange", "-ay"], - stdout = "/tmp/lvmout", - stderr = "/tmp/lvmout", + args = ["/usr/sbin/vgchange", "-ay"] + if volgroup: + args.append(volgroup) + rc = iutil.execWithRedirect(args[0], args, + stdout = output, + stderr = output, searchPath = 1) if rc: raise SystemError, "vgchange failed" -def vgdeactivate(): - """Deactivate volume groups by running vgchange -an.""" +def vgdeactivate(volgroup = None): + """Deactivate volume groups by running vgchange -an. - rc = iutil.execWithRedirect("/usr/sbin/vgchange", - ["vgchange", "-an"], - stdout = "/tmp/lvmout", - stderr = "/tmp/lvmout", + volgroup - optional single volume group to deactivate + """ + + args = ["/usr/sbin/vgchange", "-an"] + if volgroup: + args.append(volgroup) + rc = iutil.execWithRedirect(args[0], args, + stdout = output, + stderr = output, searchPath = 1) if rc: raise SystemError, "vgchange failed" +def lvremove(lvname, vgname): + """Removes a logical volume. + + lvname - name of logical volume to remove. + vgname - name of volume group lv is in. + """ + + args = ["/usr/sbin/lvremove", "-f"] + dev = "/dev/%s/%s" %(vgname, lvname) + args.append(dev) + + rc = iutil.execWithRedirect(args[0], args, + stdout = output, + stderr = output, + searchPath = 1) + if rc: + raise SystemError, "lvremove failed" + + +def vgremove(vgname): + """Removes a volume group. Deactivates the volume group first + + vgname - name of volume group. + """ + + # we'll try to deactivate... if it fails, we'll probably fail on + # the removal too... but it's worth a shot + try: + vgdeactivate(vgname) + except: + pass + + args = ["/usr/sbin/vgremove", vgname] + + rc = iutil.execWithRedirect(args[0], args, + stdout = output, + stderr = output, + searchPath = 1) + if rc: + raise SystemError, "vgremove failed" |