ohai 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +98 -0
  3. data/Rakefile +61 -0
  4. data/bin/ohai +24 -0
  5. data/lib/ohai.rb +27 -0
  6. data/lib/ohai/application.rb +113 -0
  7. data/lib/ohai/config.rb +29 -0
  8. data/lib/ohai/exception.rb +23 -0
  9. data/lib/ohai/log.rb +26 -0
  10. data/lib/ohai/mixin/command.rb +208 -0
  11. data/lib/ohai/mixin/from_file.rb +36 -0
  12. data/lib/ohai/mixin/string.rb +29 -0
  13. data/lib/ohai/plugins/command.rb +21 -0
  14. data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
  15. data/lib/ohai/plugins/darwin/hostname.rb +22 -0
  16. data/lib/ohai/plugins/darwin/kernel.rb +37 -0
  17. data/lib/ohai/plugins/darwin/network.rb +187 -0
  18. data/lib/ohai/plugins/darwin/platform.rb +36 -0
  19. data/lib/ohai/plugins/darwin/ps.rb +23 -0
  20. data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
  21. data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
  22. data/lib/ohai/plugins/darwin/uptime.rb +32 -0
  23. data/lib/ohai/plugins/dmi.rb +59 -0
  24. data/lib/ohai/plugins/ec2.rb +100 -0
  25. data/lib/ohai/plugins/erlang.rb +40 -0
  26. data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
  27. data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
  28. data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
  29. data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
  30. data/lib/ohai/plugins/freebsd/memory.rb +50 -0
  31. data/lib/ohai/plugins/freebsd/network.rb +112 -0
  32. data/lib/ohai/plugins/freebsd/platform.rb +23 -0
  33. data/lib/ohai/plugins/freebsd/ps.rb +24 -0
  34. data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
  35. data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
  36. data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
  37. data/lib/ohai/plugins/hostname.rb +27 -0
  38. data/lib/ohai/plugins/java.rb +36 -0
  39. data/lib/ohai/plugins/kernel.rb +33 -0
  40. data/lib/ohai/plugins/keys.rb +22 -0
  41. data/lib/ohai/plugins/languages.rb +21 -0
  42. data/lib/ohai/plugins/linux/block_device.rb +38 -0
  43. data/lib/ohai/plugins/linux/cpu.rb +60 -0
  44. data/lib/ohai/plugins/linux/filesystem.rb +57 -0
  45. data/lib/ohai/plugins/linux/hostname.rb +26 -0
  46. data/lib/ohai/plugins/linux/kernel.rb +33 -0
  47. data/lib/ohai/plugins/linux/lsb.rb +38 -0
  48. data/lib/ohai/plugins/linux/memory.rb +83 -0
  49. data/lib/ohai/plugins/linux/network.rb +112 -0
  50. data/lib/ohai/plugins/linux/platform.rb +43 -0
  51. data/lib/ohai/plugins/linux/ps.rb +23 -0
  52. data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
  53. data/lib/ohai/plugins/linux/uptime.rb +28 -0
  54. data/lib/ohai/plugins/linux/virtualization.rb +77 -0
  55. data/lib/ohai/plugins/netbsd/cpu.rb +48 -0
  56. data/lib/ohai/plugins/netbsd/filesystem.rb +57 -0
  57. data/lib/ohai/plugins/netbsd/hostname.rb +22 -0
  58. data/lib/ohai/plugins/netbsd/kernel.rb +35 -0
  59. data/lib/ohai/plugins/netbsd/memory.rb +98 -0
  60. data/lib/ohai/plugins/netbsd/network.rb +111 -0
  61. data/lib/ohai/plugins/netbsd/platform.rb +22 -0
  62. data/lib/ohai/plugins/netbsd/ps.rb +24 -0
  63. data/lib/ohai/plugins/netbsd/ssh_host_key.rb +26 -0
  64. data/lib/ohai/plugins/netbsd/uptime.rb +31 -0
  65. data/lib/ohai/plugins/netbsd/virtualization.rb +65 -0
  66. data/lib/ohai/plugins/network.rb +52 -0
  67. data/lib/ohai/plugins/ohai_time.rb +21 -0
  68. data/lib/ohai/plugins/openbsd/cpu.rb +38 -0
  69. data/lib/ohai/plugins/openbsd/filesystem.rb +57 -0
  70. data/lib/ohai/plugins/openbsd/hostname.rb +22 -0
  71. data/lib/ohai/plugins/openbsd/kernel.rb +35 -0
  72. data/lib/ohai/plugins/openbsd/memory.rb +98 -0
  73. data/lib/ohai/plugins/openbsd/network.rb +111 -0
  74. data/lib/ohai/plugins/openbsd/platform.rb +23 -0
  75. data/lib/ohai/plugins/openbsd/ps.rb +24 -0
  76. data/lib/ohai/plugins/openbsd/ssh_host_key.rb +26 -0
  77. data/lib/ohai/plugins/openbsd/uptime.rb +32 -0
  78. data/lib/ohai/plugins/openbsd/virtualization.rb +66 -0
  79. data/lib/ohai/plugins/os.rb +48 -0
  80. data/lib/ohai/plugins/perl.rb +37 -0
  81. data/lib/ohai/plugins/platform.rb +25 -0
  82. data/lib/ohai/plugins/python.rb +37 -0
  83. data/lib/ohai/plugins/ruby.rb +39 -0
  84. data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
  85. data/lib/ohai/plugins/solaris2/hostname.rb +25 -0
  86. data/lib/ohai/plugins/solaris2/kernel.rb +40 -0
  87. data/lib/ohai/plugins/solaris2/network.rb +141 -0
  88. data/lib/ohai/plugins/solaris2/platform.rb +33 -0
  89. data/lib/ohai/plugins/solaris2/ps.rb +23 -0
  90. data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
  91. data/lib/ohai/plugins/uptime.rb +42 -0
  92. data/lib/ohai/plugins/virtualization.rb +86 -0
  93. data/lib/ohai/plugins/windows/filesystem.rb +44 -0
  94. data/lib/ohai/plugins/windows/hostname.rb +25 -0
  95. data/lib/ohai/plugins/windows/kernel.rb +75 -0
  96. data/lib/ohai/plugins/windows/network.rb +114 -0
  97. data/lib/ohai/plugins/windows/platform.rb +26 -0
  98. data/lib/ohai/system.rb +241 -0
  99. data/spec/ohai/mixin/command_spec.rb +37 -0
  100. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  101. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  102. data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
  103. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  104. data/spec/ohai/plugins/dmi_spec.rb +73 -0
  105. data/spec/ohai/plugins/ec2_spec.rb +81 -0
  106. data/spec/ohai/plugins/erlang_spec.rb +63 -0
  107. data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
  108. data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
  109. data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
  110. data/spec/ohai/plugins/hostname_spec.rb +39 -0
  111. data/spec/ohai/plugins/java_spec.rb +70 -0
  112. data/spec/ohai/plugins/kernel_spec.rb +43 -0
  113. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  114. data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
  115. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  116. data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
  117. data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
  118. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  119. data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
  120. data/spec/ohai/plugins/netbsd/hostname_spec.rb +34 -0
  121. data/spec/ohai/plugins/netbsd/kernel_spec.rb +36 -0
  122. data/spec/ohai/plugins/netbsd/platform_spec.rb +40 -0
  123. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  124. data/spec/ohai/plugins/openbsd/hostname_spec.rb +34 -0
  125. data/spec/ohai/plugins/openbsd/kernel_spec.rb +37 -0
  126. data/spec/ohai/plugins/openbsd/platform_spec.rb +40 -0
  127. data/spec/ohai/plugins/os_spec.rb +69 -0
  128. data/spec/ohai/plugins/perl_spec.rb +89 -0
  129. data/spec/ohai/plugins/platform_spec.rb +56 -0
  130. data/spec/ohai/plugins/python_spec.rb +53 -0
  131. data/spec/ohai/plugins/ruby_spec.rb +51 -0
  132. data/spec/ohai/plugins/solaris2/hostname_spec.rb +43 -0
  133. data/spec/ohai/plugins/solaris2/kernel_spec.rb +164 -0
  134. data/spec/ohai/system_spec.rb +130 -0
  135. data/spec/ohai_spec.rb +27 -0
  136. data/spec/rcov.opts +2 -0
  137. data/spec/spec.opts +2 -0
  138. data/spec/spec_helper.rb +68 -0
  139. metadata +240 -0
