Skip to content

Commit 9ec41a3

Browse files
authored
Merge pull request #255 from UGent-DICT/feature/redhat_nonumerical_alias
support non numerical aliases on redhat
2 parents 22d8728 + 639cad8 commit 9ec41a3

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

lib/puppet/provider/network_config/redhat.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
# The valid vlan ID range is 0-4095; 4096 is out of range
2525
VLAN_RANGE_REGEX = %r{[1-3]?\d{1,3}|40[0-8]\d|409[0-5]}
2626

27+
# aliases are almost free game, redhat rejects some, and max total length is 15 characters
28+
# 15 minus at least 2 for the interface name, and a colon leaves 12 characters for the alias
29+
ALIAS_REGEX = %r{.{1,12}(?<!~|\.bak|\.old|\.orig|\.rpmnew|\.rpmorig|\.rpmsave)}
30+
2731
# @return [Regexp] The regular expression for interface scripts on redhat systems
28-
SCRIPT_REGEX = %r{\Aifcfg-[a-z]+[a-z\d]+(?::\d+|\.#{VLAN_RANGE_REGEX})?\Z}
32+
SCRIPT_REGEX = %r{\Aifcfg-[a-z]+[a-z\d]+(?::#{ALIAS_REGEX}|\.#{VLAN_RANGE_REGEX})?\Z}
2933

3034
NAME_MAPPINGS = {
3135
ipaddress: 'IPADDR',
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DEVICE="eth0:my.alias"
2+
IPADDR="10.10.10.10"
3+
NETMASK="255.255.255.0"
4+
BOOTPROTO="none"
5+
IPV6INIT="no"
6+
MTU="9000"
7+
NM_CONTROLLED="no"
8+
ONBOOT="yes"
9+
TYPE="Ethernet"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DEVICE="eth0:my.alias"
2+
IPADDR="10.10.10.10"
3+
NETMASK="255.255.255.0"
4+
BOOTPROTO="none"
5+
IPV6INIT="no"
6+
MTU="9000"
7+
NM_CONTROLLED="no"
8+
ONBOOT="yes"
9+
TYPE="Ethernet"

spec/unit/provider/network_config/redhat_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def fixture_data(file)
3131
ifcfg-eth3 ifcfg-vlan100 ifcfg-vlan100:0 ifcfg-vlan200
3232
ifcfg-vlan300 ifcfg-vlan400 ifcfg-vlan500 ifcfg-eth0.0
3333
ifcfg-eth0.1 ifcfg-eth0.4095 ifcfg-eth0:10000000
34-
ifcfg-bond1.1001]
34+
ifcfg-eth0:my.alias ifcfg-bond1.1001]
3535

3636
invalid_files = %w[.ifcfg-bond0.swp ifcfg-bond1~ ifcfg-vlan500.bak
37-
ifcfg-eth0.4096]
37+
ifcfg-eth0:my.alias.bak ifcfg-eth0.4096]
3838

3939
valid_files.each do |file|
4040
it { is_expected.to include file }

0 commit comments

Comments
 (0)