pylorax: Add delete option to umount
umount tries to delete a mountpoint if it has lorax.imgutils in the path. This doesn't work right if you try to umount something mounted deeper on the path. This adds a delete option, which is True by default, to skip the delete.
This commit is contained in:
parent
6ed2aaed69
commit
57a73fe0d4
@ -198,7 +198,7 @@ def mount(dev, opts="", mnt=None):
|
|||||||
runcmd(cmd)
|
runcmd(cmd)
|
||||||
return mnt
|
return mnt
|
||||||
|
|
||||||
def umount(mnt, lazy=False, maxretry=3, retrysleep=1.0):
|
def umount(mnt, lazy=False, maxretry=3, retrysleep=1.0, delete=True):
|
||||||
'''Unmount the given mountpoint. If lazy is True, do a lazy umount (-l).
|
'''Unmount the given mountpoint. If lazy is True, do a lazy umount (-l).
|
||||||
If the mount was a temporary dir created by mount, it will be deleted.
|
If the mount was a temporary dir created by mount, it will be deleted.
|
||||||
raises CalledProcessError if umount fails.'''
|
raises CalledProcessError if umount fails.'''
|
||||||
@ -221,7 +221,7 @@ def umount(mnt, lazy=False, maxretry=3, retrysleep=1.0):
|
|||||||
sleep(retrysleep)
|
sleep(retrysleep)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if 'lorax.imgutils' in mnt:
|
if delete and 'lorax.imgutils' in mnt:
|
||||||
os.rmdir(mnt)
|
os.rmdir(mnt)
|
||||||
logger.debug("remove tmp mountdir %s", mnt)
|
logger.debug("remove tmp mountdir %s", mnt)
|
||||||
return (rv == 0)
|
return (rv == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user