Commit e651cf0b authored by Dietmar Maurer's avatar Dietmar Maurer

use new logfunc callback for run_command

parent 647069ac
...@@ -65,25 +65,12 @@ sub debugmsg { ...@@ -65,25 +65,12 @@ sub debugmsg {
sub run_command { sub run_command {
my ($logfd, $cmdstr, %param) = @_; my ($logfd, $cmdstr, %param) = @_;
my $returnstdout = $param{returnstdout}; my $logfunc = sub {
delete $param{returnstdout};
my $ostream = 0;
my $outfunc = sub {
my $line = shift; my $line = shift;
$ostream .= "$line\n" if $returnstdout;
debugmsg ('info', $line, $logfd); debugmsg ('info', $line, $logfd);
}; };
my $errfunc = sub { PVE::Tools::run_command($cmdstr, %param, logfunc => $logfunc);
my $line = shift;
debugmsg ('info', $line, $logfd);
};
PVE::Tools::run_command($cmdstr, %param, outfunc => $outfunc, errfunc => $errfunc);
return $returnstdout ? $ostream : undef;
} }
sub storage_info { sub storage_info {
......
...@@ -92,7 +92,8 @@ sub type { ...@@ -92,7 +92,8 @@ sub type {
sub vm_status { sub vm_status {
my ($self, $vmid) = @_; my ($self, $vmid) = @_;
my $status_text = $self->cmd ("vzctl status $vmid", returnstdout => 1); my $status_text = '';
$self->cmd ("vzctl status $vmid", outfunc => sub {$status_text .= shift; });
chomp $status_text; chomp $status_text;
my $running = $status_text =~ m/running/ ? 1 : 0; my $running = $status_text =~ m/running/ ? 1 : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment