[pve-devel] [PATCH v2 pve-network 06/15] improve status error description

Alexandre Derumier aderumier at odiso.com
Tue Nov 26 10:00:21 CET 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Network/SDN/Zones/Content.pm |  6 ++++++
 PVE/Network/SDN/Zones.pm              | 16 ++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Network/SDN/Zones/Content.pm b/PVE/API2/Network/SDN/Zones/Content.pm
index 18dcb4c..94536fb 100644
--- a/PVE/API2/Network/SDN/Zones/Content.pm
+++ b/PVE/API2/Network/SDN/Zones/Content.pm
@@ -49,6 +49,11 @@ __PACKAGE__->register_method ({
 		    type => 'string',
 		    optional => 1,
 		},
+		statusmsg => {
+		    description => "Status details",
+		    type => 'string',
+		    optional => 1,
+		},
 	    },
 	},
 	links => [ { rel => 'child', href => "{vnet}" } ],
@@ -70,6 +75,7 @@ __PACKAGE__->register_method ({
 	    if ($vnet_status->{$id}->{zone} eq $transportid) {
 		my $item->{vnet} = $id;
 		$item->{status} = $vnet_status->{$id}->{'status'};
+		$item->{status} = $vnet_status->{$id}->{'statusmsg'};
 		push @$res,$item;
 	    }
         }
diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
index ba31db9..d481d5c 100644
--- a/PVE/Network/SDN/Zones.pm
+++ b/PVE/Network/SDN/Zones.pm
@@ -178,8 +178,9 @@ sub status {
     return if !-e $cluster_vnet_file && !-e $cluster_transport_file;
 
     if (!-e $local_sdn_file) {
-	warn "local sdn network configuration is not yet generated, please reload";
-	$err_config = 'pending';
+
+	$err_config = "local sdn network configuration is not yet generated, please reload";
+	warn $err_config;
     } else {
 	# fixme : use some kind of versioning info?
 	my $cluster_vnet_timestamp = (stat($cluster_vnet_file))[9];
@@ -187,8 +188,8 @@ sub status {
 	my $local_sdn_timestamp = (stat($local_sdn_file))[9];
 
 	if ($local_sdn_timestamp < $cluster_vnet_timestamp || $local_sdn_timestamp < $cluster_transport_timestamp) {
-	    warn "local sdn network configuration is too old, please reload";
-	    $err_config = 'pending';
+	    $err_config = "local sdn network configuration is too old, please reload";
+	    warn $err_config;
         }
     }
 
@@ -205,18 +206,21 @@ sub status {
 	$transport_status->{$zone}->{status} = 'available' if !defined($transport_status->{$zone}->{status});
 
 	if($err_config) {
-	    $vnet_status->{$id}->{status} = $err_config;
-	    $transport_status->{$zone}->{status} = $err_config;
+	    $vnet_status->{$id}->{status} = 'pending';
+	    $vnet_status->{$id}->{statusmsg} = $err_config;
+	    $transport_status->{$zone}->{status} = 'pending';
 	} elsif ($status->{$id}->{status} && $status->{$id}->{status} eq 'pass') {
 	    $vnet_status->{$id}->{status} = 'available';
 	    my $bridgeport = $status->{$id}->{config}->{'bridge-ports'};
 
 	    if ($status->{$bridgeport}->{status} && $status->{$bridgeport}->{status} ne 'pass') {
 		$vnet_status->{$id}->{status} = 'error';
+		$vnet_status->{$id}->{statusmsg} = 'configuration not fully applied';
 		$transport_status->{$zone}->{status} = 'error';
 	    }
 	} else {
 	    $vnet_status->{$id}->{status} = 'error';
+	    $vnet_status->{$id}->{statusmsg} = 'missing';
 	    $transport_status->{$zone}->{status} = 'error';
 	}
     }
-- 
2.20.1




More information about the pve-devel mailing list