diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb index ea7dc32da..6d3ce657c 100644 --- a/plugins/guests/linux/cap/network_interfaces.rb +++ b/plugins/guests/linux/cap/network_interfaces.rb @@ -5,7 +5,7 @@ module VagrantPlugins # Valid ethernet device prefix values. # eth - classic prefix # en - predictable interface names prefix - ETHERNET_PREFIX = ["eth", "en"] + POSSIBLE_ETHERNET_PREFIXES = ["eth".freeze, "en".freeze].freeze @@logger = Log4r::Logger.new("vagrant::guest::linux::network_interfaces") @@ -25,8 +25,8 @@ module VagrantPlugins # Break out integers from strings and sort the arrays to provide # a natural sort for the interface names ifaces = ifaces.map do |iface| - unless eth_prefix - eth_prefix = ETHERNET_PREFIX.detect do |prefix| + if eth_prefix.nil? + eth_prefix = POSSIBLE_ETHERNET_PREFIXES.detect do |prefix| iface.start_with?(prefix) end end diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb index 139cebfdc..810606f2a 100644 --- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb +++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb @@ -56,6 +56,5 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do result = cap.network_interfaces(machine) expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"]) end - end end