4 from textwrap import dedent
6 from ceph_volume import decorators, terminal, process
7 from ceph_volume.api import lvm as api
9 logger = logging.getLogger(__name__)
14 Removes the filesystem from an lv or partition.
25 Clears all data from the given path. Path should be
26 an absolute path to an lv or partition.
28 10M of data is written to the path to make sure that
29 there is no trace left of any previous Filesystem.
34 'of={path}'.format(path=path),
42 help = 'Removes all data and filesystems from a logical volume or partition.'
44 def __init__(self, argv):
47 @decorators.needs_root
50 lv = api.get_lv_from_argument(device)
52 # we are zapping a logical volume
55 # we are zapping a partition
56 #TODO: ensure device is a partition
59 logger.info("Zapping: %s", path)
60 terminal.write("Zapping: %s" % path)
66 # remove all lvm metadata
69 terminal.success("Zapping successful for: %s" % path)
72 sub_command_help = dedent("""
73 Zaps the given logical volume or partition. If given a path to a logical
74 volume it must be in the format of vg/lv. Any filesystems present
75 on the given lv or partition will be removed and all data will be purged.
77 However, the lv or partition will be kept intact.
79 Example calls for supported scenarios:
81 Zapping a logical volume:
83 ceph-volume lvm zap {vg name/lv name}
87 ceph-volume lvm zap /dev/sdc1
90 parser = argparse.ArgumentParser(
91 prog='ceph-volume lvm zap',
92 formatter_class=argparse.RawDescriptionHelpFormatter,
93 description=sub_command_help,
100 help='Path to an lv (as vg/lv) or to a partition like /dev/sda1'
102 if len(self.argv) == 0:
103 print(sub_command_help)
105 args = parser.parse_args(self.argv)