[pve-devel] [PATCH pve-network 2/2] cleanup status sub

Alexandre Derumier aderumier at odiso.com
Thu Jun 6 08:20:14 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 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.11.0




More information about the pve-devel mailing list