From 6e9fff39fd8bd7e980cc16b9a97ffe46bf7b9685 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Thu, 6 Jun 2019 08:20:14 +0200 Subject: [PATCH] cleanup status sub don't mix stderr and stdout of the ifquery command, as it can break JSON encoding afterweards Signed-off-by: Alexandre Derumier Signed-off-by: Thomas Lamprecht --- PVE/Network/Network.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PVE/Network/Network.pm b/PVE/Network/Network.pm index a89e302..a95b2c2 100644 --- a/PVE/Network/Network.pm +++ b/PVE/Network/Network.pm @@ -73,16 +73,19 @@ sub status { my $reader = sub { $result .= shift }; eval { - run_command($cmd, outfunc => $reader, errfunc => $reader); + run_command($cmd, outfunc => $reader); }; - my $resultjson = JSON::decode_json($result); + my $resultjson = decode_json($result); my $interfaces = {}; foreach my $interface (@$resultjson) { - $interfaces->{$interface->{'name'}}->{status} = $interface->{'status'}; - $interfaces->{$interface->{'name'}}->{config} = $interface->{'config'}; - $interfaces->{$interface->{'name'}}->{config_status} = $interface->{'config_status'}; + my $name = $interface->{name}; + $interfaces->{$name} = { + status => $interface->{status}, + config => $interface->{config}, + config_status => $interface->{config_status}, + }; } return $interfaces; -- 2.39.5