summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Brown <sbrown@chef.io>2019-06-03 19:44:17 +0100
committerBryan McLellan <btm@loftninjas.org>2019-06-03 14:44:17 -0400
commit85578ff2ee2f98d05f05b5101a78f5c0ba9f5b5e (patch)
treea638a9d6bad9c96f1305043b83527785982b5b48
parenta3d37e1c29cf29f15bf7f420b0ca943e078476d8 (diff)
downloadohai-85578ff2ee2f98d05f05b5101a78f5c0ba9f5b5e.tar.gz
Solaris network plugin fix for issue https://github.com/chef/ohai/iss… (#1367)
* Solaris network plugin fix for issue https://github.com/chef/ohai/issues/1366 Signed-off-by: devoptimist <sbrown@chef.io>
-rw-r--r--lib/ohai/plugins/solaris2/network.rb4
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb11
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb
index 8fe6f3eb..d93da9d6 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -103,8 +103,8 @@ Ohai.plugin(:Network) do
cint = nil
so.stdout.lines do |line|
- # regex: http://rubular.com/r/Iag7JLVTVe
- if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+) index (\d+)/
+ # regex: https://rubular.com/r/ZiIHbsnfiWPW1p
+ if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
cint = $1
iface[cint] = Mash.new unless iface[cint]
iface[cint][:mtu] = $2
diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb
index 3be74827..07151ce7 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -44,6 +44,9 @@ describe Ohai::System, "Solaris2.X network plugin" do
ARP_RN
@solaris_ifconfig = <<~ENDIFCONFIG
+ ipmp0: flags=108000000843<UP,BROADCAST,RUNNING,MULTICAST,IPMP,PHYSRUNNING> mtu 1500
+ inet 10.10.130.103 netmask fffffe00 broadcast 10.10.131.255
+ groupname ipmp0
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
@@ -143,7 +146,7 @@ describe Ohai::System, "Solaris2.X network plugin" do
end
it "detects the interfaces" do
- expect(@plugin["network"]["interfaces"].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "ip6.tun0", "lo0", "lo0:3", "net0", "net1:1", "qfe1", "vni0"])
+ expect(@plugin["network"]["interfaces"].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "ip6.tun0", "ipmp0", "lo0", "lo0:3", "net0", "net1:1", "qfe1", "vni0"])
end
it "detects the ip addresses of the interfaces" do
@@ -157,6 +160,12 @@ describe Ohai::System, "Solaris2.X network plugin" do
it "detects the L3PROTECT network flag" do
expect(@plugin["network"]["interfaces"]["net0"]["flags"]).to include("L3PROTECT")
end
+
+ it "detects an interface with no index number" do
+ expect(@plugin["network"]["interfaces"]["ipmp0"]["index"]).to eq(nil)
+ expect(@plugin["network"]["interfaces"]["ipmp0"]["mtu"]).to eq("1500")
+ end
+
end
describe "gathering solaris 11 zone IP layer address info" do