Skip to content

Commit

Permalink
Solaris_update_version: Create kernel[:update] for solaris 2
Browse files Browse the repository at this point in the history
Extract the Solaris update information from /etc/release.
  • Loading branch information
MarkGibbons committed Aug 16, 2016
1 parent c605128 commit 9cbd80d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ohai/plugins/kernel.rb
Expand Up @@ -151,6 +151,10 @@ def os_lookup(sys_type)
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")
Expand Down
23 changes: 23 additions & 0 deletions spec/unit/plugins/solaris2/kernel_spec.rb
Expand Up @@ -139,8 +139,31 @@
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 informtion" 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 informtion" 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 informtion" 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", ""])

it "gives excruciating detail about kernel modules" do
Expand Down

0 comments on commit 9cbd80d

Please sign in to comment.