diff options
| author | Alexandre Derumier <aderumier@odiso.com> | 2023-06-23 14:49:41 +0200 | 
|---|---|---|
| committer | Fabian Grünbichler <f.gruenbichler@proxmox.com> | 2023-07-19 11:46:53 +0200 | 
| commit | 26e2abdbdc7051c6c2d3dad88231b4dbd8896a35 (patch) | |
| tree | aa7217cb962aa10b93556848ca21178cbfabb29c | |
| parent | 0eda9b9aadc8f451fd5b538ec0c0910a80c19bd2 (diff) | |
zones: status: display specific message if vnet is not generated.
also cleanup duplicate code in plugins
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
| -rw-r--r-- | src/PVE/Network/SDN/Zones/Plugin.pm | 16 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Zones/QinQPlugin.pm | 8 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Zones/SimplePlugin.pm | 17 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Zones/VlanPlugin.pm | 8 | 
4 files changed, 14 insertions, 35 deletions
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm index 2c707b3..89f53d9 100644 --- a/src/PVE/Network/SDN/Zones/Plugin.pm +++ b/src/PVE/Network/SDN/Zones/Plugin.pm @@ -190,13 +190,12 @@ sub parse_tag_number_or_range {      return (scalar(@elements) > 1);  } -sub status { -    my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_; +sub generate_status_message { +    my ($class, $vnetid, $status, $ifaces) = @_;      my $err_msg = []; -    # ifaces to check -    my $ifaces = [ $vnetid ]; +    return ["vnet is not generated. Please check you reload network task log."] if !$status->{$vnetid}->{status};      foreach my $iface (@{$ifaces}) {          if (!$status->{$iface}->{status}) { @@ -205,7 +204,16 @@ sub status {  	    push @$err_msg, "error $iface";          }      } + +    return $err_msg; +} + +sub status { +    my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_; + +    my $err_msg = $class->generate_status_message($vnetid, $status);      return $err_msg; +  } diff --git a/src/PVE/Network/SDN/Zones/QinQPlugin.pm b/src/PVE/Network/SDN/Zones/QinQPlugin.pm index 8b9de43..7160434 100644 --- a/src/PVE/Network/SDN/Zones/QinQPlugin.pm +++ b/src/PVE/Network/SDN/Zones/QinQPlugin.pm @@ -198,13 +198,7 @@ sub status {  	push @$ifaces, $svlan_iface;      } -    foreach my $iface (@{$ifaces}) { -	if (!$status->{$iface}->{status}) { -	    push @$err_msg, "missing $iface"; -        } elsif ($status->{$iface}->{status} ne 'pass') { -	    push @$err_msg, "error $iface"; -	} -    } +    $err_msg = $class->generate_status_message($vnetid, $status, $ifaces);      return $err_msg;  } diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm index 7757747..4922903 100644 --- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm +++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -123,23 +123,6 @@ sub generate_sdn_config {      return $config;  } -sub status { -    my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_; - -    # ifaces to check -    my $ifaces = [ $vnetid ]; -    my $err_msg = []; -    foreach my $iface (@{$ifaces}) { -	if (!$status->{$iface}->{status}) { -	    push @$err_msg, "missing $iface"; -	} elsif ($status->{$iface}->{status} ne 'pass') { -	    push @$err_msg, "error iface $iface"; -	} -    } -    return $err_msg; -} - -  sub vnet_update_hook {      my ($class, $vnet_cfg, $vnetid, $zone_cfg) = @_; diff --git a/src/PVE/Network/SDN/Zones/VlanPlugin.pm b/src/PVE/Network/SDN/Zones/VlanPlugin.pm index 0bb6b8a..f39b71d 100644 --- a/src/PVE/Network/SDN/Zones/VlanPlugin.pm +++ b/src/PVE/Network/SDN/Zones/VlanPlugin.pm @@ -165,13 +165,7 @@ sub status {  	push @$ifaces, $vnet_uplinkpeer;      } -    foreach my $iface (@{$ifaces}) { -	if (!$status->{$iface}->{status}) { -	    push @$err_msg, "missing $iface"; -        } elsif ($status->{$iface}->{status} ne 'pass') { -	    push @$err_msg, "error iface $iface"; -	} -    } +    $err_msg = $class->generate_status_message($vnetid, $status, $ifaces);      return $err_msg;  }  | 
