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-07 16:50:35 -0400
commit59d0695d025999cf22b9bb13c330b92df371f397 (patch)
tree7c2a0721fc12ea0148866b55b3b22754a21c8ff8
parent3f59946f198bf25726061a49126f23586c7a06e0 (diff)
downloadohai-59d0695d025999cf22b9bb13c330b92df371f397.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 7a2a47bc..6a92f003 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -101,7 +101,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 caa444dc..0f1484ef 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