From e8004c9cb7c4057b8a0317e63eb3aef26cba970d Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 22 Jan 2015 09:37:52 +0100 Subject: [PATCH] zfs: cleanup zfs_request --- PVE/Storage/ZFSPlugin.pm | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm index afa5415..69c6ecc 100644 --- a/PVE/Storage/ZFSPlugin.pm +++ b/PVE/Storage/ZFSPlugin.pm @@ -49,13 +49,10 @@ my $zfs_get_base = sub { sub zfs_request { my ($class, $scfg, $timeout, $method, @params) = @_; - my $cmdmap; - my $zfscmd; - my $target; - my $msg; - $timeout = 5 if !$timeout; + my $msg = ''; + if ($lun_cmds->{$method}) { if ($scfg->{iscsiprovider} eq 'comstar') { $msg = PVE::Storage::LunCmd::Comstar::run_lun_command($scfg, $timeout, $method, @params); @@ -67,22 +64,22 @@ sub zfs_request { $zfs_unknown_scsi_provider->($scfg->{iscsiprovider}); } } else { - if ($method eq 'zpool_list') { - $zfscmd = 'zpool'; - $method = 'list', - } else { - $zfscmd = 'zfs'; - } - $target = 'root@' . $scfg->{portal}; + my $target = 'root@' . $scfg->{portal}; + + my $cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target]; - my $cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, $zfscmd, $method, @params]; + if ($method eq 'zpool_list') { + push @$cmd, 'zpool', 'list'; + } else { + push @$cmd, 'zfs', $method; + } - $msg = ''; + push @$cmd, @params; - my $output = sub { - my $line = shift; - $msg .= "$line\n"; + my $output = sub { + my $line = shift; + $msg .= "$line\n"; }; run_command($cmd, outfunc => $output, timeout => $timeout); -- 2.39.2