@@ -0,0 +1,69 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin os" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:languages] = Mash.new
27
+ @ohai[:languages][:ruby] = Mash.new
28
+ @ohai[:kernel] = Mash.new
29
+ @ohai[:kernel][:release] = "kings of leon"
30
+ end
31
+
32
+ it "should set os_version to kernel_release" do
33
+ @ohai._require_plugin("os")
34
+ @ohai[:os_version].should == @ohai[:kernel][:release]
35
+ end
36
+
37
+ describe "on linux" do
38
+ before(:each) do
39
+ @ohai[:languages][:ruby][:host_os] = "linux"
40
+ end
41
+
42
+ it "should set the os to linux" do
43
+ @ohai._require_plugin("os")
44
+ @ohai[:os].should == "linux"
45
+ end
46
+ end
47
+
48
+ describe "on darwin" do
49
+ before(:each) do
50
+ @ohai[:languages][:ruby][:host_os] = "darwin"
51
+ end
52
+
53
+ it "should set the os to darwin" do
54
+ @ohai._require_plugin("os")
55
+ @ohai[:os].should == "darwin"
56
+ end
57
+ end
58
+
59
+ describe "on solaris" do
60
+ before do
61
+ @ohai[:languages][:ruby][:host_os] = "solaris2.42" #heh
62
+ end
63
+
64
+ it "sets the os to solaris2" do
65
+ @ohai._require_plugin("os")
66
+ @ohai[:os].should == "solaris2"
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Author:: Joshua Timberman(<joshua@opscode.com>)
3
+ # Copyright:: Copyright (c) 2009 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
20
+
21
+ describe Ohai::System, "plugin perl" do
22
+ before(:each) do
23
+ @ohai = Ohai::System.new
24
+ @ohai[:languages] = Mash.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @pid = mock("PID", :null_object => true)
27
+ @stderr = mock("STDERR", :null_object => true)
28
+ @stdout = mock("STDOUT", :null_object => true)
29
+ @stdout.stub!(:each).and_yield("version='5.8.8';").
30
+ and_yield("archname='darwin-thread-multi-2level';")
31
+ @stdin = mock("STDIN", :null_object => true)
32
+ @status = 0
33
+ @ohai.stub!(:popen4).with("perl -V:version -V:archname").and_yield(
34
+ @pid,
35
+ @stdin,
36
+ @stdout,
37
+ @stderr
38
+ ).and_return(@status)
39
+ end
40
+
41
+ it "should run perl -V:version -V:archname" do
42
+ @ohai.should_receive(:popen4).with("perl -V:version -V:archname").and_return(true)
43
+ @ohai._require_plugin("perl")
44
+ end
45
+
46
+ it "should close perl command's stdin" do
47
+ @stdin.should_receive(:close)
48
+ @ohai._require_plugin("perl")
49
+ end
50
+
51
+ it "should iterate over each line of perl command's stdout" do
52
+ @stdout.should_receive(:each).and_return(true)
53
+ @ohai._require_plugin("perl")
54
+ end
55
+
56
+ it "should set languages[:perl][:version]" do
57
+ @ohai._require_plugin("perl")
58
+ @ohai.languages[:perl][:version].should eql("5.8.8")
59
+ end
60
+
61
+ it "should set languages[:perl][:archname]" do
62
+ @ohai._require_plugin("perl")
63
+ @ohai.languages[:perl][:archname].should eql("darwin-thread-multi-2level")
64
+ end
65
+
66
+ it "should set languages[:perl] if perl command succeeds" do
67
+ @status = 0
68
+ @ohai.stub!(:popen4).with("perl -V:version -V:archname").and_yield(
69
+ @pid,
70
+ @stdin,
71
+ @stdout,
72
+ @stderr
73
+ ).and_return(@status)
74
+ @ohai._require_plugin("perl")
75
+ @ohai.languages.should have_key(:perl)
76
+ end
77
+
78
+ it "should not set languages[:perl] if perl command fails" do
79
+ @status = 1
80
+ @ohai.stub!(:popen4).with("perl -V:version -V:archname").and_yield(
81
+ @pid,
82
+ @stdin,
83
+ @stdout,
84
+ @stderr
85
+ ).and_return(@status)
86
+ @ohai._require_plugin("perl")
87
+ @ohai.languages.should_not have_key(:perl)
88
+ end
89
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin platform" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:os] = 'monkey'
27
+ @ohai[:os_version] = 'poop'
28
+ end
29
+
30
+ it "should require the os platform plugin" do
31
+ @ohai.should_receive(:require_plugin).with("monkey::platform")
32
+ @ohai._require_plugin("platform")
33
+ end
34
+
35
+ it "should set the platform to the os if it was not set earlier" do
36
+ @ohai._require_plugin("platform")
37
+ @ohai[:platform].should eql("monkey")
38
+ end
39
+
40
+ it "should not set the platform to the os if it was set earlier" do
41
+ @ohai[:platform] = 'lars'
42
+ @ohai._require_plugin("platform")
43
+ @ohai[:platform].should eql("lars")
44
+ end
45
+
46
+ it "should set the platform_version to the os_version if it was not set earlier" do
47
+ @ohai._require_plugin("platform")
48
+ @ohai[:os_version].should eql("poop")
49
+ end
50
+
51
+ it "should not set the platform to the os if it was set earlier" do
52
+ @ohai[:platform_version] = 'ulrich'
53
+ @ohai._require_plugin("platform")
54
+ @ohai[:platform_version].should eql("ulrich")
55
+ end
56
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin python" do
23
+
24
+ before(:each) do
25
+ @ohai = Ohai::System.new
26
+ @ohai[:languages] = Mash.new
27
+ @ohai.stub!(:require_plugin).and_return(true)
28
+ @status = 0
29
+ @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n"
30
+ @stderr = ""
31
+ @ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr])
32
+ end
33
+
34
+ it "should get the python version from printing sys.version and sys.platform" do
35
+ @ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([0, "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n", ""])
36
+ @ohai._require_plugin("python")
37
+ end
38
+
39
+ it "should set languages[:python][:version]" do
40
+ @ohai._require_plugin("python")
41
+ @ohai.languages[:python][:version].should eql("2.5.2")
42
+ end
43
+
44
+ it "should not set the languages[:python] tree up if python command fails" do
45
+ @status = 1
46
+ @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n"
47
+ @stderr = ""
48
+ @ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr])
49
+ @ohai._require_plugin("python")
50
+ @ohai.languages.should_not have_key(:python)
51
+ end
52
+
53
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin ruby" do
23
+
24
+ before(:each) do
25
+ @ohai = Ohai::System.new
26
+ @ohai[:languages] = Mash.new
27
+ @ohai.stub!(:require_plugin).and_return(true)
28
+ end
29
+
30
+ {
31
+ :platform => RUBY_PLATFORM,
32
+ :version => RUBY_VERSION,
33
+ :release_date => RUBY_RELEASE_DATE,
34
+ :target => ::Config::CONFIG['target'],
35
+ :target_cpu => ::Config::CONFIG['target_cpu'],
36
+ :target_vendor => ::Config::CONFIG['target_vendor'],
37
+ :target_os => ::Config::CONFIG['target_os'],
38
+ :host => ::Config::CONFIG['host'],
39
+ :host_cpu => ::Config::CONFIG['host_cpu'],
40
+ :host_os => ::Config::CONFIG['host_os'],
41
+ :host_vendor => ::Config::CONFIG['host_vendor'],
42
+ :gems_dir => %x{#{::Config::CONFIG['bindir']}/gem env gemdir}.chomp!,
43
+ :ruby_bin => File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])
44
+ }.each do |attribute, value|
45
+ it "should have #{attribute} set" do
46
+ @ohai._require_plugin("ruby")
47
+ @ohai[:languages][:ruby][attribute].should eql(value)
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # Author:: Daniel DeLeo <dan@kallistec.com>
3
+ # Copyright:: Copyright (c) 2009 Daniel DeLeo
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '/spec_helper.rb')
20
+
21
+ describe Ohai::System, "Solaris2.X hostname plugin" do
22
+ before(:each) do
23
+ @ohai = Ohai::System.new
24
+ @ohai.stub!(:require_plugin).and_return(true)
25
+ @ohai[:os] = "solaris2"
26
+ @ohai.stub!(:from).with("hostname").and_return("kitteh")
27
+ @ohai.stub!(:from).with("domainname").and_return("inurfridge.eatinurfoodz")
28
+ end
29
+
30
+ it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh")
31
+
32
+ it "should get the fqdn value from 'hostname' + 'domainname'" do
33
+ @ohai.should_receive(:from).with("hostname").and_return("kitteh")
34
+ @ohai.should_receive(:from).with("domainname").and_return("inurfridge.eatinurfoodz")
35
+ @ohai._require_plugin("solaris2::hostname")
36
+ end
37
+
38
+ it "should set the fqdn to the value from 'hostname' and 'domainname'" do
39
+ @ohai._require_plugin("solaris2::hostname")
40
+ @ohai["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
41
+ end
42
+
43
+ end
@@ -0,0 +1,164 @@
1
+ #
2
+ # Author:: Daniel DeLeo <dan@kallistec.com>
3
+ # Copyright:: Copyright (c) 2009 Daniel DeLeo
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '/spec_helper.rb')
20
+
21
+ describe Ohai::System, "Solaris2.X kernel plugin" do
22
+ # NOTE: Solaris will report the same module loaded multiple times
23
+ # with the same ID, Loadaddr, etc. and only the info column different
24
+ # ignoring it, and removing the data from this fixture.
25
+ MODINFO=<<-TOOMUCH
26
+ Id Loadaddr Size Info Rev Module Name
27
+ 6 1180000 4623 1 1 specfs (filesystem for specfs)
28
+ 8 1185df0 38c4 1 1 TS (time sharing sched class)
29
+ 9 1188f50 8dc - 1 TS_DPTBL (Time sharing dispatch table)
30
+ 10 1188fe0 3623e 2 1 ufs (filesystem for ufs)
31
+ 11 11bc7ae 1ef - 1 fssnap_if (File System Snapshot Interface)
32
+ 12 11bc8f6 1b3a 1 1 rootnex (sun4u root nexus 1.95)
33
+ 13 11be023 210 57 1 options (options driver)
34
+ 15 11be6ff 181a 12 1 sad (STREAMS Administrative Driver ')
35
+ 16 11bfc79 64b 2 1 pseudo (nexus driver for 'pseudo')
36
+ 17 11c0152 23563 32 1 sd (SCSI Disk Driver 1.447)
37
+ 18 11e160d 8c49 - 1 scsi (SCSI Bus Utility Routines)
38
+ 23 12171db 1072b 50 1 glm (GLM SCSI HBA Driver 1.191.)
39
+ 24 1225816 edcb 111 1 pcipsy (PCI Bus nexus driver 1.214)
40
+ 26 123e0eb 15b7 - 1 dada ( ATA Bus Utility Routines)
41
+ 27 123f30a 722 - 1 todmostek (tod module for Mostek M48T59 1.)
42
+ 28 11e7342 1a902 5 1 procfs (filesystem for proc)
43
+ 29 12335a1 da0 134 1 power (power button driver v1.10)
44
+ 30 1234199 15cb 126 1 ebus (ebus nexus driver 1.44)
45
+ 32 123f9a4 12215 6 1 sockfs (filesystem for sockfs)
46
+ 34 12365ba 6ae 11 1 clone (Clone Pseudodriver 'clone')
47
+ 35 1251709 7b1a6 0 1 ip (IP Streams module)
48
+ 36 1236a10 34f 1 1 ip6 (IP Streams module)
49
+ 37 12c56af 282d1 2 1 tcp (TCP Streams module)
50
+ 38 1236ba4 107d - 1 md5 (MD5 Message-Digest Algorithm)
51
+ 39 1237b6c 365 3 1 tcp6 (TCP Streams module)
52
+ 40 1201148 a22f 4 1 udp (UDP Streams module)
53
+ 41 1237d11 365 5 1 udp6 (UDP Streams module)
54
+ 42 12096ef 86eb 6 1 icmp (ICMP Streams module)
55
+ 43 1237eb6 351 7 1 icmp6 (ICMP Streams module)
56
+ 44 123804c 6d5b 8 1 arp (ARP Streams module)
57
+ 45 1210282 46ba 9 1 timod (transport interface str mod)
58
+ 47 12152d1 c53 16 1 conskbd (Console kbd Multiplexer driver )
59
+ 48 1215b88 1ec2 15 1 wc (Workstation multiplexer Driver )
60
+ 49 12e66d4 516c 37 1 su (su driver 1.80)
61
+ 51 12ed065 4026 10 1 kb (streams module for keyboard)
62
+ 52 12efe3b 18c0 11 1 ms (streams module for mouse)
63
+ 53 12f14f7 a87 17 1 consms (Mouse Driver for Sun 'consms' 5)
64
+ 54 12f1bf6 b9d6 166 1 gfxp (TSI tspci driver %I%)
65
+ 55 12fb934 d77 14 1 iwscn (Workstation Redirection driver )
66
+ 58 1321301 4a4e 1 1 elfexec (exec module for elf)
67
+ 62 1328758 10bca - 1 usba (USBA: USB Architecture 1.36)
68
+ 64 1337002 4884 - 1 mpxio (Multipath Interface Library v1.)
69
+ 68 131ded0 36d9 3 1 fifofs (filesystem for fifo)
70
+ 69 131248e 6888 - 1 fctl (Sun FC Transport Library v1.14)
71
+ 71 1345ddc 18cff - 1 usba10 (USBA10: USB 1.0 Architecture 1.)
72
+ 75 135b92b f0e2 12 1 ldterm (terminal line discipline)
73
+ 76 1326309 246d 13 1 ttcompat (alt ioctl calls)
74
+ 77 133b574 8cbb 29 1 zs (Z8530 serial driver V4.128)
75
+ 78 1343d27 15d0 26 1 ptsl (tty pseudo driver slave 'ptsl' )
76
+ 79 12fc4f3 1e77 25 1 ptc (tty pseudo driver control 'ptc')
77
+ 81 13748db 1d2c 14 1 rts (Routing Socket Streams module)
78
+ 88 136a112 ac5a 20 1 se (Siemens SAB 82532 ESCC2 1.128)
79
+ 89 13cf520 4be3 105 1 tl (TPI Local Transport Driver - tl)
80
+ 90 13d3d1b 48d3 17 1 keysock (PF_KEY Socket Streams module)
81
+ 91 13d7766 323f 234 1 spdsock (PF_POLICY Socket Streams device)
82
+ 92 137c3fb 1672 97 1 sysmsg (System message redirection (fan)
83
+ 93 12fe1ba 82c 0 1 cn (Console redirection driver 5.57)
84
+ 94 7814fba6 4b5 2 1 intpexec (exec mod for interp)
85
+ 95 12fe826 2cb 42 1 pipe (pipe(2) syscall)
86
+ 96 137d2dd 112d 13 1 mm (memory driver 1.68)
87
+ 97 13da515 ea79 7 1 hme (10/100Mb Ethernet Driver v1.167)
88
+ 98 78058000 2e313 85 1 md (Solaris Volume Manager base mod)
89
+ 99 13e6c82 127bc 226 1 rpcmod (RPC syscall)
90
+ 100 13f6ab6 1f99 - 1 tlimod (KTLI misc module)
91
+ 101 13f89a9 54e8 - 1 md_stripe (Solaris Volume Manager stripes )
92
+ 102 78086000 13316 - 1 md_mirror (Solaris Volume Manager mirrors )
93
+ 103 78084c17 1669 15 1 mntfs (mount information file system)
94
+ 105 78098156 fe0 12 1 fdfs (filesystem for fd)
95
+ 106 7809a000 46d7 201 1 doorfs (doors)
96
+ 107 7809e3c4 16e2 4 1 namefs (filesystem for namefs)
97
+ 108 780a0000 15ef2 11 1 tmpfs (filesystem for tmpfs)
98
+ 109 78098ca6 1054 90 1 kstat (kernel statistics driver 1.18)
99
+ 110 1375e9f 3aa9 88 1 devinfo (DEVINFO Driver 1.48)
100
+ 111 13fda05 25b9 38 1 openeepr (OPENPROM/NVRAM Driver v1.14)
101
+ 112 780a5886 9c7 21 1 log (streams log driver)
102
+ 113 780bc000 2c080 106 1 nfs (NFS syscall, client, and common)
103
+ 114 780ea000 4e43 - 1 rpcsec (kernel RPC security module.)
104
+ 115 780f4000 8667 - 1 klmmod (lock mgr common module)
105
+ 116 780f0000 354c 2 1 FX (Fixed priority sched class)
106
+ 117 137e232 2ae - 1 FX_DPTBL (Fixed priority dispatch table)
107
+ 118 780fc000 668b 17 1 autofs (filesystem for autofs)
108
+ 119 780eeaab 1bba 104 1 random (random number device v1.8)
109
+ 120 12eb400 1b66 - 1 sha1 (SHA1 Message-Digest Algorithm)
110
+ 122 780f2788 13b8 - 1 bootdev (bootdev misc module 1.18)
111
+ 124 78124000 579e 127 1 pm (power management driver v1.104)
112
+ 125 781106aa 10b7 207 1 pset (processor sets)
113
+ 126 7812a000 289d 52 1 shmsys (System V shared memory)
114
+ 127 1216e2a 3dc - 1 ipc (common ipc code)
115
+ 128 7812e000 ee14 - 1 md_raid (Solaris Volume Manager raid mod)
116
+ 129 7813e000 d0cd - 1 md_trans (Solaris Volume Manager trans mo)
117
+ 130 7814c000 2a03 - 1 md_hotspares (Solaris Volume Manager hot spar)
118
+ 131 7814ab55 1004 - 1 md_notify (Solaris Volume Manager notifica)
119
+ 132 7809f7f6 903 22 1 sy (Indirect driver for tty 'sy' 1.)
120
+ 133 780e541c d34 23 1 ptm (Master streams driver 'ptm' 1.4)
121
+ 134 7812c76d d36 24 1 pts (Slave Stream Pseudo Terminal dr)
122
+ 135 7814e728 1617 19 1 ptem (pty hardware emulator)
123
+ 136 780e5eb8 2a5 20 1 redirmod (redirection module)
124
+ 137 78150000 6b71 91 1 vol (Volume Management Driver, 1.93)
125
+ 138 13285ad 2cf 21 1 connld (Streams-based pipes)
126
+ 139 137e27a 109 3 1 IA (interactive scheduling class)
127
+ 140 7813c544 1b10 22 1 hwc (streams module for hardware cur)
128
+ 141 78156871 170f 23 1 bufmod (streams buffer mod)
129
+ 142 1325c4c 838 72 1 ksyms (kernel symbols driver 1.25)
130
+ 143 12fea22 14864 33 1 st (SCSI tape Driver 1.238)
131
+ 144 1379790 2a12 53 1 semsys (System V semaphore facility)
132
+ 145 12138e4 15e4 4 1 RT (realtime scheduling class)
133
+ 146 121719e 28c - 1 RT_DPTBL (realtime dispatch table)
134
+ TOOMUCH
135
+
136
+ before(:each) do
137
+ @ohai = Ohai::System.new
138
+ @ohai.stub!(:require_plugin).and_return(true)
139
+ @ohai[:kernel] = Mash.new
140
+ @ohai.stub(:from).with("uname -s").and_return("SunOS")
141
+ end
142
+
143
+ it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", "SunOS")
144
+
145
+ it "gives excruciating detail about kernel modules" do
146
+ stdin = mock("stdin", :null_object => true)
147
+ @modinfo_stdout = StringIO.new(MODINFO)
148
+ @ohai.stub!(:popen4).with("modinfo").and_yield(nil, stdin, @modinfo_stdout, nil)
149
+
150
+ @ohai._require_plugin("solaris2::kernel")
151
+
152
+ @ohai[:kernel][:modules].should have(107).modules
153
+
154
+ # Teh daterz
155
+ # Id Loadaddr Size Info Rev Module Name
156
+ # 6 1180000 4623 1 1 specfs (filesystem for specfs)
157
+ teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"}
158
+ @ohai[:kernel][:modules].keys.should include("specfs")
159
+ @ohai[:kernel][:modules].keys.should_not include("Module")
160
+ @ohai[:kernel][:modules]["specfs"].should == teh_daterz
161
+ end
162
+
163
+
164
+ end