[pve-devel] [PATCH pve-network 3/3] add test statuscheck.pl
Alexandre Derumier
aderumier at odiso.com
Mon Jun 3 17:57:39 CEST 2019
could be reuse later in pvestatd to broadcast status.
---
test/statuscheck.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 test/statuscheck.pl
diff --git a/test/statuscheck.pl b/test/statuscheck.pl
new file mode 100644
index 0000000..0a8a712
--- /dev/null
+++ b/test/statuscheck.pl
@@ -0,0 +1,44 @@
+use strict;
+use warnings;
+use File::Copy;
+use PVE::Cluster qw(cfs_read_file);
+
+use PVE::Network::Network;
+use Data::Dumper;
+use PVE::Network::Network::Plugin;
+use PVE::Network::Network::VnetPlugin;
+use PVE::Network::Network::VlanPlugin;
+use PVE::Network::Network::VxlanMulticastPlugin;
+
+
+my $status = PVE::Network::Network::status();
+
+my $network_cfg = PVE::Cluster::cfs_read_file('networks.cfg');
+my $vnet_cfg = undef;
+my $transport_cfg = undef;
+
+my $vnet_status = {};
+my $transport_status = {};
+
+foreach my $id (keys %{$network_cfg->{ids}}) {
+ if ($network_cfg->{ids}->{$id}->{type} eq 'vnet') {
+ my $transportzone = $network_cfg->{ids}->{$id}->{transportzone};
+ $transport_status->{$transportzone}->{status} = 1 if !defined($transport_status->{$transportzone}->{status});
+
+ if ($status->{$id}->{status} && $status->{$id}->{status} eq 'pass') {
+ $vnet_status->{$id}->{status} = 1;
+ my $bridgeport = $status->{$id}->{config}->{'bridge-ports'};
+
+ if ($status->{$bridgeport}->{status} && $status->{$bridgeport}->{status} ne 'pass') {
+ $vnet_status->{$id}->{status} = 0;
+ $transport_status->{$transportzone}->{status} = 0;
+ }
+ } else {
+ $vnet_status->{$id}->{status} = 0;
+ $transport_status->{$transportzone}->{status} = 0;
+ }
+ }
+}
+
+print Dumper($vnet_status);
+print Dumper($transport_status);
--
2.11.0
More information about the pve-devel
mailing list