]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds support to zap encrypted devices, lvs, and partitions
authorAndrew Schoen <aschoen@redhat.com>
Wed, 21 Feb 2018 20:28:06 +0000 (14:28 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 22 Feb 2018 16:46:11 +0000 (10:46 -0600)
Fixes: http://tracker.ceph.com/issues/22878
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/zap.py

index 10d348ceadfdb4ed4f63abd5939a329f06f78b9e..279419c2e5377b08cba9cc767e320280729d945c 100644 (file)
@@ -5,7 +5,7 @@ from textwrap import dedent
 
 from ceph_volume import decorators, terminal, process
 from ceph_volume.api import lvm as api
-from ceph_volume.util import system
+from ceph_volume.util import system, encryption, disk
 
 logger = logging.getLogger(__name__)
 mlogger = terminal.MultiLogger(__name__)
@@ -67,11 +67,27 @@ class Zap(object):
             vg_name = pv.vg_name
             lv = api.get_lv(vg_name=vg_name)
 
+        dmcrypt = False
+        dmcrypt_uuid = None
         if lv:
             osd_path = "/var/lib/ceph/osd/{}-{}".format(lv.tags['ceph.cluster_name'], lv.tags['ceph.osd_id'])
+            dmcrypt_uuid = lv.lv_uuid
+            dmcrypt = lv.tags.get('ceph.encrypted', '0') == '1'
             if system.path_is_mounted(osd_path):
                 mlogger.info("Unmounting %s", osd_path)
                 system.unmount(osd_path)
+        else:
+            # we're most likely dealing with a partition here, check to
+            # see if it was encrypted
+            partuuid = disk.get_partuuid(device)
+            if encryption.status("/dev/mapper/{}".format(partuuid)):
+                dmcrypt_uuid = partuuid
+                dmcrypt = True
+
+        if dmcrypt and dmcrypt_uuid:
+            dmcrypt_path = "/dev/mapper/{}".format(dmcrypt_uuid)
+            mlogger.info("Closing encrypted path %s", dmcrypt_path)
+            encryption.dmcrypt_close(dmcrypt_path)
 
         if args.destroy and pv:
             logger.info("Found a physical volume created from %s, will destroy all it's vgs and lvs", device)