Skip to content

Commit

Permalink
Merge 639cad8 into 22d8728
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyNamedLaura committed Aug 8, 2019
2 parents 22d8728 + 639cad8 commit 410d746
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/puppet/provider/network_config/redhat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
# The valid vlan ID range is 0-4095; 4096 is out of range
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
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]+(?::\d+|\.#{VLAN_RANGE_REGEX})?\Z}
SCRIPT_REGEX = %r{\Aifcfg-[a-z]+[a-z\d]+(?::#{ALIAS_REGEX}|\.#{VLAN_RANGE_REGEX})?\Z}

NAME_MAPPINGS = {
ipaddress: 'IPADDR',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DEVICE="eth0:my.alias"
IPADDR="10.10.10.10"
NETMASK="255.255.255.0"
BOOTPROTO="none"
IPV6INIT="no"
MTU="9000"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DEVICE="eth0:my.alias"
IPADDR="10.10.10.10"
NETMASK="255.255.255.0"
BOOTPROTO="none"
IPV6INIT="no"
MTU="9000"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
4 changes: 2 additions & 2 deletions spec/unit/provider/network_config/redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def fixture_data(file)
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-bond1.1001]
ifcfg-eth0:my.alias ifcfg-bond1.1001]

invalid_files = %w[.ifcfg-bond0.swp ifcfg-bond1~ ifcfg-vlan500.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

0 comments on commit 410d746

Please sign in to comment.