logger.info("Zapping: %s", path)
terminal.write("Zapping: %s" % path)
+ if args.destroy and not lv:
+ # check if there was a pv created with the
+ # name of device
+ pv = api.PVolumes().get(pv_name=device)
+ if pv:
+ logger.info("Found a physical volume created from %s, will destroy all it's vgs and lvs", device)
+ vg_name = pv.vg_name
+ logger.info("Destroying volume group %s because --destroy was given", vg_name)
+ terminal.write("Destroying volume group %s because --destroy was given" % vg_name)
+ api.remove_vg(vg_name)
+
wipefs(path)
zap_data(path)
def main(self):
sub_command_help = dedent("""
- Zaps the given logical volume or partition. If given a path to a logical
- volume it must be in the format of vg/lv. Any filesystems present
- on the given lv or partition will be removed and all data will be purged.
+ Zaps the given logical volume, raw device or partition for reuse by ceph-volume.
+ If given a path to a logical volume it must be in the format of vg/lv. Any
+ filesystems present on the given device/lv/partition will be removed and
+ all data will be purged.
However, the lv or partition will be kept intact.
ceph-volume lvm zap /dev/sdc1
+ If the --destroy flag is given and you are zapping a raw device or partition
+ then all vgs and lvs that exist on that raw device or parition will be destroyed.
+
+ This is especially useful if you've give that raw device or partition to the
+ ceph-volume lvm create or ceph-volume lvm prepare commands previously and now want to
+ reuse that device.
+
+ For example:
+
+ ceph-volume lvm zap /dev/sda --destroy
+
+ If the --destroy flag is given and you are zapping an lv then the lv is still
+ kept intact for reuse.
+
""")
parser = argparse.ArgumentParser(
prog='ceph-volume lvm zap',
'device',
metavar='DEVICE',
nargs='?',
- help='Path to an lv (as vg/lv) or to a partition like /dev/sda1'
+ help='Path to an lv (as vg/lv), partition (as /dev/sda1) or device (as /dev/sda)'
+ )
+ parser.add_argument(
+ '--destroy',
+ action='store_true',
+ default=False,
+ help='Destroy all volume groups and logical volumes if you are zapping a raw device or partition',
)
if len(self.argv) == 0:
print(sub_command_help)