[pve-devel] [PATCH manager] Add wipe_disk to createosd

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Nov 26 18:26:16 CET 2018


On 11/26/18 5:40 PM, Alwin Antreich wrote:
> Factoring the wipe_disk out into CephTools
> 
> Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
> ---
>  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);

hmm, bit strange to call it like that, IMO, either:

PVE::CephTools::wipe_disk({ $devpath => 1 });

or change wipe_disk signature to an array (and rename it to 'wipe_disks')?

So that it could be called like:
wipe_disks($devpath)
for above and
wipe_disks(values %$disks_to_wipe);
for below?

>  
>  	    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;
> 





More information about the pve-devel mailing list