diff options
-rw-r--r-- | lib/ohai/plugins/linux/network.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/network.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb index f5543819..0e24c88f 100644 --- a/lib/ohai/plugins/linux/network.rb +++ b/lib/ohai/plugins/linux/network.rb @@ -478,7 +478,7 @@ Ohai.plugin(:Network) do # returns the macaddress for interface from a hash of interfaces (iface elsewhere in this file) def get_mac_for_interface(interfaces, interface) - interfaces[interface][:addresses].select { |k, v| v["family"] == "lladdr" }.first.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?("NOARP") + interfaces[interface][:addresses].find { |k, v| v["family"] == "lladdr" }.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?("NOARP") end # returns the default route with the lowest metric (unspecified metric is 0) diff --git a/lib/ohai/plugins/network.rb b/lib/ohai/plugins/network.rb index 8e9425ef..c1b15ced 100644 --- a/lib/ohai/plugins/network.rb +++ b/lib/ohai/plugins/network.rb @@ -88,9 +88,9 @@ Ohai.plugin(:NetworkAddresses) do r = gw_if_ips.first else # checking network masks - r = gw_if_ips.select do |v| + r = gw_if_ips.find do |v| network_contains_address(network[gw_attr], v[:ipaddress], v[:iface]) - end.first + end if r.nil? r = gw_if_ips.first logger.trace("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}") |