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:
Brian C. Lane 2016-04-26 17:23:32 -07:00
parent 6ed2aaed69
commit 57a73fe0d4

View File

@ -198,7 +198,7 @@ def mount(dev, opts="", mnt=None):
runcmd(cmd)
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).
If the mount was a temporary dir created by mount, it will be deleted.
raises CalledProcessError if umount fails.'''
@ -221,7 +221,7 @@ def umount(mnt, lazy=False, maxretry=3, retrysleep=1.0):
sleep(retrysleep)
else:
break
if 'lorax.imgutils' in mnt:
if delete and 'lorax.imgutils' in mnt:
os.rmdir(mnt)
logger.debug("remove tmp mountdir %s", mnt)
return (rv == 0)