Factoring the wipe_disk out into CephTools

Signed-off-by: Alwin Antreich <[email protected]>
---
 PVE/API2/Ceph.pm | 11 +++++------
 PVE/CephTools.pm | 11 +++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index d74bd016..ec9bce64 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -312,6 +312,9 @@ __PACKAGE__->register_method ({
                }
            }
 
+           my $disks_to_wipe = {};
+           $disks_to_wipe->{$devpath} = 1;
+           PVE::CephTools::wipe_disk($disks_to_wipe);
 
            run_command($cmd);
        };
@@ -439,12 +442,8 @@ __PACKAGE__->register_method ({
                foreach my $part (@$partitions_to_remove) {
                    $remove_partition->($part);
                }
-               my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 
conv=fdatasync);
-               foreach my $devpath (keys %$disks_to_wipe) {
-                   print "wipe disk: $devpath\n";
-                   eval { run_command([@wipe_cmd, "of=${devpath}"]) };
-                   warn $@ if $@;
-               }
+
+               PVE::CephTools::wipe_disk($disks_to_wipe);
            }
        };
 
diff --git a/PVE/CephTools.pm b/PVE/CephTools.pm
index d80e2b65..e17dee93 100644
--- a/PVE/CephTools.pm
+++ b/PVE/CephTools.pm
@@ -465,4 +465,15 @@ sub destroy_mds {
     return undef;
 };
 
+sub wipe_disk {
+    my ($disks_to_wipe) = @_;
+
+    my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
+    foreach my $devpath (keys %$disks_to_wipe) {
+        print "wipe disk: $devpath\n";
+        eval { run_command([@wipe_cmd, "of=${devpath}"]) };
+        warn $@ if $@;
+    }
+};
+
 1;
-- 
2.11.0


_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to