ohai 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +98 -0
- data/Rakefile +61 -0
- data/bin/ohai +24 -0
- data/lib/ohai.rb +27 -0
- data/lib/ohai/application.rb +113 -0
- data/lib/ohai/config.rb +29 -0
- data/lib/ohai/exception.rb +23 -0
- data/lib/ohai/log.rb +26 -0
- data/lib/ohai/mixin/command.rb +208 -0
- data/lib/ohai/mixin/from_file.rb +36 -0
- data/lib/ohai/mixin/string.rb +29 -0
- data/lib/ohai/plugins/command.rb +21 -0
- data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
- data/lib/ohai/plugins/darwin/hostname.rb +22 -0
- data/lib/ohai/plugins/darwin/kernel.rb +37 -0
- data/lib/ohai/plugins/darwin/network.rb +187 -0
- data/lib/ohai/plugins/darwin/platform.rb +36 -0
- data/lib/ohai/plugins/darwin/ps.rb +23 -0
- data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
- data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
- data/lib/ohai/plugins/darwin/uptime.rb +32 -0
- data/lib/ohai/plugins/dmi.rb +59 -0
- data/lib/ohai/plugins/ec2.rb +100 -0
- data/lib/ohai/plugins/erlang.rb +40 -0
- data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
- data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
- data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
- data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
- data/lib/ohai/plugins/freebsd/memory.rb +50 -0
- data/lib/ohai/plugins/freebsd/network.rb +112 -0
- data/lib/ohai/plugins/freebsd/platform.rb +23 -0
- data/lib/ohai/plugins/freebsd/ps.rb +24 -0
- data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
- data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
- data/lib/ohai/plugins/hostname.rb +27 -0
- data/lib/ohai/plugins/java.rb +36 -0
- data/lib/ohai/plugins/kernel.rb +33 -0
- data/lib/ohai/plugins/keys.rb +22 -0
- data/lib/ohai/plugins/languages.rb +21 -0
- data/lib/ohai/plugins/linux/block_device.rb +38 -0
- data/lib/ohai/plugins/linux/cpu.rb +60 -0
- data/lib/ohai/plugins/linux/filesystem.rb +57 -0
- data/lib/ohai/plugins/linux/hostname.rb +26 -0
- data/lib/ohai/plugins/linux/kernel.rb +33 -0
- data/lib/ohai/plugins/linux/lsb.rb +38 -0
- data/lib/ohai/plugins/linux/memory.rb +83 -0
- data/lib/ohai/plugins/linux/network.rb +112 -0
- data/lib/ohai/plugins/linux/platform.rb +43 -0
- data/lib/ohai/plugins/linux/ps.rb +23 -0
- data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/linux/uptime.rb +28 -0
- data/lib/ohai/plugins/linux/virtualization.rb +77 -0
- data/lib/ohai/plugins/netbsd/cpu.rb +48 -0
- data/lib/ohai/plugins/netbsd/filesystem.rb +57 -0
- data/lib/ohai/plugins/netbsd/hostname.rb +22 -0
- data/lib/ohai/plugins/netbsd/kernel.rb +35 -0
- data/lib/ohai/plugins/netbsd/memory.rb +98 -0
- data/lib/ohai/plugins/netbsd/network.rb +111 -0
- data/lib/ohai/plugins/netbsd/platform.rb +22 -0
- data/lib/ohai/plugins/netbsd/ps.rb +24 -0
- data/lib/ohai/plugins/netbsd/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/netbsd/uptime.rb +31 -0
- data/lib/ohai/plugins/netbsd/virtualization.rb +65 -0
- data/lib/ohai/plugins/network.rb +52 -0
- data/lib/ohai/plugins/ohai_time.rb +21 -0
- data/lib/ohai/plugins/openbsd/cpu.rb +38 -0
- data/lib/ohai/plugins/openbsd/filesystem.rb +57 -0
- data/lib/ohai/plugins/openbsd/hostname.rb +22 -0
- data/lib/ohai/plugins/openbsd/kernel.rb +35 -0
- data/lib/ohai/plugins/openbsd/memory.rb +98 -0
- data/lib/ohai/plugins/openbsd/network.rb +111 -0
- data/lib/ohai/plugins/openbsd/platform.rb +23 -0
- data/lib/ohai/plugins/openbsd/ps.rb +24 -0
- data/lib/ohai/plugins/openbsd/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/openbsd/uptime.rb +32 -0
- data/lib/ohai/plugins/openbsd/virtualization.rb +66 -0
- data/lib/ohai/plugins/os.rb +48 -0
- data/lib/ohai/plugins/perl.rb +37 -0
- data/lib/ohai/plugins/platform.rb +25 -0
- data/lib/ohai/plugins/python.rb +37 -0
- data/lib/ohai/plugins/ruby.rb +39 -0
- data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
- data/lib/ohai/plugins/solaris2/hostname.rb +25 -0
- data/lib/ohai/plugins/solaris2/kernel.rb +40 -0
- data/lib/ohai/plugins/solaris2/network.rb +141 -0
- data/lib/ohai/plugins/solaris2/platform.rb +33 -0
- data/lib/ohai/plugins/solaris2/ps.rb +23 -0
- data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/uptime.rb +42 -0
- data/lib/ohai/plugins/virtualization.rb +86 -0
- data/lib/ohai/plugins/windows/filesystem.rb +44 -0
- data/lib/ohai/plugins/windows/hostname.rb +25 -0
- data/lib/ohai/plugins/windows/kernel.rb +75 -0
- data/lib/ohai/plugins/windows/network.rb +114 -0
- data/lib/ohai/plugins/windows/platform.rb +26 -0
- data/lib/ohai/system.rb +241 -0
- data/spec/ohai/mixin/command_spec.rb +37 -0
- data/spec/ohai/mixin/from_file_spec.rb +53 -0
- data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
- data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
- data/spec/ohai/plugins/dmi_spec.rb +73 -0
- data/spec/ohai/plugins/ec2_spec.rb +81 -0
- data/spec/ohai/plugins/erlang_spec.rb +63 -0
- data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
- data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
- data/spec/ohai/plugins/hostname_spec.rb +39 -0
- data/spec/ohai/plugins/java_spec.rb +70 -0
- data/spec/ohai/plugins/kernel_spec.rb +43 -0
- data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
- data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
- data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
- data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
- data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
- data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
- data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
- data/spec/ohai/plugins/netbsd/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/netbsd/kernel_spec.rb +36 -0
- data/spec/ohai/plugins/netbsd/platform_spec.rb +40 -0
- data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
- data/spec/ohai/plugins/openbsd/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/openbsd/kernel_spec.rb +37 -0
- data/spec/ohai/plugins/openbsd/platform_spec.rb +40 -0
- data/spec/ohai/plugins/os_spec.rb +69 -0
- data/spec/ohai/plugins/perl_spec.rb +89 -0
- data/spec/ohai/plugins/platform_spec.rb +56 -0
- data/spec/ohai/plugins/python_spec.rb +53 -0
- data/spec/ohai/plugins/ruby_spec.rb +51 -0
- data/spec/ohai/plugins/solaris2/hostname_spec.rb +43 -0
- data/spec/ohai/plugins/solaris2/kernel_spec.rb +164 -0
- data/spec/ohai/system_spec.rb +130 -0
- data/spec/ohai_spec.rb +27 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +68 -0
- metadata +240 -0
@@ -0,0 +1,39 @@
|
|
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, "hostname plugin" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set the domain to everything after the first dot of the fqdn" do
|
29
|
+
@ohai[:fqdn] = "katie.bethell"
|
30
|
+
@ohai._require_plugin("hostname")
|
31
|
+
@ohai.domain.should == "bethell"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not set a domain if fqdn is not set" do
|
35
|
+
@ohai._require_plugin("hostname")
|
36
|
+
@ohai.domain.should == nil
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Benjamin Black (<bb@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 java" do
|
22
|
+
before(:each) do
|
23
|
+
@ohai = Ohai::System.new
|
24
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
25
|
+
@ohai[:languages] = Mash.new
|
26
|
+
@status = 0
|
27
|
+
@stdout = ""
|
28
|
+
@stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"
|
29
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should run java -version" do
|
33
|
+
@ohai.should_receive(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([0, "", "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"])
|
34
|
+
@ohai._require_plugin("java")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set java[:version]" do
|
38
|
+
@ohai._require_plugin("java")
|
39
|
+
@ohai.languages[:java][:version].should eql("1.5.0_16")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should set java[:runtime][:name] to runtime name" do
|
43
|
+
@ohai._require_plugin("java")
|
44
|
+
@ohai.languages[:java][:runtime][:name].should eql("Java(TM) 2 Runtime Environment, Standard Edition")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should set java[:runtime][:build] to runtime build" do
|
48
|
+
@ohai._require_plugin("java")
|
49
|
+
@ohai.languages[:java][:runtime][:build].should eql("1.5.0_16-b06-284")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should set java[:hotspot][:name] to hotspot name" do
|
53
|
+
@ohai._require_plugin("java")
|
54
|
+
@ohai.languages[:java][:hotspot][:name].should eql("Java HotSpot(TM) Client VM")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set java[:hotspot][:build] to hotspot build" do
|
58
|
+
@ohai._require_plugin("java")
|
59
|
+
@ohai.languages[:java][:hotspot][:build].should eql("1.5.0_16-133, mixed mode, sharing")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not set the languages[:java] tree up if java command fails" do
|
63
|
+
@status = 1
|
64
|
+
@stdout = ""
|
65
|
+
@stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"
|
66
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr])
|
67
|
+
@ohai._require_plugin("java")
|
68
|
+
@ohai.languages.should_not have_key(:java)
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 kernel" 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.stub!(:from).with("uname -s").and_return("Darwin")
|
29
|
+
@ohai.stub!(:from).with("uname -r").and_return("9.5.0")
|
30
|
+
@ohai.stub!(:from).with("uname -v").and_return("Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386")
|
31
|
+
@ohai.stub!(:from).with("uname -m").and_return("i386")
|
32
|
+
@ohai.stub!(:from).with("uname -o").and_return("Linux")
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_check_from_mash("kernel", "name", "uname -s", "Darwin")
|
36
|
+
|
37
|
+
it_should_check_from_mash("kernel", "release", "uname -r", "9.5.0")
|
38
|
+
|
39
|
+
it_should_check_from_mash("kernel", "version", "uname -v", "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386")
|
40
|
+
|
41
|
+
it_should_check_from_mash("kernel", "machine", "uname -m", "i386")
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,128 @@
|
|
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, "Linux cpu plugin" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
+
@ohai[:os] = "linux"
|
27
|
+
@mock_file = mock("/proc/cpuinfo")
|
28
|
+
@mock_file.stub!(:each).
|
29
|
+
and_yield("processor : 0").
|
30
|
+
and_yield("vendor_id : GenuineIntel").
|
31
|
+
and_yield("cpu family : 6").
|
32
|
+
and_yield("model : 23").
|
33
|
+
and_yield("model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz").
|
34
|
+
and_yield("stepping : 6").
|
35
|
+
and_yield("cpu MHz : 1968.770").
|
36
|
+
and_yield("cache size : 64 KB").
|
37
|
+
and_yield("fdiv_bug : no").
|
38
|
+
and_yield("hlt_bug : no").
|
39
|
+
and_yield("f00f_bug : no").
|
40
|
+
and_yield("coma_bug : no").
|
41
|
+
and_yield("fpu : yes").
|
42
|
+
and_yield("fpu_exception : yes").
|
43
|
+
and_yield("cpuid level : 10").
|
44
|
+
and_yield("wp : yes").
|
45
|
+
and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov").
|
46
|
+
and_yield("bogomips : 2575.86").
|
47
|
+
and_yield("clflush size : 32")
|
48
|
+
File.stub!(:open).with("/proc/cpuinfo").and_return(@mock_file)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set cpu[:total] to 1" do
|
52
|
+
@ohai._require_plugin("linux::cpu")
|
53
|
+
@ohai[:cpu][:total].should == 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should set cpu[:real] to 0" do
|
57
|
+
@ohai._require_plugin("linux::cpu")
|
58
|
+
@ohai[:cpu][:real].should == 0
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have a cpu 0" do
|
62
|
+
@ohai._require_plugin("linux::cpu")
|
63
|
+
@ohai[:cpu].should have_key("0")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have a vendor_id for cpu 0" do
|
67
|
+
@ohai._require_plugin("linux::cpu")
|
68
|
+
@ohai[:cpu]["0"].should have_key("vendor_id")
|
69
|
+
@ohai[:cpu]["0"]["vendor_id"].should eql("GenuineIntel")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have a family for cpu 0" do
|
73
|
+
@ohai._require_plugin("linux::cpu")
|
74
|
+
@ohai[:cpu]["0"].should have_key("family")
|
75
|
+
@ohai[:cpu]["0"]["family"].should eql("6")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have a model for cpu 0" do
|
79
|
+
@ohai._require_plugin("linux::cpu")
|
80
|
+
@ohai[:cpu]["0"].should have_key("model")
|
81
|
+
@ohai[:cpu]["0"]["model"].should eql("23")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have a stepping for cpu 0" do
|
85
|
+
@ohai._require_plugin("linux::cpu")
|
86
|
+
@ohai[:cpu]["0"].should have_key("stepping")
|
87
|
+
@ohai[:cpu]["0"]["stepping"].should eql("6")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not have a phyiscal_id for cpu 0" do
|
91
|
+
@ohai._require_plugin("linux::cpu")
|
92
|
+
@ohai[:cpu]["0"].should_not have_key("physical_id")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not have a core_id for cpu 0" do
|
96
|
+
@ohai._require_plugin("linux::cpu")
|
97
|
+
@ohai[:cpu]["0"].should_not have_key("core_id")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not have a cores for cpu 0" do
|
101
|
+
@ohai._require_plugin("linux::cpu")
|
102
|
+
@ohai[:cpu]["0"].should_not have_key("cores")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should have a model name for cpu 0" do
|
106
|
+
@ohai._require_plugin("linux::cpu")
|
107
|
+
@ohai[:cpu]["0"].should have_key("model_name")
|
108
|
+
@ohai[:cpu]["0"]["model_name"].should eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should have a mhz for cpu 0" do
|
112
|
+
@ohai._require_plugin("linux::cpu")
|
113
|
+
@ohai[:cpu]["0"].should have_key("mhz")
|
114
|
+
@ohai[:cpu]["0"]["mhz"].should eql("1968.770")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should have a cache_size for cpu 0" do
|
118
|
+
@ohai._require_plugin("linux::cpu")
|
119
|
+
@ohai[:cpu]["0"].should have_key("cache_size")
|
120
|
+
@ohai[:cpu]["0"]["cache_size"].should eql("64 KB")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should have flags for cpu 0" do
|
124
|
+
@ohai._require_plugin("linux::cpu")
|
125
|
+
@ohai[:cpu]["0"].should have_key("flags")
|
126
|
+
@ohai[:cpu]["0"]["flags"].should == %w{fpu pse tsc msr mce cx8 sep mtrr pge cmov}
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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, "Linux hostname plugin" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
+
@ohai[:os] = "linux"
|
27
|
+
@ohai.stub!(:from).with("hostname -s").and_return("katie")
|
28
|
+
@ohai.stub!(:from).with("hostname --fqdn").and_return("katie.bethell")
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
32
|
+
|
33
|
+
it_should_check_from("linux::hostname", "fqdn", "hostname --fqdn", "katie.bethell")
|
34
|
+
|
35
|
+
describe "when domain name is unset" do
|
36
|
+
before(:each) do
|
37
|
+
@ohai.should_receive(:from).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not raise an error" do
|
41
|
+
lambda { @ohai._require_plugin("linux::hostname") }.should_not raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not set fqdn" do
|
45
|
+
@ohai._require_plugin("linux::hostname")
|
46
|
+
@ohai.fqdn.should == nil
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,31 @@
|
|
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, "Linux kernel plugin" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai._require_plugin("kernel")
|
26
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
27
|
+
@ohai.stub!(:from).with("uname -o").and_return("Linux")
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", "Linux")
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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, "Linux lsb plugin" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai[:os] = "linux"
|
26
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
27
|
+
@mock_file = mock("/etc/lsb-release")
|
28
|
+
@mock_file.stub!(:each).
|
29
|
+
and_yield("DISTRIB_ID=Ubuntu").
|
30
|
+
and_yield("DISTRIB_RELEASE=8.04").
|
31
|
+
and_yield("DISTRIB_CODENAME=hardy").
|
32
|
+
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
|
33
|
+
File.stub!(:open).with("/etc/lsb-release").and_return(@mock_file)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should set lsb[:id]" do
|
37
|
+
@ohai._require_plugin("linux::lsb")
|
38
|
+
@ohai[:lsb][:id].should == "Ubuntu"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set lsb[:release]" do
|
42
|
+
@ohai._require_plugin("linux::lsb")
|
43
|
+
@ohai[:lsb][:release].should == "8.04"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should set lsb[:codename]" do
|
47
|
+
@ohai._require_plugin("linux::lsb")
|
48
|
+
@ohai[:lsb][:codename].should == "hardy"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set lsb[:description]" do
|
52
|
+
@ohai._require_plugin("linux::lsb")
|
53
|
+
@ohai[:lsb][:description].should == "\"Ubuntu 8.04\""
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should not set any lsb values if /etc/lsb-release cannot be read" do
|
57
|
+
File.stub!(:open).with("/etc/lsb-release").and_raise(IOError)
|
58
|
+
@ohai.attribute?(:lsb).should be(false)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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, "Linux plugin platform" do
|
23
|
+
before(:each) do
|
24
|
+
@ohai = Ohai::System.new
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
+
@ohai.extend(SimpleFromFile)
|
27
|
+
@ohai[:os] = "linux"
|
28
|
+
@ohai[:lsb] = Mash.new
|
29
|
+
File.stub!(:exists?).with("/etc/debian_version").and_return(false)
|
30
|
+
File.stub!(:exists?).with("/etc/redhat-release").and_return(false)
|
31
|
+
File.stub!(:exists?).with("/etc/gentoo-release").and_return(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should require the lsb plugin" do
|
35
|
+
@ohai.should_receive(:require_plugin).with("linux::lsb").and_return(true)
|
36
|
+
@ohai._require_plugin("linux::platform")
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "on lsb compliant distributions" do
|
40
|
+
before(:each) do
|
41
|
+
@ohai[:lsb][:id] = "Ubuntu"
|
42
|
+
@ohai[:lsb][:release] = "8.04"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should set platform to lowercased lsb[:id]" do
|
46
|
+
@ohai._require_plugin("linux::platform")
|
47
|
+
@ohai[:platform].should == "ubuntu"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should set platform_version to lsb[:release]" do
|
51
|
+
@ohai._require_plugin("linux::platform")
|
52
|
+
@ohai[:platform_version].should == "8.04"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "on debian" do
|
57
|
+
before(:each) do
|
58
|
+
@ohai.lsb = nil
|
59
|
+
File.should_receive(:exists?).with("/etc/debian_version").and_return(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should check for the existance of debian_version" do
|
63
|
+
@ohai._require_plugin("linux::platform")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should read the version from /etc/debian_version" do
|
67
|
+
File.should_receive(:read).with("/etc/debian_version").and_return("5.0")
|
68
|
+
@ohai._require_plugin("linux::platform")
|
69
|
+
@ohai[:platform_version].should == "5.0"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should correctly strip any newlines" do
|
73
|
+
File.should_receive(:read).with("/etc/debian_version").and_return("5.0\n")
|
74
|
+
@ohai._require_plugin("linux::platform")
|
75
|
+
@ohai[:platform_version].should == "5.0"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|