summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaymala Sinha <jsinha@chef.io>2017-07-07 16:50:35 -0400
committerJaymala Sinha <jsinha@chef.io>2017-07-11 10:00:41 -0400
commitdd111fe4aef4e7986a5fa6d0eb50646fd419723e (patch)
treef6e5d3b318ac3dbf3039668f38f81d55c65a0681
parente98d3bd8847684e12cb7ac1e06d9930d8cd6902a (diff)
downloadohai-dd111fe4aef4e7986a5fa6d0eb50646fd419723e.tar.gz
Fix solaris2 ipaddress attribute search
```# ohai ipaddress ``` returns following warnings and replaces the node IP address with a blank IP after chef-client run ``` [2017-07-07T20:36:32+00:00] WARN: [inet] no ip address on net0 [2017-07-07T20:36:32+00:00] WARN: unable to detect ipaddress /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/ohai-8.19.1/lib/ohai/system.rb:193:in `attributes_print': I cannot find an attribute named ipaddress! (ArgumentError) ``` Tested this fix on solaris11 client node and verfied IP address was retained after ccr. Signed-off-by: Jaymala Sinha <jsinha@chef.io>
-rw-r--r--lib/ohai/plugins/solaris2/network.rb3
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb4
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb
index c13e5ffc..e1be22e6 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -103,7 +103,8 @@ Ohai.plugin(:Network) do
cint = nil
so.stdout.lines do |line|
- if line =~ /^([0-9a-zA-Z\.\:\-]+)\S/
+ # if line =~ /^([0-9a-zA-Z\.\:\-]+)\S/
+ 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 3755c183..5112294e 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -147,7 +147,7 @@ ROUTE_GET
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", "lo0", "lo0:3", "net0", "net1:1", "qfe1"])
end
it "detects the ip addresses of the interfaces" do
@@ -176,7 +176,7 @@ ROUTE_GET
end
it "finds the default interface for a solaris 11 zone" do
- expect(@plugin[:network][:default_interface]).to eq("net1")
+ expect(@plugin[:network][:default_interface]).to eq("net1:1")
end
end