ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -21,41 +21,29 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "Linux plugin uptime" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
|
28
|
-
@mock_file = mock("/proc/uptime", { :gets => "18423 989" })
|
29
|
-
File.stub!(:open).with("/proc/uptime").and_return(@mock_file)
|
24
|
+
@plugin = get_plugin("uptime")
|
25
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
26
|
+
@double_file = double("/proc/uptime", { :gets => "18423 989" })
|
27
|
+
File.stub(:open).with("/proc/uptime").and_return(@double_file)
|
30
28
|
end
|
31
29
|
|
32
|
-
it "should check /proc/uptime for the uptime and idletime" do
|
33
|
-
File.should_receive(:open).with("/proc/uptime").and_return(@mock_file)
|
34
|
-
@ohai._require_plugin("linux::uptime")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should split the value of /proc uptime" do
|
38
|
-
@mock_file.gets.should_receive(:split).with(" ").and_return(["18423", "989"])
|
39
|
-
@ohai._require_plugin("linux::uptime")
|
40
|
-
end
|
41
|
-
|
42
30
|
it "should set uptime_seconds to uptime" do
|
43
|
-
@
|
44
|
-
@
|
31
|
+
@plugin.run
|
32
|
+
@plugin[:uptime_seconds].should == 18423
|
45
33
|
end
|
46
34
|
|
47
35
|
it "should set uptime to a human readable date" do
|
48
|
-
@
|
49
|
-
@
|
36
|
+
@plugin.run
|
37
|
+
@plugin[:uptime].should == "5 hours 07 minutes 03 seconds"
|
50
38
|
end
|
51
39
|
|
52
40
|
it "should set idletime_seconds to uptime" do
|
53
|
-
@
|
54
|
-
@
|
41
|
+
@plugin.run
|
42
|
+
@plugin[:idletime_seconds].should == 989
|
55
43
|
end
|
56
44
|
|
57
45
|
it "should set idletime to a human readable date" do
|
58
|
-
@
|
59
|
-
@
|
46
|
+
@plugin.run
|
47
|
+
@plugin[:idletime].should == "16 minutes 29 seconds"
|
60
48
|
end
|
61
|
-
end
|
49
|
+
end
|
@@ -20,230 +20,250 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux virtualization platform" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
-
@ohai.extend(SimpleFromFile)
|
23
|
+
@plugin = get_plugin("linux/virtualization")
|
24
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
27
25
|
|
28
26
|
# default to all requested Files not existing
|
29
|
-
File.stub
|
30
|
-
File.stub
|
31
|
-
File.stub
|
32
|
-
File.stub
|
33
|
-
File.stub
|
34
|
-
File.stub
|
35
|
-
File.stub
|
36
|
-
File.stub
|
27
|
+
File.stub(:exists?).with("/proc/xen").and_return(false)
|
28
|
+
File.stub(:exists?).with("/proc/xen/capabilities").and_return(false)
|
29
|
+
File.stub(:exists?).with("/proc/modules").and_return(false)
|
30
|
+
File.stub(:exists?).with("/proc/cpuinfo").and_return(false)
|
31
|
+
File.stub(:exists?).with("/usr/sbin/dmidecode").and_return(false)
|
32
|
+
File.stub(:exists?).with("/proc/self/status").and_return(false)
|
33
|
+
File.stub(:exists?).with("/proc/bc/0").and_return(false)
|
34
|
+
File.stub(:exists?).with("/proc/vz").and_return(false)
|
37
35
|
end
|
38
36
|
|
39
37
|
describe "when we are checking for xen" do
|
40
38
|
it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
|
41
39
|
File.should_receive(:exists?).with("/proc/xen").and_return(true)
|
42
40
|
File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(false)
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
41
|
+
@plugin.run
|
42
|
+
@plugin[:virtualization][:system].should == "xen"
|
43
|
+
@plugin[:virtualization][:role].should == "guest"
|
46
44
|
end
|
47
45
|
|
48
46
|
it "should set xen host if /proc/xen/capabilities contains control_d " do
|
49
47
|
File.should_receive(:exists?).with("/proc/xen").and_return(true)
|
50
48
|
File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
51
|
-
File.stub
|
52
|
-
@
|
53
|
-
@
|
54
|
-
@
|
49
|
+
File.stub(:read).with("/proc/xen/capabilities").and_return("control_d")
|
50
|
+
@plugin.run
|
51
|
+
@plugin[:virtualization][:system].should == "xen"
|
52
|
+
@plugin[:virtualization][:role].should == "host"
|
55
53
|
end
|
56
54
|
|
57
55
|
it "should set xen guest if /proc/xen/capabilities exists but is empty" do
|
58
56
|
File.should_receive(:exists?).with("/proc/xen").and_return(true)
|
59
57
|
File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
60
|
-
File.stub
|
61
|
-
@
|
62
|
-
@
|
63
|
-
@
|
58
|
+
File.stub(:read).with("/proc/xen/capabilities").and_return("")
|
59
|
+
@plugin.run
|
60
|
+
@plugin[:virtualization][:system].should == "xen"
|
61
|
+
@plugin[:virtualization][:role].should == "guest"
|
64
62
|
end
|
65
63
|
|
66
64
|
it "should not set virtualization if xen isn't there" do
|
67
65
|
File.should_receive(:exists?).at_least(:once).and_return(false)
|
68
|
-
@
|
69
|
-
@
|
66
|
+
@plugin.run
|
67
|
+
@plugin[:virtualization].should == {}
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
73
71
|
describe "when we are checking for kvm" do
|
74
72
|
it "should set kvm host if /proc/modules contains kvm" do
|
75
73
|
File.should_receive(:exists?).with("/proc/modules").and_return(true)
|
76
|
-
File.stub
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
74
|
+
File.stub(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
|
75
|
+
@plugin.run
|
76
|
+
@plugin[:virtualization][:system].should == "kvm"
|
77
|
+
@plugin[:virtualization][:role].should == "host"
|
80
78
|
end
|
81
79
|
|
82
80
|
it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
|
83
81
|
File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
84
|
-
File.stub
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@
|
82
|
+
File.stub(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
|
83
|
+
@plugin.run
|
84
|
+
@plugin[:virtualization][:system].should == "kvm"
|
85
|
+
@plugin[:virtualization][:role].should == "guest"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should set kvm guest if /proc/cpuinfo contains Common KVM processor" do
|
89
|
+
File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
90
|
+
File.stub(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
|
91
|
+
@plugin.run
|
92
|
+
@plugin[:virtualization][:system].should == "kvm"
|
93
|
+
@plugin[:virtualization][:role].should == "guest"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should set kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
|
97
|
+
File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
98
|
+
File.stub(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
|
99
|
+
@plugin.run
|
100
|
+
@plugin[:virtualization][:system].should == "kvm"
|
101
|
+
@plugin[:virtualization][:role].should == "guest"
|
88
102
|
end
|
89
103
|
|
90
104
|
it "should not set virtualization if kvm isn't there" do
|
91
105
|
File.should_receive(:exists?).at_least(:once).and_return(false)
|
92
|
-
@
|
93
|
-
@
|
106
|
+
@plugin.run
|
107
|
+
@plugin[:virtualization].should == {}
|
94
108
|
end
|
95
109
|
end
|
96
110
|
|
97
111
|
describe "when we are checking for VirtualBox" do
|
98
112
|
it "should set vbox host if /proc/modules contains vboxdrv" do
|
99
113
|
File.should_receive(:exists?).with("/proc/modules").and_return(true)
|
100
|
-
File.stub
|
101
|
-
@
|
102
|
-
@
|
103
|
-
@
|
114
|
+
File.stub(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
|
115
|
+
@plugin.run
|
116
|
+
@plugin[:virtualization][:system].should == "vbox"
|
117
|
+
@plugin[:virtualization][:role].should == "host"
|
104
118
|
end
|
105
119
|
|
106
|
-
it "should set vbox
|
120
|
+
it "should set vbox gues if /proc/modules contains vboxguest" do
|
107
121
|
File.should_receive(:exists?).with("/proc/modules").and_return(true)
|
108
|
-
File.stub
|
109
|
-
@
|
110
|
-
@
|
111
|
-
@
|
122
|
+
File.stub(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
|
123
|
+
@plugin.run
|
124
|
+
@plugin[:virtualization][:system].should == "vbox"
|
125
|
+
@plugin[:virtualization][:role].should == "guest"
|
112
126
|
end
|
113
127
|
|
114
128
|
it "should not set virtualization if vbox isn't there" do
|
115
129
|
File.should_receive(:exists?).at_least(:once).and_return(false)
|
116
|
-
@
|
117
|
-
@
|
130
|
+
@plugin.run
|
131
|
+
@plugin[:virtualization].should == {}
|
118
132
|
end
|
119
133
|
end
|
120
134
|
|
121
135
|
describe "when we are parsing dmidecode" do
|
122
136
|
before(:each) do
|
123
137
|
File.should_receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
|
124
|
-
@stdin = mock("STDIN", { :close => true })
|
125
|
-
@pid = 10
|
126
|
-
@stderr = mock("STDERR")
|
127
|
-
@stdout = mock("STDOUT")
|
128
|
-
@status = 0
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should run dmidecode" do
|
132
|
-
@ohai.should_receive(:popen4).with("dmidecode").and_return(true)
|
133
|
-
@ohai._require_plugin("linux::virtualization")
|
134
138
|
end
|
135
139
|
|
136
140
|
it "should set virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
|
137
141
|
ms_vpc_dmidecode=<<-MSVPC
|
138
142
|
System Information
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
Manufacturer: Microsoft Corporation
|
144
|
+
Product Name: Virtual Machine
|
145
|
+
Version: VS2005R2
|
146
|
+
Serial Number: 1688-7189-5337-7903-2297-1012-52
|
147
|
+
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
148
|
+
Wake-up Type: Power Switch
|
145
149
|
MSVPC
|
146
|
-
@
|
147
|
-
|
148
|
-
@
|
149
|
-
@
|
150
|
-
@ohai[:virtualization][:system].should == "virtualpc"
|
151
|
-
@ohai[:virtualization][:role].should == "guest"
|
150
|
+
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
|
151
|
+
@plugin.run
|
152
|
+
@plugin[:virtualization][:system].should == "virtualpc"
|
153
|
+
@plugin[:virtualization][:role].should == "guest"
|
152
154
|
end
|
153
155
|
|
154
156
|
it "should set vmware guest if dmidecode detects VMware Virtual Platform" do
|
155
157
|
vmware_dmidecode=<<-VMWARE
|
156
158
|
System Information
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
159
|
+
Manufacturer: VMware, Inc.
|
160
|
+
Product Name: VMware Virtual Platform
|
161
|
+
Version: None
|
162
|
+
Serial Number: VMware-50 3f f7 14 42 d1 f1 da-3b 46 27 d0 29 b4 74 1d
|
163
|
+
UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
|
164
|
+
Wake-up Type: Power Switch
|
165
|
+
SKU Number: Not Specified
|
166
|
+
Family: Not Specified
|
165
167
|
VMWARE
|
166
|
-
@
|
167
|
-
@
|
168
|
-
@
|
169
|
-
@
|
170
|
-
|
168
|
+
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
|
169
|
+
@plugin.run
|
170
|
+
@plugin[:virtualization][:system].should == "vmware"
|
171
|
+
@plugin[:virtualization][:role].should == "guest"
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should set vbox guest if dmidecode detects Oracle Corporation" do
|
175
|
+
vbox_dmidecode=<<-VBOX
|
176
|
+
Base Board Information
|
177
|
+
Manufacturer: Oracle Corporation
|
178
|
+
Product Name: VirtualBox
|
179
|
+
Version: 1.2
|
180
|
+
Serial Number: 0
|
181
|
+
Asset Tag: Not Specified
|
182
|
+
Features:
|
183
|
+
Board is a hosting board
|
184
|
+
Location In Chasis: Not Specified
|
185
|
+
Type: Motherboard
|
186
|
+
Contained Object Handles: 0
|
187
|
+
VBOX
|
188
|
+
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
|
189
|
+
@plugin.run
|
190
|
+
@plugin[:virtualization][:system].should == "vbox"
|
191
|
+
@plugin[:virtualization][:role].should == "guest"
|
171
192
|
end
|
172
193
|
|
173
194
|
it "should run dmidecode and not set virtualization if nothing is detected" do
|
174
|
-
@
|
175
|
-
@
|
176
|
-
@
|
195
|
+
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
|
196
|
+
@plugin.run
|
197
|
+
@plugin[:virtualization].should == {}
|
177
198
|
end
|
178
199
|
end
|
179
200
|
|
180
201
|
describe "when we are checking for Linux-VServer" do
|
181
202
|
it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do
|
182
203
|
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
183
|
-
File.stub
|
184
|
-
@
|
185
|
-
@
|
186
|
-
@
|
204
|
+
File.stub(:read).with("/proc/self/status").and_return("s_context: 0")
|
205
|
+
@plugin.run
|
206
|
+
@plugin[:virtualization][:system].should == "linux-vserver"
|
207
|
+
@plugin[:virtualization][:role].should == "host"
|
187
208
|
end
|
188
209
|
|
189
210
|
it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
|
190
211
|
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
191
|
-
File.stub
|
192
|
-
@
|
193
|
-
@
|
194
|
-
@
|
212
|
+
File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
|
213
|
+
@plugin.run
|
214
|
+
@plugin[:virtualization][:system].should == "linux-vserver"
|
215
|
+
@plugin[:virtualization][:role].should == "host"
|
195
216
|
end
|
196
217
|
|
197
218
|
it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
|
198
219
|
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
199
|
-
File.stub
|
200
|
-
@
|
201
|
-
@
|
202
|
-
@
|
220
|
+
File.stub(:read).with("/proc/self/status").and_return("s_context: 2")
|
221
|
+
@plugin.run
|
222
|
+
@plugin[:virtualization][:system].should == "linux-vserver"
|
223
|
+
@plugin[:virtualization][:role].should == "guest"
|
203
224
|
end
|
204
225
|
|
205
226
|
it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
|
206
227
|
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
207
|
-
File.stub
|
208
|
-
@
|
209
|
-
@
|
210
|
-
@
|
228
|
+
File.stub(:read).with("/proc/self/status").and_return("VxID: 2")
|
229
|
+
@plugin.run
|
230
|
+
@plugin[:virtualization][:system].should == "linux-vserver"
|
231
|
+
@plugin[:virtualization][:role].should == "guest"
|
211
232
|
end
|
212
233
|
|
213
234
|
it "should not set virtualization if Linux-VServer isn't there" do
|
214
235
|
File.should_receive(:exists?).at_least(:once).and_return(false)
|
215
|
-
@
|
216
|
-
@
|
236
|
+
@plugin.run
|
237
|
+
@plugin[:virtualization].should == {}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "when we are checking for openvz" do
|
242
|
+
it "should set openvz host if /proc/bc/0 exists" do
|
243
|
+
File.should_receive(:exists?).with("/proc/bc/0").and_return(true)
|
244
|
+
@plugin.run
|
245
|
+
@plugin[:virtualization][:system].should == "openvz"
|
246
|
+
@plugin[:virtualization][:role].should == "host"
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
|
250
|
+
File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
|
251
|
+
File.should_receive(:exists?).with("/proc/vz").and_return(true)
|
252
|
+
@plugin.run
|
253
|
+
@plugin[:virtualization][:system].should == "openvz"
|
254
|
+
@plugin[:virtualization][:role].should == "guest"
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should not set virtualization if openvz isn't there" do
|
258
|
+
File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
|
259
|
+
File.should_receive(:exists?).with("/proc/vz").and_return(false)
|
260
|
+
@plugin.run
|
261
|
+
@plugin[:virtualization].should == {}
|
217
262
|
end
|
218
263
|
end
|
219
|
-
describe "when we are checking for openvz" do
|
220
|
-
it "should set openvz host if /proc/bc/0 exists" do
|
221
|
-
File.should_receive(:exists?).with("/proc/bc/0").and_return(true)
|
222
|
-
@ohai._require_plugin("linux::virtualization")
|
223
|
-
@ohai[:virtualization][:system].should == "openvz"
|
224
|
-
@ohai[:virtualization][:role].should == "host"
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
|
228
|
-
File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
|
229
|
-
File.should_receive(:exists?).with("/proc/vz").and_return(true)
|
230
|
-
@ohai._require_plugin("linux::virtualization")
|
231
|
-
@ohai[:virtualization][:system].should == "openvz"
|
232
|
-
@ohai[:virtualization][:role].should == "guest"
|
233
|
-
end
|
234
|
-
|
235
|
-
it "should not set virtualization if openvz isn't there" do
|
236
|
-
File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
|
237
|
-
File.should_receive(:exists?).with("/proc/vz").and_return(false)
|
238
|
-
@ohai._require_plugin("linux::virtualization")
|
239
|
-
@ohai[:virtualization].should == {}
|
240
|
-
end
|
241
|
-
end
|
242
264
|
|
243
265
|
it "should not set virtualization if no tests match" do
|
244
|
-
@
|
245
|
-
@
|
266
|
+
@plugin.run
|
267
|
+
@plugin[:virtualization].should == {}
|
246
268
|
end
|
247
269
|
end
|
248
|
-
|
249
|
-
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
|
+
# Author:: Theodore Nordsieck (<theo@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2009 VMware, Inc.
|
5
|
+
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
6
|
# License:: Apache License, Version 2.0
|
5
7
|
#
|
6
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -22,32 +24,27 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
|
|
22
24
|
describe Ohai::System, "plugin lua" do
|
23
25
|
|
24
26
|
before(:each) do
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
28
|
-
@status = 0
|
29
|
-
@stdout = ""
|
27
|
+
@plugin = get_plugin("lua")
|
28
|
+
@plugin[:languages] = Mash.new
|
30
29
|
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
|
31
|
-
@
|
30
|
+
@plugin.stub(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should get the lua version from running lua -v" do
|
35
|
-
@
|
36
|
-
@
|
34
|
+
@plugin.should_receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
|
35
|
+
@plugin.run
|
37
36
|
end
|
38
37
|
|
39
38
|
it "should set languages[:lua][:version]" do
|
40
|
-
@
|
41
|
-
@
|
39
|
+
@plugin.run
|
40
|
+
@plugin.languages[:lua][:version].should eql("5.1.2")
|
42
41
|
end
|
43
42
|
|
44
43
|
it "should not set the languages[:lua] tree up if lua command fails" do
|
45
|
-
@status = 1
|
46
|
-
@stdout = ""
|
47
44
|
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
45
|
+
@plugin.stub(:shell_out).with("lua -v").and_return(mock_shell_out(1, "", @stderr))
|
46
|
+
@plugin.run
|
47
|
+
@plugin.languages.should_not have_key(:lua)
|
51
48
|
end
|
52
49
|
|
53
50
|
end
|