summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2016-06-17 15:13:29 +0100
committerGitHub <noreply@github.com>2016-06-17 15:13:29 +0100
commitf5ddbd0873b1fee480b78fb6beaecf9a9b63bc7f (patch)
tree75a75171c3e39bfcfa48600501c95a0b7d83f5a2
parent17e5c748a70e5388a542a1cff5f86b630c5a629e (diff)
parent0a666b19e6bc1b6912423c873c33fc4198bc03fa (diff)
downloadohai-f5ddbd0873b1fee480b78fb6beaecf9a9b63bc7f.tar.gz
Merge pull request #830 from jaymzh/network_v6_interfaces
Add additional info to networking interfaces/addresses
-rw-r--r--lib/ohai/plugins/linux/network.rb12
-rw-r--r--spec/unit/plugins/linux/network_spec.rb4
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 18f6dd31..65aa3d1a 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -310,10 +310,18 @@ Ohai.plugin(:Network) do
end
def parse_ip_addr_inet6_line(cint, iface, line)
- if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)/
+ if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)( .*)?/
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
tmp_addr = $1
- iface[cint][:addresses][tmp_addr] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("host") ? "Node" : $3.capitalize) }
+ tags = $4 || ""
+ tags = tags.split(" ")
+
+ iface[cint][:addresses][tmp_addr] = {
+ "family" => "inet6",
+ "prefixlen" => $2,
+ "scope" => ($3.eql?("host") ? "Node" : $3.capitalize),
+ "tags" => tags,
+ }
end
end
diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb
index 40bbdc17..b91e8d0f 100644
--- a/spec/unit/plugins/linux/network_spec.rb
+++ b/spec/unit/plugins/linux/network_spec.rb
@@ -808,6 +808,10 @@ EOM
expect(plugin["network"]["interfaces"]["eth3"]["state"]).to eq("up")
end
+ it "detects tags on v6 addresses of the ethernet interface" do
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["2001:44b8:4160:8f00:a00:27ff:fe13:eacd"]["tags"]).to eq(["dynamic"])
+ end
+
describe "when IPv6 is disabled" do
before :each do
allow(File).to receive(:exist?).with("/proc/net/if_inet6").and_return(false)