From: Alfredo Deza Date: Tue, 30 Jan 2018 14:34:53 +0000 (-0500) Subject: ceph-volume util.system tmp mounts can now remove a dmcrypt mapper X-Git-Tag: v13.0.2~330^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=60e8699650a491013d51239b9dc58160946d3bf9;p=ceph.git ceph-volume util.system tmp mounts can now remove a dmcrypt mapper Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/util/system.py b/src/ceph-volume/ceph_volume/util/system.py index acecc6c8d9b15..952fa56fe5862 100644 --- a/src/ceph-volume/ceph_volume/util/system.py +++ b/src/ceph-volume/ceph_volume/util/system.py @@ -85,11 +85,17 @@ class tmp_mount(object): """ Temporarily mount a device on a temporary directory, and unmount it upon exit + + When ``encrypted`` is set to ``True``, the exit method will call out to + close the device so that it doesn't remain open after mounting. It is + assumed that it will be open because otherwise it wouldn't be possible to + mount in the first place """ - def __init__(self, device): + def __init__(self, device, encrypted=False): self.device = device self.path = None + self.encrypted = encrypted def __enter__(self): self.path = tempfile.mkdtemp() @@ -107,6 +113,10 @@ class tmp_mount(object): '-v', self.path ]) + if self.encrypted: + # avoid a circular import from the encryption module + from ceph_volume.util import encryption + encryption.dmcrypt_close(self.device) def path_is_mounted(path, destination=None):