ohai 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,34 @@
|
|
|
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, "Darwin hostname plugin" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai[:os] = "darwin"
|
|
27
|
+
@ohai.stub!(:from).with("hostname -s").and_return("katie")
|
|
28
|
+
@ohai.stub!(:from).with("hostname").and_return("katie.bethell")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie")
|
|
32
|
+
|
|
33
|
+
it_should_check_from("darwin::hostname", "fqdn", "hostname", "katie.bethell")
|
|
34
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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, "Darwin kernel plugin" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai[:kernel] = Mash.new
|
|
27
|
+
@ohai[:kernel][:name] = "darwin"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should not set kernel_machine to x86_64" do
|
|
31
|
+
@ohai.stub!(:from).with("sysctl -n hw.optional.x86_64").and_return("0")
|
|
32
|
+
@ohai._require_plugin("darwin::kernel")
|
|
33
|
+
@ohai[:kernel][:machine].should_not == 'x86_64'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should set kernel_machine to x86_64" do
|
|
37
|
+
@ohai.stub!(:from).with("sysctl -n hw.optional.x86_64").and_return("1")
|
|
38
|
+
@ohai._require_plugin("darwin::kernel")
|
|
39
|
+
@ohai[:kernel][:machine].should == 'x86_64'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should set the kernel_os to the kernel_name value" do
|
|
43
|
+
@ohai._require_plugin("darwin::kernel")
|
|
44
|
+
@ohai[:kernel][:os].should == @ohai[:kernel][:name]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
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, "Darwin plugin platform" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai[:os] = "darwin"
|
|
27
|
+
@pid = 10
|
|
28
|
+
@stdin = mock("STDIN", { :close => true })
|
|
29
|
+
@stdout = mock("STDOUT")
|
|
30
|
+
@stdout.stub!(:each).
|
|
31
|
+
and_yield("ProductName: Mac OS X").
|
|
32
|
+
and_yield("ProductVersion: 10.5.5").
|
|
33
|
+
and_yield("BuildVersion: 9F33")
|
|
34
|
+
@stderr = mock("STDERR")
|
|
35
|
+
@ohai.stub!(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should run sw_vers" do
|
|
39
|
+
@ohai.should_receive(:popen4).with("/usr/bin/sw_vers").and_return(true)
|
|
40
|
+
@ohai._require_plugin("darwin::platform")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should close sw_vers stdin" do
|
|
44
|
+
@stdin.should_receive(:close)
|
|
45
|
+
@ohai._require_plugin("darwin::platform")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should iterate over each line of sw_vers stdout" do
|
|
49
|
+
@stdout.should_receive(:each).and_return(true)
|
|
50
|
+
@ohai._require_plugin("darwin::platform")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should set platform to ProductName, downcased with _ for \\s" do
|
|
54
|
+
@ohai._require_plugin("darwin::platform")
|
|
55
|
+
@ohai[:platform].should == "mac_os_x"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should set platform_version to ProductVersion" do
|
|
59
|
+
@ohai._require_plugin("darwin::platform")
|
|
60
|
+
@ohai[:platform_version].should == "10.5.5"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should set platform_build to BuildVersion" do
|
|
64
|
+
@ohai._require_plugin("darwin::platform")
|
|
65
|
+
@ohai[:platform_build].should == "9F33"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
|
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 dmi" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:from).with("dmidecode --version").and_return("2.9")
|
|
26
|
+
@ohai.stub!(:from).with("dmidecode -s bios-vendor").and_return("Dell Inc.")
|
|
27
|
+
@ohai.stub!(:from).with("dmidecode -s bios-version").and_return("2.6.1")
|
|
28
|
+
@ohai.stub!(:from).with("dmidecode -s bios-release-date").and_return("12\/06\/2007")
|
|
29
|
+
@ohai.stub!(:from).with("dmidecode -s system-manufacturer").and_return("Dell Inc.")
|
|
30
|
+
@ohai.stub!(:from).with("dmidecode -s system-product-name").and_return("OptiPlex 745")
|
|
31
|
+
@ohai.stub!(:from).with("dmidecode -s system-version").and_return("Not Specified")
|
|
32
|
+
@ohai.stub!(:from).with("dmidecode -s system-serial-number").and_return("XXXXXXX")
|
|
33
|
+
@ohai.stub!(:from).with("dmidecode -s system-uuid").and_return("44454C4C-4700-1032-8035-B9C04F474331")
|
|
34
|
+
@ohai.stub!(:from).with("dmidecode -s baseboard-manufacturer").and_return("Dell Inc.")
|
|
35
|
+
@ohai.stub!(:from).with("dmidecode -s baseboard-product-name").and_return("0RF703")
|
|
36
|
+
@ohai.stub!(:from).with("dmidecode -s baseboard-version").and_return("Not Specified")
|
|
37
|
+
@ohai.stub!(:from).with("dmidecode -s baseboard-serial-number").and_return("..CN137406CP0289.")
|
|
38
|
+
@ohai.stub!(:from).with("dmidecode -s baseboard-asset-tag").and_return("None")
|
|
39
|
+
@ohai.stub!(:from).with("dmidecode -s chassis-manufacturer").and_return("Dell Inc.")
|
|
40
|
+
@ohai.stub!(:from).with("dmidecode -s chassis-type").and_return("Mini Tower")
|
|
41
|
+
@ohai.stub!(:from).with("dmidecode -s chassis-version").and_return("Not Specified")
|
|
42
|
+
@ohai.stub!(:from).with("dmidecode -s chassis-serial-number").and_return("XXXXXXX")
|
|
43
|
+
@ohai.stub!(:from).with("dmidecode -s chassis-asset-tag").and_return("None")
|
|
44
|
+
@ohai.stub!(:from).with("dmidecode -s processor-family").and_return("Not Specified")
|
|
45
|
+
@ohai.stub!(:from).with("dmidecode -s processor-manufacturer").and_return("Intel")
|
|
46
|
+
@ohai.stub!(:from).with("dmidecode -s processor-version").and_return("Not Specified")
|
|
47
|
+
@ohai.stub!(:from).with("dmidecode -s processor-frequency").and_return("2000 Mhz")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it_should_check_from_deep_mash("dmi", "dmi", "version", "dmidecode --version", "2.9")
|
|
51
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "bios" ], "vendor", "dmidecode -s bios-vendor", "Dell Inc.")
|
|
52
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "bios" ], "version", "dmidecode -s bios-version", "2.6.1")
|
|
53
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "bios" ], "release_date", "dmidecode -s bios-release-date", "12\/06\/2007")
|
|
54
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "system" ], "manufacturer", "dmidecode -s system-manufacturer", "Dell Inc.")
|
|
55
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "system" ], "product_name", "dmidecode -s system-product-name", "OptiPlex 745")
|
|
56
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "system" ], "version", "dmidecode -s system-version", "Not Specified")
|
|
57
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "system" ], "serial_number", "dmidecode -s system-serial-number", "XXXXXXX")
|
|
58
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "system" ], "uuid", "dmidecode -s system-uuid", "44454C4C-4700-1032-8035-B9C04F474331")
|
|
59
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "baseboard" ], "manufacturer", "dmidecode -s baseboard-manufacturer", "Dell Inc.")
|
|
60
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "baseboard" ], "product_name", "dmidecode -s baseboard-product-name", "0RF703")
|
|
61
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "baseboard" ], "version", "dmidecode -s baseboard-version", "Not Specified")
|
|
62
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "baseboard" ], "serial_number", "dmidecode -s baseboard-serial-number", "..CN137406CP0289.")
|
|
63
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "baseboard" ], "asset_tag", "dmidecode -s baseboard-asset-tag", "None")
|
|
64
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "chassis" ], "manufacturer", "dmidecode -s chassis-manufacturer", "Dell Inc.")
|
|
65
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "chassis" ], "type", "dmidecode -s chassis-type", "Mini Tower")
|
|
66
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "chassis" ], "version", "dmidecode -s chassis-version", "Not Specified")
|
|
67
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "chassis" ], "serial_number", "dmidecode -s chassis-serial-number", "XXXXXXX")
|
|
68
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "chassis" ], "asset_tag", "dmidecode -s chassis-asset-tag", "None")
|
|
69
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "processor" ], "family", "dmidecode -s processor-family", "Not Specified")
|
|
70
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "processor" ], "manufacturer", "dmidecode -s processor-manufacturer", "Intel")
|
|
71
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "processor" ], "version", "dmidecode -s processor-version", "Not Specified")
|
|
72
|
+
it_should_check_from_deep_mash("dmi", [ "dmi", "processor" ], "frequency", "dmidecode -s processor-frequency", "2000 Mhz")
|
|
73
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
|
3
|
+
# Author:: Christopher Brown (cb@opscode.com)
|
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
|
5
|
+
# License:: Apache License, Version 2.0
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
|
|
21
|
+
require 'open-uri'
|
|
22
|
+
|
|
23
|
+
describe Ohai::System, "plugin ec2" do
|
|
24
|
+
before(:each) do
|
|
25
|
+
@ohai = Ohai::System.new
|
|
26
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
27
|
+
@ohai[:network] = {:interfaces => {:eth0 => {} } }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "!ec2", :shared => true do
|
|
31
|
+
it "should NOT attempt to fetch the ec2 metadata" do
|
|
32
|
+
OpenURI.should_not_receive(:open)
|
|
33
|
+
@ohai._require_plugin("ec2")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "ec2", :shared => true do
|
|
38
|
+
before(:each) do
|
|
39
|
+
OpenURI.stub!(:open_uri).
|
|
40
|
+
with("http://169.254.169.254/2008-02-01/meta-data/").
|
|
41
|
+
and_return(mock(IO, :read => "instance_type\nami_id\n"))
|
|
42
|
+
OpenURI.stub!(:open_uri).
|
|
43
|
+
with("http://169.254.169.254/2008-02-01/meta-data/instance_type").
|
|
44
|
+
and_return(mock(IO, :read => "c1.medium"))
|
|
45
|
+
OpenURI.stub!(:open_uri).
|
|
46
|
+
with("http://169.254.169.254/2008-02-01/meta-data/ami_id").
|
|
47
|
+
and_return(mock(IO, :read => "ami-5d2dc934"))
|
|
48
|
+
OpenURI.stub!(:open_uri).
|
|
49
|
+
with("http://169.254.169.254/2008-02-01/user-data/").
|
|
50
|
+
and_return(mock(IO, :gets => "By the pricking of my thumb..."))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should recursively fetch all the ec2 metadata" do
|
|
54
|
+
IO.stub!(:select).and_return([[],[1],[]])
|
|
55
|
+
t = mock("connection")
|
|
56
|
+
t.stub!(:connect_nonblock).and_raise(Errno::EINPROGRESS)
|
|
57
|
+
Socket.stub!(:new).and_return(t)
|
|
58
|
+
@ohai._require_plugin("ec2")
|
|
59
|
+
@ohai[:ec2].should_not be_nil
|
|
60
|
+
@ohai[:ec2]['instance_type'].should == "c1.medium"
|
|
61
|
+
@ohai[:ec2]['ami_id'].should == "ami-5d2dc934"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "with ec2 mac and metadata address connected" do
|
|
66
|
+
it_should_behave_like "ec2"
|
|
67
|
+
|
|
68
|
+
before(:each) do
|
|
69
|
+
IO.stub!(:select).and_return([[],[1],[]])
|
|
70
|
+
@ohai[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"}
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe "without ec2 mac and metadata address connected" do
|
|
75
|
+
it_should_behave_like "!ec2"
|
|
76
|
+
|
|
77
|
+
before(:each) do
|
|
78
|
+
@ohai[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"00:50:56:c0:00:08"}
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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 erlang" 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
|
+
@stdin = ""
|
|
30
|
+
@stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
|
|
31
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should get the erlang version from erl +V" do
|
|
35
|
+
@ohai.should_receive(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([0, "", "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"])
|
|
36
|
+
@ohai._require_plugin("erlang")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should set languages[:erlang][:version]" do
|
|
40
|
+
@ohai._require_plugin("erlang")
|
|
41
|
+
@ohai.languages[:erlang][:version].should eql("5.6.2")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should set languages[:erlang][:options]" do
|
|
45
|
+
@ohai._require_plugin("erlang")
|
|
46
|
+
@ohai.languages[:erlang][:options].should eql(["ASYNC_THREADS", "SMP", "HIPE"])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should set languages[:erlang][:emulator]" do
|
|
50
|
+
@ohai._require_plugin("erlang")
|
|
51
|
+
@ohai.languages[:erlang][:emulator].should eql("BEAM")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should not set the languages[:erlang] tree up if erlang command fails" do
|
|
55
|
+
@status = 1
|
|
56
|
+
@stdin = ""
|
|
57
|
+
@stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
|
|
58
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr])
|
|
59
|
+
@ohai._require_plugin("erlang")
|
|
60
|
+
@ohai.languages.should_not have_key(:erlang)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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, "FreeBSD hostname plugin" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai[:os] = "freebsd"
|
|
27
|
+
@ohai.stub!(:from).with("hostname -s").and_return("katie")
|
|
28
|
+
@ohai.stub!(:from).with("hostname -f").and_return("katie.bethell")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie")
|
|
32
|
+
|
|
33
|
+
it_should_check_from("freebsd::hostname", "fqdn", "hostname -f", "katie.bethell")
|
|
34
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
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, "FreeBSD kernel plugin" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai.stub!(:from).with("uname -i").and_return("foo")
|
|
27
|
+
@ohai.stub!(:from_with_regex).with("sysctl kern.securelevel").and_return("kern.securelevel: 1")
|
|
28
|
+
@ohai[:kernel] = Mash.new
|
|
29
|
+
@ohai[:kernel][:name] = "freebsd"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should set the kernel_os to the kernel_name value" do
|
|
33
|
+
@ohai._require_plugin("freebsd::kernel")
|
|
34
|
+
@ohai[:kernel][:os].should == @ohai[:kernel][:name]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
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, "FreeBSD plugin platform" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@ohai = Ohai::System.new
|
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
|
26
|
+
@ohai.stub!(:from).with("uname -s").and_return("FreeBSD")
|
|
27
|
+
@ohai.stub!(:from).with("uname -r").and_return("7.1")
|
|
28
|
+
@ohai[:os] = "freebsd"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should set platform to lowercased lsb[:id]" do
|
|
32
|
+
@ohai._require_plugin("freebsd::platform")
|
|
33
|
+
@ohai[:platform].should == "freebsd"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should set platform_version to lsb[:release]" do
|
|
37
|
+
@ohai._require_plugin("freebsd::platform")
|
|
38
|
+
@ohai[:platform_version].should == "7.1"
|
|
39
|
+
end
|
|
40
|
+
end
|