lib/ohai/plugins/network.rb in ohai-0.6.12.rc.2 vs lib/ohai/plugins/network.rb in ohai-0.6.12.rc.3

- old
+ new

@@ -32,22 +32,26 @@ ip = nil; mac = nil addresses.keys.each do |addr| if match.nil? ip = addr if addresses[addr]["family"].eql?("inet") else - ip = addr if addresses[addr]["family"].eql?("inet") && network_contains_address(match, addr, addresses[addr][:netmask]) + ip = addr if addresses[addr]["family"].eql?("inet") && network_contains_address(match, addr, addresses[addr]) end mac = addr if addresses[addr]["family"].eql?("lladdr") break if (ip and mac) end Ohai::Log.debug("Found IPv4 address #{ip} with MAC #{mac} #{match.nil? ? '' : 'matching address ' + match}") [ip, mac] end -def network_contains_address(address_to_match, network_ip, network_mask) - network = IPAddress "#{network_ip}/#{network_mask}" - host = IPAddress address_to_match - network.include?(host) +def network_contains_address(address_to_match, network_ip, network_opts) + if network_opts[:peer] + network_opts[:peer] == address_to_match + else + network = IPAddress "#{network_ip}/#{network_opts[:netmask]}" + host = IPAddress address_to_match + network.include?(host) + end end # If we have a default interface that has addresses, populate the short-cut attributes if network[:default_interface] and network["interfaces"][network[:default_interface]] and