diff options
Diffstat (limited to 'lib/facter/arp.rb')
-rw-r--r-- | lib/facter/arp.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/facter/arp.rb b/lib/facter/arp.rb index 5035ad0..0a7cf67 100644 --- a/lib/facter/arp.rb +++ b/lib/facter/arp.rb @@ -3,14 +3,17 @@ require 'facter/util/ip' Facter.add(:arp) do confine :kernel => :linux setcode do - arp = [] output = Facter::Util::Resolution.exec('arp -a') if not output.nil? + arp = "" output.each_line do |s| - arp.push($1) if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/ + if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/ + arp = $1 + break # stops on the first match + end end end - arp[0] + EC2_ARP == arp ? arp : nil end end @@ -18,7 +21,8 @@ Facter::Util::IP.get_interfaces.each do |interface| Facter.add("arp_" + Facter::Util::IP.alphafy(interface)) do confine :kernel => :linux setcode do - Facter::Util::IP.get_arp_value(interface) + arp = Facter::Util::IP.get_arp_value(interface) + EC2_ARP == arp ? arp : nil end end end |