lib/ohai/plugins/network.rb in ohai-13.12.6 vs lib/ohai/plugins/network.rb in ohai-14.0.28
- old
+ new
@@ -74,37 +74,37 @@
# working with the address(es) of the default network interface
gw_if_ips = ips.select do |v|
v[:iface] == network[int_attr]
end
if gw_if_ips.empty?
- Ohai::Log.warn("Plugin Network: [#{family}] no ip address on #{network[int_attr]}")
+ logger.warn("Plugin Network: [#{family}] no ip address on #{network[int_attr]}")
elsif network[gw_attr] &&
network["interfaces"][network[int_attr]] &&
network["interfaces"][network[int_attr]]["addresses"]
if [ "0.0.0.0", "::", /^fe80:/ ].any? { |pat| pat === network[gw_attr] }
# link level default route
- Ohai::Log.debug("Plugin Network: link level default #{family} route, picking ip from #{network[gw_attr]}")
+ logger.trace("Plugin Network: link level default #{family} route, picking ip from #{network[gw_attr]}")
r = gw_if_ips.first
else
# checking network masks
r = gw_if_ips.select do |v|
network_contains_address(network[gw_attr], v[:ipaddress], v[:iface])
end.first
if r.nil?
r = gw_if_ips.first
- Ohai::Log.debug("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
+ logger.trace("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
else
- Ohai::Log.debug("Plugin Network: [#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
+ logger.trace("Plugin Network: [#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
end
end
else
# return the first ip address on network[int_attr]
r = gw_if_ips.first
end
else
r = ips.first
- Ohai::Log.debug("Plugin Network: [#{family}] no default interface, picking the first ipaddress")
+ logger.trace("Plugin Network: [#{family}] no default interface, picking the first ipaddress")
end
return [ nil, nil ] if r.nil? || r.empty?
[ r[:ipaddress].to_s, r[:iface] ]
@@ -118,11 +118,11 @@
# address_to_match: String
# ipaddress: IPAddress
# iface: String
def network_contains_address(address_to_match, ipaddress, iface)
- if peer = network["interfaces"][iface]["addresses"][ipaddress.to_s][:peer]
+ if ( peer = network["interfaces"][iface]["addresses"][ipaddress.to_s][:peer] )
IPAddress(peer) == IPAddress(address_to_match)
else
ipaddress.include? IPAddress(address_to_match)
end
end
@@ -146,37 +146,37 @@
(r["ip"], r["iface"]) = find_ip(family)
r["mac"] = find_mac_from_iface(r["iface"]) unless r["iface"].nil?
# don't overwrite attributes if they've already been set by the "#{os}::network" plugin
if (family == "inet") && ipaddress.nil?
if r["ip"].nil?
- Ohai::Log.warn("Plugin Network: unable to detect ipaddress")
+ logger.warn("Plugin Network: unable to detect ipaddress")
else
ipaddress r["ip"]
end
elsif (family == "inet6") && ip6address.nil?
if r["ip"].nil?
- Ohai::Log.debug("Plugin Network: unable to detect ip6address")
+ logger.trace("Plugin Network: unable to detect ip6address")
else
ip6address r["ip"]
end
end
# set the macaddress [only if we haven't already]. this allows the #{os}::network plugin to set macaddress
# otherwise we set macaddress on a first-found basis (and we started with ipv4)
if macaddress.nil?
if r["mac"]
- Ohai::Log.debug("Plugin Network: setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
+ logger.trace("Plugin Network: setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
macaddress r["mac"]
else
- Ohai::Log.debug("Plugin Network: unable to detect macaddress for family '#{family}'")
+ logger.trace("Plugin Network: unable to detect macaddress for family '#{family}'")
end
end
results[family] = r
end
if results["inet"]["iface"] && results["inet6"]["iface"] &&
(results["inet"]["iface"] != results["inet6"]["iface"])
- Ohai::Log.debug("Plugin Network: ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
+ logger.trace("Plugin Network: ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
end
end
end