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
@@ -20,16 +20,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
describe Ohai::System, "Solaris plugin platform" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@ohai[:os] = "solaris2"
|
27
|
-
@ohai.stub!(:popen4).with("/sbin/uname -X")
|
23
|
+
@plugin = get_plugin("solaris2/platform")
|
24
|
+
@plugin.stub(:collect_os).and_return(:solaris2)
|
25
|
+
@plugin.stub(:shell_out).with("/sbin/uname -X")
|
28
26
|
end
|
29
27
|
|
30
28
|
describe "on SmartOS" do
|
31
29
|
before(:each) do
|
32
|
-
uname_x = <<-UNAME_X
|
30
|
+
@uname_x = <<-UNAME_X
|
33
31
|
System = SunOS
|
34
32
|
Node = node.example.com
|
35
33
|
Release = 5.11
|
@@ -42,34 +40,27 @@ OEM# = 0
|
|
42
40
|
Origin# = 1
|
43
41
|
NumCPU = 16
|
44
42
|
UNAME_X
|
45
|
-
@stdin = mock("STDIN", { :close => true })
|
46
|
-
@pid = 10
|
47
|
-
@stderr = mock("STDERR")
|
48
|
-
@status = 0
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
File.stub!(:exists?).with("/sbin/uname").and_return(true)
|
53
|
-
@ohai.stub(:popen4).with("/sbin/uname -X").and_yield(@pid, @stdin, @uname_x_lines, @stderr).and_return(@status)
|
44
|
+
File.stub(:exists?).with("/sbin/uname").and_return(true)
|
45
|
+
@plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
|
54
46
|
|
55
47
|
@release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
|
56
|
-
|
57
|
-
File.stub!(:open).with("/etc/release").and_yield(@release)
|
48
|
+
File.stub(:open).with("/etc/release").and_yield(@release)
|
58
49
|
end
|
59
50
|
|
60
51
|
it "should run uname and set platform and build" do
|
61
|
-
@
|
62
|
-
@
|
52
|
+
@plugin.run
|
53
|
+
@plugin[:platform_build].should == "joyent_20120130T201844Z"
|
63
54
|
end
|
64
55
|
|
65
56
|
it "should set the platform" do
|
66
|
-
@
|
67
|
-
@
|
57
|
+
@plugin.run
|
58
|
+
@plugin[:platform].should == "smartos"
|
68
59
|
end
|
69
60
|
|
70
61
|
it "should set the platform_version" do
|
71
|
-
@
|
72
|
-
@
|
62
|
+
@plugin.run
|
63
|
+
@plugin[:platform_version].should == "5.11"
|
73
64
|
end
|
74
65
|
|
75
66
|
end
|
@@ -20,60 +20,55 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
describe Ohai::System, "Solaris virtualization platform" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
@psrinfo_pv = <<-PSRINFO_PV
|
24
|
+
The physical processor has 1 virtual processor (0)
|
25
|
+
x86 (GenuineIntel family 6 model 2 step 3 clock 2667 MHz)
|
26
|
+
Intel Pentium(r) Pro
|
27
|
+
PSRINFO_PV
|
28
|
+
|
29
|
+
@plugin = get_plugin("solaris2/virtualization")
|
30
|
+
@plugin.stub(:collect_os).and_return(:solaris2)
|
27
31
|
|
28
32
|
# default to all requested Files not existing
|
29
|
-
File.stub
|
30
|
-
File.stub
|
31
|
-
File.stub
|
33
|
+
File.stub(:exists?).with("/usr/sbin/psrinfo").and_return(false)
|
34
|
+
File.stub(:exists?).with("/usr/sbin/smbios").and_return(false)
|
35
|
+
File.stub(:exists?).with("/usr/sbin/zoneadm").and_return(false)
|
36
|
+
@plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
|
37
|
+
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
|
32
38
|
end
|
33
39
|
|
34
40
|
describe "when we are checking for kvm" do
|
35
41
|
before(:each) do
|
36
42
|
File.should_receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
|
37
|
-
@stdin = mock("STDIN", { :close => true })
|
38
|
-
@pid = 10
|
39
|
-
@stderr = mock("STDERR")
|
40
|
-
@stdout = mock("STDOUT")
|
41
|
-
@status = 0
|
42
43
|
end
|
43
44
|
|
44
45
|
it "should run psrinfo -pv" do
|
45
|
-
@
|
46
|
-
@
|
46
|
+
@plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
|
47
|
+
@plugin.run
|
47
48
|
end
|
48
49
|
|
49
50
|
it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
|
50
|
-
@
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
54
|
-
@ohai[:virtualization][:role].should == "guest"
|
51
|
+
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
|
52
|
+
@plugin.run
|
53
|
+
@plugin[:virtualization][:system].should == "kvm"
|
54
|
+
@plugin[:virtualization][:role].should == "guest"
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should not set virtualization if kvm isn't there" do
|
58
|
-
@
|
59
|
-
@
|
60
|
-
@
|
58
|
+
@plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
|
59
|
+
@plugin.run
|
60
|
+
@plugin[:virtualization].should == {}
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "when we are parsing smbios" do
|
65
65
|
before(:each) do
|
66
66
|
File.should_receive(:exists?).with("/usr/sbin/smbios").and_return(true)
|
67
|
-
@stdin = mock("STDIN", { :close => true })
|
68
|
-
@pid = 20
|
69
|
-
@stderr = mock("STDERR")
|
70
|
-
@stdout = mock("STDOUT")
|
71
|
-
@status = 0
|
72
67
|
end
|
73
68
|
|
74
69
|
it "should run smbios" do
|
75
|
-
@
|
76
|
-
@
|
70
|
+
@plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
|
71
|
+
@plugin.run
|
77
72
|
end
|
78
73
|
|
79
74
|
it "should set virtualpc guest if smbios detects Microsoft Virtual Machine" do
|
@@ -89,12 +84,10 @@ ID SIZE TYPE
|
|
89
84
|
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
90
85
|
Wake-Up Event: 0x6 (power switch)
|
91
86
|
MSVPC
|
92
|
-
@
|
93
|
-
|
94
|
-
@
|
95
|
-
@
|
96
|
-
@ohai[:virtualization][:system].should == "virtualpc"
|
97
|
-
@ohai[:virtualization][:role].should == "guest"
|
87
|
+
@plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
|
88
|
+
@plugin.run
|
89
|
+
@plugin[:virtualization][:system].should == "virtualpc"
|
90
|
+
@plugin[:virtualization][:role].should == "guest"
|
98
91
|
end
|
99
92
|
|
100
93
|
it "should set vmware guest if smbios detects VMware Virtual Platform" do
|
@@ -110,23 +103,22 @@ ID SIZE TYPE
|
|
110
103
|
UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
|
111
104
|
Wake-Up Event: 0x6 (power switch)
|
112
105
|
VMWARE
|
113
|
-
@
|
114
|
-
@
|
115
|
-
@
|
116
|
-
@
|
117
|
-
@ohai[:virtualization][:role].should == "guest"
|
106
|
+
@plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
|
107
|
+
@plugin.run
|
108
|
+
@plugin[:virtualization][:system].should == "vmware"
|
109
|
+
@plugin[:virtualization][:role].should == "guest"
|
118
110
|
end
|
119
111
|
|
120
112
|
it "should run smbios and not set virtualization if nothing is detected" do
|
121
|
-
@
|
122
|
-
@
|
123
|
-
@
|
113
|
+
@plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
|
114
|
+
@plugin.run
|
115
|
+
@plugin[:virtualization].should == {}
|
124
116
|
end
|
125
117
|
end
|
126
118
|
|
127
119
|
it "should not set virtualization if no tests match" do
|
128
|
-
@
|
129
|
-
@
|
120
|
+
@plugin.run
|
121
|
+
@plugin[:virtualization].should == {}
|
130
122
|
end
|
131
123
|
end
|
132
124
|
|
@@ -21,12 +21,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
|
|
21
21
|
describe Ohai::System, "ssh_host_key plugin" do
|
22
22
|
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@ohai.stub(:require_plugin).and_return(true)
|
27
|
-
|
28
|
-
# Avoid using the real from_file to load the plugin => less stubbing required
|
29
|
-
@ohai.extend(SimpleFromFile)
|
24
|
+
@plugin = get_plugin("ssh_host_key")
|
25
|
+
@plugin[:keys] = Mash.new
|
30
26
|
|
31
27
|
File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(true)
|
32
28
|
File.stub(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
|
@@ -50,21 +46,21 @@ describe Ohai::System, "ssh_host_key plugin" do
|
|
50
46
|
|
51
47
|
shared_examples "loads keys" do
|
52
48
|
it "reads the key and sets the dsa attribute correctly" do
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@
|
49
|
+
@plugin.run
|
50
|
+
@plugin[:keys][:ssh][:host_dsa_public].should eql(@dsa_key.split[1])
|
51
|
+
@plugin[:keys][:ssh][:host_dsa_type].should be_nil
|
56
52
|
end
|
57
53
|
|
58
54
|
it "reads the key and sets the rsa attribute correctly" do
|
59
|
-
@
|
60
|
-
@
|
61
|
-
@
|
55
|
+
@plugin.run
|
56
|
+
@plugin[:keys][:ssh][:host_rsa_public].should eql(@rsa_key.split[1])
|
57
|
+
@plugin[:keys][:ssh][:host_rsa_type].should be_nil
|
62
58
|
end
|
63
59
|
|
64
60
|
it "reads the key and sets the ecdsa attribute correctly" do
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@
|
61
|
+
@plugin.run
|
62
|
+
@plugin[:keys][:ssh][:host_ecdsa_public].should eql(@ecdsa_key.split[1])
|
63
|
+
@plugin[:keys][:ssh][:host_ecdsa_type].should eql(@ecdsa_key.split[0])
|
68
64
|
end
|
69
65
|
end
|
70
66
|
|
@@ -0,0 +1,208 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
7
|
+
# may not use this file except in compliance with the License. You may
|
8
|
+
# 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 expressed or
|
15
|
+
# implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License
|
18
|
+
#
|
19
|
+
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
21
|
+
|
22
|
+
describe Ohai::ProvidesMap do
|
23
|
+
|
24
|
+
let(:ohai_system) { Ohai::System.new }
|
25
|
+
let(:provides_map) { Ohai::ProvidesMap.new }
|
26
|
+
let(:plugin_1) { Ohai::DSL::Plugin.new(ohai_system.data) }
|
27
|
+
let(:plugin_2) { Ohai::DSL::Plugin.new(ohai_system.data) }
|
28
|
+
let(:plugin_3) { Ohai::DSL::Plugin.new(ohai_system.data) }
|
29
|
+
let(:plugin_4) { Ohai::DSL::Plugin.new(ohai_system.data) }
|
30
|
+
|
31
|
+
describe "when looking up providing plugins for a single attribute" do
|
32
|
+
describe "when the attribute does not exist" do
|
33
|
+
it "should raise Ohai::Exceptions::AttributeNotFound error" do
|
34
|
+
expect{ provides_map.find_providers_for(["single"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'single'")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when the attribute does not have a provider" do
|
39
|
+
it "should raise Ohai::Exceptions::ProviderNotFound error" do
|
40
|
+
provides_map.set_providers_for(plugin_1, ["first/second"])
|
41
|
+
expect{ provides_map.find_providers_for(["first"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'first'")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when only one plugin provides the attribute" do
|
46
|
+
before do
|
47
|
+
provides_map.set_providers_for(plugin_1, ["single"])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return the provider" do
|
51
|
+
expect(provides_map.find_providers_for(["single"])).to eq([plugin_1])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "when multiple plugins provide the attribute" do
|
56
|
+
before do
|
57
|
+
provides_map.set_providers_for(plugin_1, ["single"])
|
58
|
+
provides_map.set_providers_for(plugin_2, ["single"])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return all providers" do
|
62
|
+
expect(provides_map.find_providers_for(["single"])).to eq([plugin_1, plugin_2])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "when looking up providing plugins for multiple attributes" do
|
68
|
+
describe "when a different plugin provides each attribute" do
|
69
|
+
|
70
|
+
before do
|
71
|
+
provides_map.set_providers_for(plugin_1, ["one"])
|
72
|
+
provides_map.set_providers_for(plugin_2, ["two"])
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should return each provider" do
|
76
|
+
expect(provides_map.find_providers_for(["one", "two"])).to eq([plugin_1, plugin_2])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "when one plugin provides both requested attributes" do
|
81
|
+
|
82
|
+
before do
|
83
|
+
provides_map.set_providers_for(plugin_1, ["one"])
|
84
|
+
provides_map.set_providers_for(plugin_1, ["one_again"])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return unique providers" do
|
88
|
+
expect(provides_map.find_providers_for(["one", "one_again"])).to eq([plugin_1])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "when looking up providers for multi-level attributes" do
|
94
|
+
describe "when the full attribute exists in the map" do
|
95
|
+
before do
|
96
|
+
provides_map.set_providers_for(plugin_1, ["top/middle/bottom"])
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should collect the provider" do
|
100
|
+
expect(provides_map.find_providers_for(["top/middle/bottom"])).to eq([plugin_1])
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "when setting multi-level attributes" do
|
106
|
+
describe "when the attribute contains //" do
|
107
|
+
it "should raise an Ohai::Exceptions::AttributeSyntaxError" do
|
108
|
+
expect{ provides_map.set_providers_for(plugin_1, ["this/plugin//is/bad"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: this/plugin//is/bad")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "when the attribute has a trailing slash" do
|
113
|
+
it "should raise an Ohai::Exceptions::AttributeSyntaxError" do
|
114
|
+
expect{ provides_map.set_providers_for(plugin_1, ["this/plugin/is/bad/"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': this/plugin/is/bad/")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "when looking for providers of attributes specified in CLI" do
|
120
|
+
before do
|
121
|
+
provides_map.set_providers_for(plugin_1, ["cat/whiskers"])
|
122
|
+
provides_map.set_providers_for(plugin_2, ["cat/paws", "cat/paws/toes"])
|
123
|
+
provides_map.set_providers_for(plugin_3, ["cat/mouth/teeth"])
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should find providers for subattributes if any exists when the attribute doesn't have a provider" do
|
127
|
+
providers = provides_map.deep_find_providers_for(["cat"])
|
128
|
+
expect(providers).to have(3).plugins
|
129
|
+
expect(providers).to include(plugin_1)
|
130
|
+
expect(providers).to include(plugin_2)
|
131
|
+
expect(providers).to include(plugin_3)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should find providers for the first parent attribute when the attribute or any subattributes doesn't have a provider" do
|
135
|
+
providers = provides_map.deep_find_providers_for(["cat/paws/front"])
|
136
|
+
expect(providers).to eq([plugin_2])
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "when looking for the closest providers" do
|
141
|
+
describe "and the full attribute is provided" do
|
142
|
+
before do
|
143
|
+
provides_map.set_providers_for(plugin_1, ["do/not/eat/metal"])
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should return the provider of the full attribute" do
|
147
|
+
expect(provides_map.find_closest_providers_for(["do/not/eat/metal"])).to eql([plugin_1])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "and the full attribute is not provided" do
|
152
|
+
before do
|
153
|
+
provides_map.set_providers_for(plugin_1, ["do/not/eat"])
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should not raise error if a parent attribute is provided" do
|
157
|
+
expect{ provides_map.find_closest_providers_for(["do/not/eat/plastic"]) }.not_to raise_error
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should return the providers of the closest parent attribute" do
|
161
|
+
provides_map.set_providers_for(plugin_2, ["do/not"]) # set a less-specific parent
|
162
|
+
expect(provides_map.find_closest_providers_for(["do/not/eat/glass"])).to eql([plugin_1])
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should raise error if the least-specific parent is not an attribute" do
|
166
|
+
expect{ provides_map.find_closest_providers_for(["please/eat/your/vegetables"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'please/eat/your/vegetables'")
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should raise error if no parent attribute has a provider" do
|
170
|
+
expect{ provides_map.find_closest_providers_for(["do/not"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'do/not'")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "when listing all plugins" do
|
176
|
+
before(:each) do
|
177
|
+
provides_map.set_providers_for(plugin_1, ["one"])
|
178
|
+
provides_map.set_providers_for(plugin_2, ["two"])
|
179
|
+
provides_map.set_providers_for(plugin_3, ["stub/three"])
|
180
|
+
provides_map.set_providers_for(plugin_4, ["foo/bar/four", "also/this/four"])
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should find all the plugins providing attributes" do
|
184
|
+
all_plugins = provides_map.all_plugins
|
185
|
+
expect(all_plugins).to have(4).plugins
|
186
|
+
expect(all_plugins).to include(plugin_1)
|
187
|
+
expect(all_plugins).to include(plugin_2)
|
188
|
+
expect(all_plugins).to include(plugin_3)
|
189
|
+
expect(all_plugins).to include(plugin_4)
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "with an attribute filter" do
|
193
|
+
it "finds plugins with a single level of attribute" do
|
194
|
+
expect(provides_map.all_plugins("one")).to eq([plugin_1])
|
195
|
+
end
|
196
|
+
|
197
|
+
it "finds plugins with an exact match for multiple levels of attribute" do
|
198
|
+
expect(provides_map.all_plugins("stub/three")).to eq([plugin_3])
|
199
|
+
end
|
200
|
+
|
201
|
+
it "finds plugins that provide subattributes of the requested path" do
|
202
|
+
expect(provides_map.all_plugins("stub")).to eq([plugin_3])
|
203
|
+
expect(provides_map.all_plugins("foo/bar")).to eq([plugin_4])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|