Set provider mode when formatting network interfaces file on Debian
When the interfaces file is generated it is necessary to determine the mode (vlan or raw) from the interface name. Originally the plugin considers that a previous interfaces file exists and will use it to set the mode value. But on StarlingX network_config is generated by sysinv and there is no previous file to parse, so this change adds the mode logic on file formatting. Test Plan: PASS: generate valid ifupdown config when interface name is of format "vlanNNN" on Debian and apply it with ifup/ifdown command Story: 2009101 Task: 44659 Signed-off-by: Andre Fernando Zanella Kantek <AndreFernandoZanella.Kantek@windriver.com> Change-Id: Ibccd189ea14eed4b8504908188fabedfa6bf4c2a
This commit is contained in:
parent
9b0fb8e455
commit
d0a4cdcb1e
@ -0,0 +1,68 @@
|
||||
From 800d2d360068874b306735cd000b657c55cbb0f4 Mon Sep 17 00:00:00 2001
|
||||
From: Andre Fernando Zanella Kantek
|
||||
<AndreFernandoZanella.Kantek@windriver.com>
|
||||
Date: Wed, 2 Mar 2022 13:32:03 -0300
|
||||
Subject: [PATCH] set provider mode when formatting interfaces file
|
||||
|
||||
When the interfaces file is generated it is necessary to determine the
|
||||
mode (vlan or raw) from the interface name. Originally the plugin
|
||||
considers that a previous interfaces file exists and will use it to
|
||||
set the mode value.
|
||||
|
||||
But on StarlingX network_config is generated by sysinv and there is no
|
||||
previous file to parse, so this change adds the mode logic on
|
||||
file formatting.
|
||||
|
||||
Signed-off-by: Andre Fernando Zanella Kantek <AndreFernandoZanella.Kantek@windriver.com>
|
||||
---
|
||||
.../provider/network_config/interfaces.rb | 25 ++++++++++++++++++-
|
||||
1 file changed, 24 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb
|
||||
index d72ab45..f16d082 100644
|
||||
--- a/lib/puppet/provider/network_config/interfaces.rb
|
||||
+++ b/lib/puppet/provider/network_config/interfaces.rb
|
||||
@@ -200,9 +200,15 @@ Puppet::Type.type(:network_config).provide(:interfaces) do
|
||||
# 'vlan22'
|
||||
when %r{^vlan}
|
||||
:vlan
|
||||
- # 'eth2.0003' or 'br1.2'
|
||||
+ # 'eno1.0003' or 'br1.0002'
|
||||
when %r{^[a-z]{1,}[0-9]{1,}\.[0-9]{1,4}}
|
||||
:vlan
|
||||
+ # 'enp0s9.0003'
|
||||
+ when %r{^[a-z]{1,}[0-9]{1,}[a-z]{1,}[0-9]{1,}\.[0-9]{1,4}}
|
||||
+ :vlan
|
||||
+ # handles 'eth0' or 'enp0s9.100'
|
||||
+ # there is no need to mark as vlan in case of enp0s9.100
|
||||
+ # or eth2.4 as it does not need vlan-raw-device option
|
||||
else
|
||||
:raw
|
||||
end
|
||||
@@ -279,6 +285,23 @@ Puppet::Type.type(:network_config).provide(:interfaces) do
|
||||
stanza = []
|
||||
stanza << %(iface #{provider.name} #{provider.family} #{provider.method})
|
||||
|
||||
+ provider.mode = case provider.name
|
||||
+ # 'vlan22'
|
||||
+ when %r{^vlan}
|
||||
+ :vlan
|
||||
+ # 'eno1.0003' or 'br1.0002'
|
||||
+ when %r{^[a-z]{1,}[0-9]{1,}\.[0-9]{1,4}}
|
||||
+ :vlan
|
||||
+ # 'enp0s9.0003'
|
||||
+ when %r{^[a-z]{1,}[0-9]{1,}[a-z]{1,}[0-9]{1,}\.[0-9]{1,4}}
|
||||
+ :vlan
|
||||
+ # handles 'eth0' or 'enp0s9.100'
|
||||
+ # there is no need to mark as vlan in case of enp0s9.100
|
||||
+ # as it does not need vlan-raw-device option
|
||||
+ else
|
||||
+ :raw
|
||||
+ end
|
||||
+
|
||||
# add the vlan-raw-device only when explicitely set in interfaces(5) stanza
|
||||
# otherwise it's already assumed given the stanza name (ethX.NN)
|
||||
if provider.mode == :vlan
|
||||
--
|
||||
2.17.1
|
||||
|
@ -1 +1,2 @@
|
||||
0001-save-result-file-to-var-run-network-to-allow-manipul.patch
|
||||
0001-save-result-file-to-var-run-network-to-allow-manipul.patch
|
||||
0002-set-provider-mode-when-formatting-interfaces-file.patch
|
Loading…
Reference in New Issue
Block a user