]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds utilites to wipe the fs and clear data when zapping
authorAndrew Schoen <aschoen@redhat.com>
Thu, 19 Oct 2017 16:44:11 +0000 (11:44 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Fri, 27 Oct 2017 16:15:43 +0000 (11:15 -0500)
These should eventually move to a disk api.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/zap.py

index df44753d93e848c6e31f309791f545a9196ca0bd..e8dfb5eec2cf03ffe896c33dc1dd1206be50cf85 100644 (file)
@@ -3,12 +3,41 @@ import logging
 
 from textwrap import dedent
 
-from ceph_volume import decorators, terminal
+from ceph_volume import decorators, terminal, process
 from ceph_volume.api import lvm as api
 
 logger = logging.getLogger(__name__)
 
 
+def wipefs(path):
+    """
+    Removes the filesystem from an lv or partition.
+    """
+    process.run([
+        'sudo',
+        'wipefs',
+        '--all',
+        path
+    ])
+
+
+def zap_data(path):
+    """
+    Clears all data from the given path. Path should be
+    an absolute path to an lv or partition.
+
+    10M of data is written to the path to make sure that
+    there is no trace left of any previous Filesystem.
+    """
+    process.run([
+        'dd',
+        'if=/dev/zero',
+        'of={path}'.format(path=path),
+        'bs=1M',
+        'count=10',
+    ])
+
+
 class Zap(object):
 
     help = 'Destroy a logical volume or partition.'