Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/puppet/provider/network_config/redhat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
VLAN_RANGE_REGEX = %r{[1-3]?\d{1,3}|40[0-8]\d|409[0-5]}

# aliases are almost free game, redhat rejects some, and max total length is 15 characters
# 15 minus at least 2 for the interface name, and a colon leaves 12 characters for the alias
# 15 minus at least 2 for the interface name, and a colon/underscore leaves 12 characters for the alias
ALIAS_REGEX = %r{.{1,12}(?<!~|\.bak|\.old|\.orig|\.rpmnew|\.rpmorig|\.rpmsave)}

# @return [Regexp] The regular expression for interface scripts on redhat systems
SCRIPT_REGEX = %r{\Aifcfg-[a-z]+[a-z_\d]+(?::#{ALIAS_REGEX}|\.#{VLAN_RANGE_REGEX})?\Z}
# Note: accepts both : and _ as alias separators (underscore for Windows compatibility)
SCRIPT_REGEX = %r{\Aifcfg-[a-z]+[a-z_\d]+(?:[:_]#{ALIAS_REGEX}|\.#{VLAN_RANGE_REGEX})?\Z}

NAME_MAPPINGS = {
ipaddress: 'IPADDR',
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/provider/network_config/redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def fixture_data(file)
let(:network_scripts_path) { fixture_file('network-scripts') }

valid_files = %w[ifcfg-bond0 ifcfg-bond1 ifcfg-eth0 ifcfg-eth1 ifcfg-eth2
ifcfg-eth3 ifcfg-vlan100 ifcfg-vlan100:0 ifcfg-vlan200
ifcfg-eth3 ifcfg-vlan100 ifcfg-vlan100_0 ifcfg-vlan200
ifcfg-vlan300 ifcfg-vlan400 ifcfg-vlan500 ifcfg-eth0.0
ifcfg-eth0.1 ifcfg-eth0.4095 ifcfg-eth0:10000000
ifcfg-eth0:my.alias ifcfg-bond1.1001]
ifcfg-eth0.1 ifcfg-eth0.4095 ifcfg-eth0_10000000
ifcfg-eth0_my.alias ifcfg-bond1.1001]

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

valid_files.each do |file|
it { is_expected.to include file }
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/network_config/sles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fixture_data(file)
ifcfg-eth0.4095 ifcfg-bond1.1001]

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

valid_files.each do |file|
it { is_expected.to include file }
Expand Down
Loading