5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2024-12-22 13:34:16 +03:00

zfs diskmanage: code/indentation cleanup in get_pool_data

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-11-11 08:01:14 +01:00
parent 0bcfafa471
commit 8b06da647a

View File

@ -19,9 +19,7 @@ my $ZPOOL = '/sbin/zpool';
my $ZFS = '/sbin/zfs';
sub get_pool_data {
if (!-f $ZPOOL) {
die "zfsutils-linux not installed\n";
}
die "zfsutils-linux not installed\n" if ! -f $ZPOOL;
my $propnames = [qw(name size alloc free frag dedup health)];
my $numbers = {
@ -32,24 +30,21 @@ sub get_pool_data {
dedup => 1,
};
my $cmd = [$ZPOOL,'list', '-HpPLo', join(',', @$propnames)];
my $pools = [];
run_command($cmd, outfunc => sub {
run_command([$ZPOOL, 'list', '-HpPLo', join(',', @$propnames)], outfunc => sub {
my ($line) = @_;
my @props = split('\s+', trim($line));
my $pool = {};
for (my $i = 0; $i < scalar(@$propnames); $i++) {
if ($numbers->{$propnames->[$i]}) {
$pool->{$propnames->[$i]} = $props[$i] + 0;
} else {
$pool->{$propnames->[$i]} = $props[$i];
}
my @props = split('\s+', trim($line));
my $pool = {};
for (my $i = 0; $i < scalar(@$propnames); $i++) {
if ($numbers->{$propnames->[$i]}) {
$pool->{$propnames->[$i]} = $props[$i] + 0;
} else {
$pool->{$propnames->[$i]} = $props[$i];
}
}
push @$pools, $pool;
push @$pools, $pool;
});
return $pools;