plugins/guests/linux/cap/network_interfaces.rb in vagrant-unbundled-1.9.1.1 vs plugins/guests/linux/cap/network_interfaces.rb in vagrant-unbundled-1.9.5.1
- old
+ new
@@ -17,10 +17,17 @@
def self.network_interfaces(machine, path = "/sbin/ip")
s = ""
machine.communicate.sudo("#{path} -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data|
s << data if type == :stdout
end
+ # In some cases net devices may be added to the guest and will not
+ # properly show up when using `ip`. This pulls any device information
+ # that can be found in /proc and adds it to the list of interfaces
+ s << "\n"
+ machine.communicate.sudo("cat /proc/net/dev | grep -E '^[a-z0-9 ]+:' | awk '{print $1}' | sed 's/://'", error_check: false) do |type, data|
+ s << data if type == :stdout
+ end
ifaces = s.split("\n")
@@logger.debug("Unsorted list: #{ifaces.inspect}")
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
# NOTE: Devices named with a hex value suffix will _not_ be sorted
@@ -33,10 +40,10 @@
else
iface_part
end
end
end
- ifaces = ifaces.sort do |lhs, rhs|
+ ifaces = ifaces.uniq.sort do |lhs, rhs|
result = 0
slice_length = [rhs.size, lhs.size].min
slice_length.times do |idx|
if(lhs[idx].is_a?(rhs[idx].class))
result = lhs[idx] <=> rhs[idx]