]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
util/system: add unmount_tmpfs helper
authorJan Fajerski <jfajerski@suse.com>
Thu, 12 Dec 2019 08:28:27 +0000 (09:28 +0100)
committerJan Fajerski <jfajerski@suse.com>
Thu, 12 Dec 2019 13:55:04 +0000 (14:55 +0100)
Thsi unmounts a path if and only if it's a tmpfs mount.

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/ceph-volume/ceph_volume/util/system.py

index 5aaca59af7557f4310ce936c6917d28cff2312a8..775be4e708be7dc4dfd03bd4e6f7386ac4a96f53 100644 (file)
@@ -164,6 +164,19 @@ class tmp_mount(object):
             encryption.dmcrypt_close(self.device)
 
 
+def unmount_tmpfs(path):
+    """
+    Removes the mount at the given path iff the path is a tmpfs mount point.
+    Otherwise no action is taken.
+    """
+    _out, _err, rc = process.call(['findmnt', '-t', 'tmpfs', '-M', path])
+    if rc != 0:
+        logger.info('{} does not appear to be a tmpfs mount'.format(path))
+    else:
+        logger.info('Unmounting tmpfs path at {}'.format( path))
+        unmount(path)
+
+
 def unmount(path):
     """
     Removes mounts at the given path