]> git.proxmox.com Git - pve-manager.git/commitdiff
Factoring the wipe_disk out into CephTools
authorAlwin Antreich <a.antreich@proxmox.com>
Tue, 27 Nov 2018 15:02:56 +0000 (16:02 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 28 Nov 2018 09:25:16 +0000 (10:25 +0100)
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/API2/Ceph.pm
PVE/CephTools.pm

index 3f2bb11d8fb209985fc44b62babc58c9f1889b78..401c0e5bd2c72292c615e5c939cdeddb543269a0 100644 (file)
@@ -312,6 +312,7 @@ __PACKAGE__->register_method ({
                }
            }
 
+           PVE::CephTools::wipe_disk($devpath);
 
            run_command($cmd);
        };
@@ -439,12 +440,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(keys %$disks_to_wipe);
            }
        };
 
index 8ee34d145026706160491359d78297113e699cb2..8d44562112ebf6be6bd88358d7e7c7527ed970e6 100644 (file)
@@ -469,4 +469,17 @@ sub destroy_mds {
     return undef;
 };
 
+# wipe the first 200 MB to clear off leftovers from previous use, otherwise a
+# create OSD fails.
+sub wipe_disk {
+    my (@devs) = @_;
+
+    my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
+    foreach my $devpath (values @devs) {
+        print "wipe disk: $devpath\n";
+        eval { run_command([@wipe_cmd, "of=${devpath}"]) };
+        warn $@ if $@;
+    }
+};
+
 1;