--- PVE/Network/Network.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/PVE/Network/Network.pm b/PVE/Network/Network.pm index ee0b973..3a33ecd 100644 --- a/PVE/Network/Network.pm +++ b/PVE/Network/Network.pm @@ -3,6 +3,8 @@ package PVE::Network::Network; use strict; use warnings; use Data::Dumper; +use JSON; +use PVE::Tools qw(extract_param dir_glob_regex); use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file); use PVE::Network::Network::Plugin; use PVE::Network::Network::VnetPlugin; @@ -62,4 +64,30 @@ sub complete_network { return $cmdname eq 'add' ? [] : [ PVE::Network::Network::networks_ids($cfg) ]; } +sub status { + + my $cmd = ['ifquery', '-a', '-c', '-o','json']; + my $result;; + + my $code = sub { + my $line = shift; + $result .= $line; + }; + + eval { + PVE::Tools::run_command($cmd, outfunc => $code, errfunc => $code); + }; + + my $resultjson = JSON::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'}; + } + + return $interfaces; +} + 1; -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel