]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume lvm.zap remove vgs|lvs when --destroy is used
authorAlfredo Deza <adeza@redhat.com>
Tue, 13 Nov 2018 13:30:23 +0000 (08:30 -0500)
committerAlfredo Deza <adeza@redhat.com>
Tue, 13 Nov 2018 22:06:48 +0000 (17:06 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/zap.py

index 70a24f0f776b55b6d10f19eb8d81568f982538cd..8e0e3a3c5e974af2b24fcf636268f8a18d620783 100644 (file)
@@ -108,8 +108,19 @@ class Zap(object):
             zap_data(path)
 
             if lv and not pvs:
-                # remove all lvm metadata
-                lv.clear_tags()
+                if args.destroy:
+                    lvs = api.Volumes()
+                    lvs.filter(vg_name=lv.vg_name)
+                    if len(lvs) <= 1:
+                        mlogger.info('Only 1 LV left in VG, will proceed to destroy volume group %s', lv.vg_name)
+                        api.remove_vg(lv.vg_name)
+                    else:
+                        mlogger.info('More than 1 LV left in VG, will proceed to destroy LV only')
+                        mlogger.info('Removing LV because --destroy was given: %s', lv)
+                        api.remove_lv(lv)
+                else:
+                    # just remove all lvm metadata, leaving the LV around
+                    lv.clear_tags()
 
         terminal.success("Zapping successful for: %s" % ", ".join(args.devices))