summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-04-23 16:20:25 +0100
committerThom May <thom@may.lt>2015-04-23 16:20:25 +0100
commit85235a85a004c66a3ae2ef40c1b46f93451bde8e (patch)
treec1ba5152653a2857598385197a789d798fb4d7a4
parent04d8188c1090955d95bae5e5ce68c5dfae911dcf (diff)
downloadohai-85235a85a004c66a3ae2ef40c1b46f93451bde8e.tar.gz
Work correctly when IPv6 is disabled on Linux
Right now, ohai will return v4 addresses and routes for v6, rather than just not returning anything. Fixes #380
-rw-r--r--lib/ohai/plugins/linux/network.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 314c8676..50360bb6 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -33,6 +33,10 @@ Ohai.plugin(:Network) do
encap
end
+ def ipv6_enabled?
+ File.exist? "/proc/net/if_inet6"
+ end
+
def iproute2_binary_available?
["/sbin/ip", "/usr/bin/ip", "/bin/ip"].any? { |path| File.exist?(path) }
end
@@ -60,12 +64,14 @@ Ohai.plugin(:Network) do
:default_route => "0.0.0.0/0",
:default_prefix => :default,
:neighbour_attribute => :arp
- },{
+ }]
+
+ families << {
:name => "inet6",
:default_route => "::/0",
:default_prefix => :default_inet6,
:neighbour_attribute => :neighbour_inet6
- }]
+ } if ipv6_enabled?
so = shell_out("ip addr")
cint = nil