diff options
author | Thom May <thom@may.lt> | 2016-09-07 09:42:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-07 09:42:01 +0100 |
commit | 3455869e625b96cc8207b9162f54b6ca293c5aea (patch) | |
tree | 1d142489e0e3ff55c3620b7d67477e45daf0b796 | |
parent | d9584633fe261a0caec6ec4dc9bd8e7609a55fcf (diff) | |
parent | f875cd7e8d32d8bc8a2750c91bc96077a1633103 (diff) | |
download | ohai-3455869e625b96cc8207b9162f54b6ca293c5aea.tar.gz |
Merge pull request #869 from MarkGibbons/Solaris_update_version
Solaris_update_version: Create kernel[:update] for solaris 2
-rw-r--r-- | lib/ohai/plugins/kernel.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/solaris2/kernel_spec.rb | 23 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb index d0c44842..3441eb73 100644 --- a/lib/ohai/plugins/kernel.rb +++ b/lib/ohai/plugins/kernel.rb @@ -156,6 +156,10 @@ Ohai.plugin(:Kernel) do so = shell_out("uname -s") kernel[:os] = so.stdout.split($/)[0] + so = File.open("/etc/release") { |file| file.gets } + md = /(?<update>\d.*\d)/.match(so) + kernel[:update] = md[:update] if md + modules = Mash.new so = shell_out("modinfo") diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index 4cf82477..cb2822b1 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -139,6 +139,29 @@ describe Ohai::System, "Solaris2.X kernel plugin" do allow(@plugin).to receive(:init_kernel).and_return({}) allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", "")) allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, "")) + @release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013") + allow(File).to receive(:open).with("/etc/release").and_yield(@release) + end + + it "should give the Solaris update version information" do + @release = StringIO.new(" Solaris 10 10/08 s10s_u6wos_07b SPARC\n Use is subject to license terms.\n Assembled 27 October 2008") + allow(File).to receive(:open).with("/etc/release").and_yield(@release) + @plugin.run + expect(@plugin[:kernel][:update]).to eq("10 10/08 s10s_u6wos_07") + end + + it "should give the Oracle Solaris update version information" do + @release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013") + allow(File).to receive(:open).with("/etc/release").and_yield(@release) + @plugin.run + expect(@plugin[:kernel][:update]).to eq("10 1/13 s10s_u11wos_24") + end + + it "should give the Solaris 11 update version information" do + @release = StringIO.new(" Oracle Solaris 11.3 SPARC\n Assembled 25 July 2016") + allow(File).to receive(:open).with("/etc/release").and_yield(@release) + @plugin.run + expect(@plugin[:kernel][:update]).to eq("11.3") end it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""]) |