Skip to content

Commit

Permalink
quick bad fix: set ipaddress from global scope addresses only
Browse files Browse the repository at this point in the history
it means it won't set ipaddress if there's no global scope address...
  • Loading branch information
llaurent committed Apr 5, 2012
1 parent 322d01a commit 83971da
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/ohai/plugins/network.rb
Expand Up @@ -39,10 +39,14 @@
def find_ip_and_mac(addresses, match = nil)
ip = nil; mac = nil; ip6 = 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])
if addresses[addr]["family"].eql?("inet")
# skip non global scope addresses (if attribute "scope" exists)
next if addresses[addr].has_key? "scope" && addresses[addr]["scope"].downcase != "global"
if match.nil?
ip = addr
else
ip = addr if network_contains_address(match, addr, addresses[addr])
end
end
ip6 = addr if addresses[addr]["family"].eql?("inet6") && addresses[addr]["scope"].eql?("Global")
mac = addr if addresses[addr]["family"].eql?("lladdr")
Expand Down

0 comments on commit 83971da

Please sign in to comment.