From 57a73fe0d4a9d49ffaf952d885ae811b4696ba50 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 26 Apr 2016 17:23:32 -0700 Subject: [PATCH] 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. --- src/pylorax/imgutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py index b77d26a8..ca27e2cd 100644 --- a/src/pylorax/imgutils.py +++ b/src/pylorax/imgutils.py @@ -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)