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.
26 Clears all data from the given path. Path should be
27 an absolute path to an lv or partition.
29 10M of data is written to the path to make sure that
30 there is no trace left of any previous Filesystem.
35 'of={path}'.format(path
=path
),
43 help = 'Removes all data and filesystems from a logical volume or partition.'
45 def __init__(self
, argv
):
48 @decorators.needs_root
51 lv
= api
.get_lv_from_argument(device
)
53 # we are zapping a logical volume
56 # we are zapping a partition
57 #TODO: ensure device is a partition
60 logger
.info("Zapping: %s", path
)
61 terminal
.write("Zapping: %s" % path
)
67 # remove all lvm metadata
70 terminal
.success("Zapping successful for: %s" % path
)
73 sub_command_help
= dedent("""
74 Zaps the given logical volume or partition. If given a path to a logical
75 volume it must be in the format of vg/lv. Any filesystems present
76 on the given lv or partition will be removed and all data will be purged.
78 However, the lv or partition will be kept intact.
80 Example calls for supported scenarios:
82 Zapping a logical volume:
84 ceph-volume lvm zap {vg name/lv name}
88 ceph-volume lvm zap /dev/sdc1
91 parser
= argparse
.ArgumentParser(
92 prog
='ceph-volume lvm zap',
93 formatter_class
=argparse
.RawDescriptionHelpFormatter
,
94 description
=sub_command_help
,
101 help='Path to an lv (as vg/lv) or to a partition like /dev/sda1'
103 if len(self
.argv
) == 0:
104 print(sub_command_help
)
106 args
= parser
.parse_args(self
.argv
)