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
@@ -22,264 +22,249 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
|
23
23
|
describe Ohai::System, "Linux plugin platform" do
|
24
24
|
before(:each) do
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
File.stub
|
31
|
-
File.stub
|
32
|
-
File.stub
|
33
|
-
File.stub
|
34
|
-
File.stub
|
35
|
-
File.stub
|
36
|
-
File.stub
|
37
|
-
File.stub
|
38
|
-
File.stub!(:exists?).with("/etc/oracle-release").and_return(false)
|
39
|
-
File.stub!(:exists?).with("/usr/bin/raspi-config").and_return(false)
|
25
|
+
@plugin = get_plugin("linux/platform")
|
26
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
27
|
+
@plugin[:lsb] = Mash.new
|
28
|
+
File.stub(:exists?).with("/etc/debian_version").and_return(false)
|
29
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(false)
|
30
|
+
File.stub(:exists?).with("/etc/gentoo-release").and_return(false)
|
31
|
+
File.stub(:exists?).with("/etc/SuSE-release").and_return(false)
|
32
|
+
File.stub(:exists?).with("/etc/arch-release").and_return(false)
|
33
|
+
File.stub(:exists?).with("/etc/system-release").and_return(false)
|
34
|
+
File.stub(:exists?).with("/etc/slackware-version").and_return(false)
|
35
|
+
File.stub(:exists?).with("/etc/enterprise-release").and_return(false)
|
36
|
+
File.stub(:exists?).with("/etc/oracle-release").and_return(false)
|
37
|
+
File.stub(:exists?).with("/usr/bin/raspi-config").and_return(false)
|
40
38
|
end
|
41
|
-
|
42
|
-
it "should require the lsb plugin" do
|
43
|
-
@ohai.should_receive(:require_plugin).with("linux::lsb").and_return(true)
|
44
|
-
@ohai._require_plugin("linux::platform")
|
45
|
-
end
|
46
|
-
|
39
|
+
|
47
40
|
describe "on lsb compliant distributions" do
|
48
41
|
before(:each) do
|
49
|
-
@
|
50
|
-
@
|
42
|
+
@plugin[:lsb][:id] = "Ubuntu"
|
43
|
+
@plugin[:lsb][:release] = "8.04"
|
51
44
|
end
|
52
45
|
|
53
46
|
it "should set platform to lowercased lsb[:id]" do
|
54
|
-
@
|
55
|
-
@
|
47
|
+
@plugin.run
|
48
|
+
@plugin[:platform].should == "ubuntu"
|
56
49
|
end
|
57
50
|
|
58
51
|
it "should set platform_version to lsb[:release]" do
|
59
|
-
@
|
60
|
-
@
|
52
|
+
@plugin.run
|
53
|
+
@plugin[:platform_version].should == "8.04"
|
61
54
|
end
|
62
55
|
|
63
56
|
it "should set platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do
|
64
|
-
@
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@
|
57
|
+
@plugin[:lsb][:id] = "Ubuntu"
|
58
|
+
@plugin.run
|
59
|
+
@plugin[:platform].should == "ubuntu"
|
60
|
+
@plugin[:platform_family].should == "debian"
|
68
61
|
end
|
69
62
|
it "should set platform to linuxmint and platform_family to debian [:lsb][:id] contains LinuxMint" do
|
70
|
-
@
|
71
|
-
@
|
72
|
-
@
|
73
|
-
@
|
63
|
+
@plugin[:lsb][:id] = "LinuxMint"
|
64
|
+
@plugin.run
|
65
|
+
@plugin[:platform].should == "linuxmint"
|
66
|
+
@plugin[:platform_family].should == "debian"
|
74
67
|
end
|
75
68
|
it "should set platform to debian and platform_family to debian [:lsb][:id] contains Debian" do
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
69
|
+
@plugin[:lsb][:id] = "Debian"
|
70
|
+
@plugin.run
|
71
|
+
@plugin[:platform].should == "debian"
|
72
|
+
@plugin[:platform_family].should == "debian"
|
80
73
|
end
|
81
74
|
it "should set platform to redhat and platform_family to rhel when [:lsb][:id] contains Redhat" do
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@
|
85
|
-
@
|
86
|
-
@
|
75
|
+
@plugin[:lsb][:id] = "RedHatEnterpriseServer"
|
76
|
+
@plugin[:lsb][:release] = "5.7"
|
77
|
+
@plugin.run
|
78
|
+
@plugin[:platform].should == "redhat"
|
79
|
+
@plugin[:platform_family].should == "rhel"
|
87
80
|
end
|
88
81
|
|
89
82
|
it "should set platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
|
90
|
-
@
|
91
|
-
@
|
92
|
-
@
|
93
|
-
@
|
94
|
-
@
|
83
|
+
@plugin[:lsb][:id] = "AmazonAMI"
|
84
|
+
@plugin[:lsb][:release] = "2011.09"
|
85
|
+
@plugin.run
|
86
|
+
@plugin[:platform].should == "amazon"
|
87
|
+
@plugin[:platform_family].should == "rhel"
|
95
88
|
end
|
96
89
|
|
97
90
|
it "should set platform to scientific when [:lsb][:id] contains ScientificSL" do
|
98
|
-
@
|
99
|
-
@
|
100
|
-
@
|
101
|
-
@
|
91
|
+
@plugin[:lsb][:id] = "ScientificSL"
|
92
|
+
@plugin[:lsb][:release] = "5.7"
|
93
|
+
@plugin.run
|
94
|
+
@plugin[:platform].should == "scientific"
|
102
95
|
end
|
103
96
|
end
|
104
97
|
|
105
98
|
describe "on debian" do
|
106
99
|
before(:each) do
|
107
|
-
@
|
100
|
+
@plugin.lsb = nil
|
108
101
|
File.should_receive(:exists?).with("/etc/debian_version").and_return(true)
|
109
102
|
end
|
110
|
-
|
111
|
-
it "should check for the existance of debian_version" do
|
112
|
-
@ohai._require_plugin("linux::platform")
|
113
|
-
end
|
114
103
|
|
115
104
|
it "should read the version from /etc/debian_version" do
|
116
105
|
File.should_receive(:read).with("/etc/debian_version").and_return("5.0")
|
117
|
-
@
|
118
|
-
@
|
106
|
+
@plugin.run
|
107
|
+
@plugin[:platform_version].should == "5.0"
|
119
108
|
end
|
120
109
|
|
121
110
|
it "should correctly strip any newlines" do
|
122
111
|
File.should_receive(:read).with("/etc/debian_version").and_return("5.0\n")
|
123
|
-
@
|
124
|
-
@
|
112
|
+
@plugin.run
|
113
|
+
@plugin[:platform_version].should == "5.0"
|
125
114
|
end
|
126
115
|
|
127
116
|
# Ubuntu has /etc/debian_version as well
|
128
117
|
it "should detect Ubuntu as itself rather than debian" do
|
129
|
-
@
|
130
|
-
@
|
131
|
-
@
|
132
|
-
@
|
118
|
+
@plugin[:lsb][:id] = "Ubuntu"
|
119
|
+
@plugin[:lsb][:release] = "8.04"
|
120
|
+
@plugin.run
|
121
|
+
@plugin[:platform].should == "ubuntu"
|
133
122
|
end
|
134
123
|
|
135
124
|
# Raspbian is a debian clone
|
136
125
|
it "should detect Raspbian as itself with debian as the family" do
|
137
126
|
File.should_receive(:exists?).with("/usr/bin/raspi-config").and_return(true)
|
138
127
|
File.should_receive(:read).with("/etc/debian_version").and_return("wheezy/sid")
|
139
|
-
@
|
140
|
-
@
|
141
|
-
@
|
128
|
+
@plugin.run
|
129
|
+
@plugin[:platform].should == "raspbian"
|
130
|
+
@plugin[:platform_family].should == "debian"
|
142
131
|
end
|
143
132
|
end
|
144
133
|
|
145
134
|
describe "on slackware" do
|
146
135
|
before(:each) do
|
147
|
-
@
|
136
|
+
@plugin.lsb = nil
|
148
137
|
File.should_receive(:exists?).with("/etc/slackware-version").and_return(true)
|
149
138
|
end
|
150
139
|
|
151
140
|
it "should set platform and platform_family to slackware" do
|
152
141
|
File.should_receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
|
153
|
-
@
|
154
|
-
@
|
155
|
-
@
|
142
|
+
@plugin.run
|
143
|
+
@plugin[:platform].should == "slackware"
|
144
|
+
@plugin[:platform_family].should == "slackware"
|
156
145
|
end
|
157
146
|
end
|
158
147
|
|
159
148
|
describe "on arch" do
|
160
149
|
before(:each) do
|
161
|
-
@
|
150
|
+
@plugin.lsb = nil
|
162
151
|
File.should_receive(:exists?).with("/etc/arch-release").and_return(true)
|
163
152
|
end
|
164
153
|
|
165
154
|
it "should set platform to arch and platform_family to arch" do
|
166
|
-
@
|
167
|
-
@
|
168
|
-
@
|
155
|
+
@plugin.run
|
156
|
+
@plugin[:platform].should == "arch"
|
157
|
+
@plugin[:platform_family].should == "arch"
|
169
158
|
end
|
170
159
|
|
171
160
|
end
|
172
161
|
|
173
162
|
describe "on gentoo" do
|
174
163
|
before(:each) do
|
175
|
-
@
|
164
|
+
@plugin.lsb = nil
|
176
165
|
File.should_receive(:exists?).with("/etc/gentoo-release").and_return(true)
|
177
166
|
end
|
178
167
|
|
179
168
|
it "should set platform and platform_family to gentoo" do
|
180
169
|
File.should_receive(:read).with("/etc/gentoo-release").and_return("Gentoo Base System release 1.20.1.1")
|
181
|
-
@
|
182
|
-
@
|
183
|
-
@
|
170
|
+
@plugin.run
|
171
|
+
@plugin[:platform].should == "gentoo"
|
172
|
+
@plugin[:platform_family].should == "gentoo"
|
184
173
|
end
|
185
174
|
end
|
186
175
|
|
187
176
|
describe "on redhat breeds" do
|
188
177
|
describe "with lsb_release results" do
|
189
178
|
it "should set the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do
|
190
|
-
@
|
191
|
-
@
|
192
|
-
@
|
193
|
-
@
|
194
|
-
@
|
195
|
-
@
|
179
|
+
@plugin[:lsb][:id] = "RedHatEnterpriseServer"
|
180
|
+
@plugin[:lsb][:release] = "6.1"
|
181
|
+
@plugin.run
|
182
|
+
@plugin[:platform].should == "redhat"
|
183
|
+
@plugin[:platform_version].should == "6.1"
|
184
|
+
@plugin[:platform_family].should == "rhel"
|
196
185
|
end
|
197
186
|
|
198
187
|
it "should set the platform to centos and platform_family to rhel" do
|
199
|
-
@
|
200
|
-
@
|
201
|
-
@
|
202
|
-
@
|
203
|
-
@
|
204
|
-
@
|
188
|
+
@plugin[:lsb][:id] = "CentOS"
|
189
|
+
@plugin[:lsb][:release] = "5.4"
|
190
|
+
@plugin.run
|
191
|
+
@plugin[:platform].should == "centos"
|
192
|
+
@plugin[:platform_version].should == "5.4"
|
193
|
+
@plugin[:platform_family].should == "rhel"
|
205
194
|
|
206
195
|
end
|
207
196
|
|
208
197
|
|
209
198
|
it "should set the platform_family to rhel if the LSB name is oracle-ish" do
|
210
|
-
@
|
211
|
-
@
|
212
|
-
@
|
199
|
+
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
|
200
|
+
@plugin.run
|
201
|
+
@plugin[:platform_family].should == "rhel"
|
213
202
|
end
|
214
203
|
|
215
204
|
it "should set the platform_family to rhel if the LSB name is amazon-ish" do
|
216
|
-
@
|
217
|
-
@
|
218
|
-
@
|
205
|
+
@plugin[:lsb][:id] = "Amazon"
|
206
|
+
@plugin.run
|
207
|
+
@plugin[:platform_family].should == "rhel"
|
219
208
|
end
|
220
209
|
|
221
210
|
it "should set the platform_family to fedora if the LSB name is fedora-ish" do
|
222
|
-
@
|
223
|
-
@
|
224
|
-
@
|
211
|
+
@plugin[:lsb][:id] = "Fedora"
|
212
|
+
@plugin.run
|
213
|
+
@plugin[:platform_family].should == "fedora"
|
225
214
|
end
|
226
215
|
|
227
216
|
it "should set the platform_family to redhat if the LSB name is scientific-ish" do
|
228
|
-
@
|
229
|
-
@
|
230
|
-
@
|
217
|
+
@plugin[:lsb][:id] = "Scientific"
|
218
|
+
@plugin.run
|
219
|
+
@plugin[:platform_family].should == "rhel"
|
231
220
|
end
|
232
221
|
end
|
233
222
|
|
234
223
|
describe "without lsb_release results" do
|
235
224
|
before(:each) do
|
236
|
-
@
|
225
|
+
@plugin.lsb = nil
|
237
226
|
File.should_receive(:exists?).with("/etc/redhat-release").and_return(true)
|
238
227
|
end
|
239
228
|
|
240
|
-
it "should check for the existance of redhat-release" do
|
241
|
-
@ohai._require_plugin("linux::platform")
|
242
|
-
end
|
243
|
-
|
244
229
|
it "should read the platform as centos and version as 5.3" do
|
245
230
|
File.should_receive(:read).with("/etc/redhat-release").and_return("CentOS release 5.3")
|
246
|
-
@
|
247
|
-
@
|
231
|
+
@plugin.run
|
232
|
+
@plugin[:platform].should == "centos"
|
248
233
|
end
|
249
234
|
|
250
235
|
it "may be that someone munged Red Hat to be RedHat" do
|
251
236
|
File.should_receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
|
252
|
-
@
|
253
|
-
@
|
254
|
-
@
|
237
|
+
@plugin.run
|
238
|
+
@plugin[:platform].should == "redhat"
|
239
|
+
@plugin[:platform_version].should == "5.3"
|
255
240
|
end
|
256
241
|
|
257
242
|
it "should read the platform as redhat and version as 5.3" do
|
258
243
|
File.should_receive(:read).with("/etc/redhat-release").and_return("Red Hat release 5.3")
|
259
|
-
@
|
260
|
-
@
|
261
|
-
@
|
244
|
+
@plugin.run
|
245
|
+
@plugin[:platform].should == "redhat"
|
246
|
+
@plugin[:platform_version].should == "5.3"
|
262
247
|
end
|
263
248
|
|
264
249
|
it "should read the platform as fedora and version as 13 (rawhide)" do
|
265
250
|
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
|
266
|
-
@
|
267
|
-
@
|
268
|
-
@
|
251
|
+
@plugin.run
|
252
|
+
@plugin[:platform].should == "fedora"
|
253
|
+
@plugin[:platform_version].should == "13 (rawhide)"
|
269
254
|
end
|
270
255
|
|
271
256
|
it "should read the platform as fedora and version as 10" do
|
272
257
|
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 10")
|
273
|
-
@
|
274
|
-
@
|
275
|
-
@
|
258
|
+
@plugin.run
|
259
|
+
@plugin[:platform].should == "fedora"
|
260
|
+
@plugin[:platform_version].should == "10"
|
276
261
|
end
|
277
262
|
|
278
263
|
it "should read the platform as fedora and version as 13 using to_i" do
|
279
264
|
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
|
280
|
-
@
|
281
|
-
@
|
282
|
-
@
|
265
|
+
@plugin.run
|
266
|
+
@plugin[:platform].should == "fedora"
|
267
|
+
@plugin[:platform_version].to_i.should == 13
|
283
268
|
end
|
284
269
|
end
|
285
270
|
end
|
@@ -287,83 +272,83 @@ describe Ohai::System, "Linux plugin platform" do
|
|
287
272
|
describe "on oracle enterprise linux" do
|
288
273
|
describe "with lsb_results" do
|
289
274
|
it "should read the platform as oracle and version as 5.7" do
|
290
|
-
@
|
291
|
-
@
|
292
|
-
File.stub
|
293
|
-
File.stub
|
275
|
+
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
|
276
|
+
@plugin[:lsb][:release] = "5.7"
|
277
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
278
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
294
279
|
File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
295
280
|
File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
296
|
-
@
|
297
|
-
@
|
298
|
-
@
|
281
|
+
@plugin.run
|
282
|
+
@plugin[:platform].should == "oracle"
|
283
|
+
@plugin[:platform_version].should == "5.7"
|
299
284
|
end
|
300
285
|
|
301
286
|
it "should read the platform as oracle and version as 6.1" do
|
302
|
-
@
|
303
|
-
@
|
304
|
-
File.stub
|
305
|
-
File.stub
|
287
|
+
@plugin[:lsb][:id] = "OracleServer"
|
288
|
+
@plugin[:lsb][:release] = "6.1"
|
289
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
290
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
306
291
|
File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
|
307
292
|
File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
308
|
-
@
|
309
|
-
@
|
310
|
-
@
|
293
|
+
@plugin.run
|
294
|
+
@plugin[:platform].should == "oracle"
|
295
|
+
@plugin[:platform_version].should == "6.1"
|
311
296
|
end
|
312
297
|
end
|
313
298
|
|
314
299
|
describe "without lsb_results" do
|
315
300
|
before(:each) do
|
316
|
-
@
|
301
|
+
@plugin.lsb = nil
|
317
302
|
end
|
318
303
|
|
319
304
|
it "should read the platform as oracle and version as 5" do
|
320
|
-
File.stub
|
321
|
-
File.stub
|
305
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
306
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
322
307
|
File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
323
308
|
File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
324
|
-
@
|
325
|
-
@
|
326
|
-
@
|
309
|
+
@plugin.run
|
310
|
+
@plugin[:platform].should == "oracle"
|
311
|
+
@plugin[:platform_version].should == "5"
|
327
312
|
end
|
328
313
|
|
329
314
|
it "should read the platform as oracle and version as 5.1" do
|
330
|
-
File.stub
|
331
|
-
File.stub
|
315
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
316
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
332
317
|
File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
333
318
|
File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
334
|
-
@
|
335
|
-
@
|
336
|
-
@
|
319
|
+
@plugin.run
|
320
|
+
@plugin[:platform].should == "oracle"
|
321
|
+
@plugin[:platform_version].should == "5.1"
|
337
322
|
end
|
338
323
|
|
339
324
|
it "should read the platform as oracle and version as 5.7" do
|
340
|
-
File.stub
|
341
|
-
File.stub
|
325
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
326
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
342
327
|
File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
343
328
|
File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
344
|
-
@
|
345
|
-
@
|
346
|
-
@
|
329
|
+
@plugin.run
|
330
|
+
@plugin[:platform].should == "oracle"
|
331
|
+
@plugin[:platform_version].should == "5.7"
|
347
332
|
end
|
348
333
|
|
349
334
|
it "should read the platform as oracle and version as 6.0" do
|
350
|
-
File.stub
|
351
|
-
File.stub
|
335
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
336
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
|
352
337
|
File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
|
353
338
|
File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
|
354
|
-
@
|
355
|
-
@
|
356
|
-
@
|
339
|
+
@plugin.run
|
340
|
+
@plugin[:platform].should == "oracle"
|
341
|
+
@plugin[:platform_version].should == "6.0"
|
357
342
|
end
|
358
343
|
|
359
344
|
it "should read the platform as oracle and version as 6.1" do
|
360
|
-
File.stub
|
361
|
-
File.stub
|
345
|
+
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
|
346
|
+
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
362
347
|
File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
|
363
348
|
File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
364
|
-
@
|
365
|
-
@
|
366
|
-
@
|
349
|
+
@plugin.run
|
350
|
+
@plugin[:platform].should == "oracle"
|
351
|
+
@plugin[:platform_version].should == "6.1"
|
367
352
|
end
|
368
353
|
end
|
369
354
|
end
|
@@ -375,73 +360,69 @@ describe Ohai::System, "Linux plugin platform" do
|
|
375
360
|
|
376
361
|
describe "with lsb_release results" do
|
377
362
|
before(:each) do
|
378
|
-
@
|
363
|
+
@plugin[:lsb][:id] = "SUSE LINUX"
|
379
364
|
end
|
380
365
|
|
381
366
|
it "should read the platform as suse" do
|
382
|
-
@
|
383
|
-
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
|
384
|
-
@
|
385
|
-
@
|
386
|
-
@
|
387
|
-
@
|
367
|
+
@plugin[:lsb][:release] = "12.1"
|
368
|
+
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
|
369
|
+
@plugin.run
|
370
|
+
@plugin[:platform].should == "suse"
|
371
|
+
@plugin[:platform_version].should == "12.1"
|
372
|
+
@plugin[:platform_family].should == "suse"
|
388
373
|
end
|
389
374
|
end
|
390
375
|
|
391
376
|
describe "without lsb_release results" do
|
392
377
|
before(:each) do
|
393
|
-
@
|
394
|
-
end
|
395
|
-
|
396
|
-
it "should check for the existance of SuSE-release" do
|
397
|
-
@ohai._require_plugin("linux::platform")
|
378
|
+
@plugin.lsb = nil
|
398
379
|
end
|
399
380
|
|
400
381
|
it "should set platform and platform_family to suse and bogus verion to 10.0" do
|
401
382
|
File.should_receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
|
402
|
-
@
|
403
|
-
@
|
404
|
-
@
|
383
|
+
@plugin.run
|
384
|
+
@plugin[:platform].should == "suse"
|
385
|
+
@plugin[:platform_family].should == "suse"
|
405
386
|
end
|
406
387
|
|
407
388
|
it "should read the version as 10.1 for bogus SLES 10" do
|
408
389
|
File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 10 (i586)\nVERSION = 10\nPATCHLEVEL = 1\n")
|
409
|
-
@
|
410
|
-
@
|
411
|
-
@
|
412
|
-
@
|
390
|
+
@plugin.run
|
391
|
+
@plugin[:platform].should == "suse"
|
392
|
+
@plugin[:platform_version].should == "10.1"
|
393
|
+
@plugin[:platform_family].should == "suse"
|
413
394
|
end
|
414
395
|
|
415
396
|
it "should read the version as 11.2" do
|
416
397
|
File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
|
417
|
-
@
|
418
|
-
@
|
419
|
-
@
|
420
|
-
@
|
398
|
+
@plugin.run
|
399
|
+
@plugin[:platform].should == "suse"
|
400
|
+
@plugin[:platform_version].should == "11.2"
|
401
|
+
@plugin[:platform_family].should == "suse"
|
421
402
|
end
|
422
403
|
|
423
404
|
it "[OHAI-272] should read the version as 11.3" do
|
424
|
-
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
|
425
|
-
@
|
426
|
-
@
|
427
|
-
@
|
428
|
-
@
|
405
|
+
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
|
406
|
+
@plugin.run
|
407
|
+
@plugin[:platform].should == "suse"
|
408
|
+
@plugin[:platform_version].should == "11.3"
|
409
|
+
@plugin[:platform_family].should == "suse"
|
429
410
|
end
|
430
411
|
|
431
412
|
it "[OHAI-272] should read the version as 9.1" do
|
432
|
-
File.should_receive(:read).with("/etc/SuSE-release").and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
|
433
|
-
@
|
434
|
-
@
|
435
|
-
@
|
436
|
-
@
|
413
|
+
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
|
414
|
+
@plugin.run
|
415
|
+
@plugin[:platform].should == "suse"
|
416
|
+
@plugin[:platform_version].should == "9.1"
|
417
|
+
@plugin[:platform_family].should == "suse"
|
437
418
|
end
|
438
419
|
|
439
420
|
it "[OHAI-272] should read the version as 11.4" do
|
440
|
-
File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
|
441
|
-
@
|
442
|
-
@
|
443
|
-
@
|
444
|
-
@
|
421
|
+
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
|
422
|
+
@plugin.run
|
423
|
+
@plugin[:platform].should == "suse"
|
424
|
+
@plugin[:platform_version].should == "11.4"
|
425
|
+
@plugin[:platform_family].should == "suse"
|
445
426
|
end
|
446
427
|
end
|
447
428
|
end
|