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-27 19:25:13 +0100
commitdcec494d4b1e9f55d7072e5bf18b8a7e0df5a840 (patch)
treebac1323a4d6c8c8fedd0162790d06ef5e69db8a9
parentbbec325db366001f9e5b8bddd4d5137773395a07 (diff)
downloadohai-dcec494d4b1e9f55d7072e5bf18b8a7e0df5a840.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