[pve-devel] applied: [PATCH manager] network reload: check if recent enough PVE ifupdown2 version is present
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jan 14 11:02:46 CET 2020
We need a recent version *and* our patches on top of the vanilla
ifupdown2:
0001-don-t-remove-tap-veth-fwpr-interfaces-from-bridge-on.patch
0004-don-t-remove-bridge-is-tap-veth-are-still-plugged.patch
So check for at least 1.2.8 and the pve string in the version output.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
PVE/API2/Network.pm | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 20e37781..49a38746 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -538,6 +538,23 @@ __PACKAGE__->register_method({
return $ifaces->{$param->{iface}};
}});
+sub ifupdown2_version {
+ my $v;
+ PVE::Tools::run_command(['ifreload', '-V'], outfunc => sub { $v //= shift });
+ return if !defined($v) || $v !~ /^\s*ifupdown2:(\S+)\s*$/;
+ $v = $1;
+ my ($major, $minor, $extra, $pve) = split(/\.|-/, $v);
+ my $is_pve = defined($pve) && $pve =~ /pve/;
+
+ return ($major * 100000 + $minor * 1000 + $extra * 10, $is_pve, $v);
+}
+sub assert_ifupdown2_installed {
+ die "you need ifupdown2 to reload network configuration\n" if ! -e '/usr/share/ifupdown2';
+ my ($v, $pve, $v_str) = ifupdown2_version();
+ die "incompatible 'ifupdown2' package version '$v_str'! Did you installed from Proxmox repositories?\n"
+ if $v < (1*100000 + 2*1000 + 8*10) || !$pve;
+}
+
__PACKAGE__->register_method({
name => 'reload_network_config',
path => '',
@@ -566,7 +583,7 @@ __PACKAGE__->register_method({
my $current_config_file = "/etc/network/interfaces";
my $new_config_file = "/etc/network/interfaces.new";
- die "you need ifupdown2 to reload networking\n" if !-e '/usr/share/ifupdown2';
+ assert_ifupdown2_installed();
if (-x '/usr/bin/ovs-vsctl') {
my $ovs_configured = sub {
--
2.20.1
More information about the pve-devel
mailing list