ohai 0.5.8 → 0.6.0.beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +16 -48
- data/bin/ohai +1 -1
- data/lib/ohai.rb +1 -3
- data/lib/ohai/mash.rb +211 -0
- data/lib/ohai/mixin/command.rb +157 -44
- data/lib/ohai/mixin/ec2_metadata.rb +87 -0
- data/lib/ohai/plugins/c.rb +16 -13
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +25 -0
- data/lib/ohai/plugins/darwin/network.rb +10 -1
- data/lib/ohai/plugins/dmi.rb +100 -37
- data/lib/ohai/plugins/dmi_common.rb +117 -0
- data/lib/ohai/plugins/ec2.rb +12 -61
- data/lib/ohai/plugins/eucalyptus.rb +65 -0
- data/lib/ohai/plugins/freebsd/network.rb +11 -2
- data/lib/ohai/plugins/java.rb +4 -4
- data/lib/ohai/plugins/linux/filesystem.rb +24 -0
- data/lib/ohai/plugins/linux/network.rb +14 -1
- data/lib/ohai/plugins/linux/platform.rb +3 -0
- data/lib/ohai/plugins/linux/virtualization.rb +28 -6
- data/lib/ohai/plugins/netbsd/network.rb +10 -1
- data/lib/ohai/plugins/network.rb +3 -1
- data/lib/ohai/plugins/ohai.rb +1 -0
- data/lib/ohai/plugins/openbsd/network.rb +10 -1
- data/lib/ohai/plugins/ruby.rb +1 -1
- data/lib/ohai/plugins/sigar/filesystem.rb +2 -0
- data/lib/ohai/plugins/solaris2/dmi.rb +176 -0
- data/lib/ohai/plugins/solaris2/filesystem.rb +101 -0
- data/lib/ohai/plugins/solaris2/hostname.rb +10 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -1
- data/lib/ohai/plugins/solaris2/uptime.rb +36 -0
- data/lib/ohai/plugins/solaris2/virtualization.rb +91 -0
- data/lib/ohai/plugins/virtualization.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +17 -11
- data/lib/ohai/system.rb +22 -32
- data/lib/ohai/version.rb +23 -0
- data/spec/ohai/plugins/c_spec.rb +58 -7
- data/spec/ohai/plugins/cloud_spec.rb +24 -0
- data/spec/ohai/plugins/dmi_spec.rb +107 -47
- data/spec/ohai/plugins/ec2_spec.rb +3 -3
- data/spec/ohai/plugins/eucalyptus_spec.rb +84 -0
- data/spec/ohai/plugins/java_spec.rb +55 -2
- data/spec/ohai/plugins/linux/platform_spec.rb +13 -0
- data/spec/ohai/plugins/linux/virtualization_spec.rb +47 -6
- data/spec/ohai/plugins/perl_spec.rb +15 -14
- data/spec/ohai/plugins/rackspace_spec.rb +14 -14
- data/spec/ohai/plugins/solaris2/hostname_spec.rb +3 -8
- data/spec/ohai/plugins/solaris2/kernel_spec.rb +6 -6
- data/spec/ohai/plugins/solaris2/network_spec.rb +22 -22
- data/spec/ohai/plugins/solaris2/virtualization_spec.rb +133 -0
- data/spec/spec_helper.rb +5 -13
- metadata +182 -179
data/spec/ohai/plugins/c_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
3
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
@@ -27,7 +27,7 @@ Thread model: posix
|
|
27
27
|
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
|
28
28
|
EOF
|
29
29
|
|
30
|
-
|
30
|
+
C_GLIBC_2_3_4 = <<EOF
|
31
31
|
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
|
32
32
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
33
33
|
This is free software; see the source for copying conditions.
|
@@ -50,6 +50,28 @@ For bug reporting instructions, please see:
|
|
50
50
|
<http://www.gnu.org/software/libc/bugs.html>.
|
51
51
|
EOF
|
52
52
|
|
53
|
+
C_GLIBC_2_5 = <<EOF
|
54
|
+
GNU C Library stable release version 2.5, by Roland McGrath et al.
|
55
|
+
Copyright (C) 2006 Free Software Foundation, Inc.
|
56
|
+
This is free software; see the source for copying conditions.
|
57
|
+
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
58
|
+
PARTICULAR PURPOSE.
|
59
|
+
Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-44).
|
60
|
+
Compiled on a Linux 2.6.9 system on 2009-09-02.
|
61
|
+
Available extensions:
|
62
|
+
The C stubs add-on version 2.1.2.
|
63
|
+
crypt add-on version 2.1 by Michael Glad and others
|
64
|
+
GNU Libidn by Simon Josefsson
|
65
|
+
GNU libio by Per Bothner
|
66
|
+
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
|
67
|
+
Native POSIX Threads Library by Ulrich Drepper et al
|
68
|
+
BIND-8.2.3-T5B
|
69
|
+
RT using linux kernel aio
|
70
|
+
Thread-local storage support included.
|
71
|
+
For bug reporting instructions, please see:
|
72
|
+
<http://www.gnu.org/software/libc/bugs.html>.
|
73
|
+
EOF
|
74
|
+
|
53
75
|
C_CL = <<EOF
|
54
76
|
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
|
55
77
|
Copyright (C) Microsoft Corporation. All rights reserved.
|
@@ -87,7 +109,7 @@ describe Ohai::System, "plugin c" do
|
|
87
109
|
#gcc
|
88
110
|
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"gcc -v"}).and_return([0, "", C_GCC])
|
89
111
|
#glibc
|
90
|
-
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0,
|
112
|
+
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_3_4, ""])
|
91
113
|
#ms cl
|
92
114
|
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([0, "", C_CL])
|
93
115
|
#ms vs
|
@@ -123,8 +145,8 @@ describe Ohai::System, "plugin c" do
|
|
123
145
|
end
|
124
146
|
|
125
147
|
#glibc
|
126
|
-
it "should get the glibc version from running
|
127
|
-
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0,
|
148
|
+
it "should get the glibc x.x.x version from running /lib/libc.so.6" do
|
149
|
+
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_3_4, ""])
|
128
150
|
@ohai._require_plugin("c")
|
129
151
|
end
|
130
152
|
|
@@ -135,7 +157,7 @@ describe Ohai::System, "plugin c" do
|
|
135
157
|
|
136
158
|
it "should set languages[:c][:glibc][:description]" do
|
137
159
|
@ohai._require_plugin("c")
|
138
|
-
@ohai.languages[:c][:glibc][:description].should eql(
|
160
|
+
@ohai.languages[:c][:glibc][:description].should eql(C_GLIBC_2_3_4.split($/).first)
|
139
161
|
end
|
140
162
|
|
141
163
|
it "should not set the languages[:c][:glibc] tree up if glibc command fails" do
|
@@ -144,6 +166,13 @@ describe Ohai::System, "plugin c" do
|
|
144
166
|
@ohai[:languages][:c].should_not have_key(:glibc) if @ohai[:languages][:c]
|
145
167
|
end
|
146
168
|
|
169
|
+
it "should get the glibc x.x version from running /lib/libc.so.6" do
|
170
|
+
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_5, ""])
|
171
|
+
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_5, ""])
|
172
|
+
@ohai._require_plugin("c")
|
173
|
+
@ohai.languages[:c][:glibc][:version].should eql("2.5")
|
174
|
+
end
|
175
|
+
|
147
176
|
#ms cl
|
148
177
|
it "should get the cl version from running cl /?" do
|
149
178
|
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([0, "", C_CL])
|
@@ -196,7 +225,7 @@ describe Ohai::System, "plugin c" do
|
|
196
225
|
|
197
226
|
it "should set languages[:c][:xlc][:version]" do
|
198
227
|
@ohai._require_plugin("c")
|
199
|
-
@ohai.languages[:c][:xlc][:version].should eql("
|
228
|
+
@ohai.languages[:c][:xlc][:version].should eql("9.0")
|
200
229
|
end
|
201
230
|
|
202
231
|
it "should set languages[:c][:xlc][:description]" do
|
@@ -210,6 +239,12 @@ describe Ohai::System, "plugin c" do
|
|
210
239
|
@ohai[:languages][:c].should_not have_key(:xlc) if @ohai[:languages][:c]
|
211
240
|
end
|
212
241
|
|
242
|
+
it "should set the languages[:c][:xlc] tree up if xlc exit status is 249" do
|
243
|
+
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([63744, "", ""])
|
244
|
+
@ohai._require_plugin("c")
|
245
|
+
@ohai[:languages][:c].should_not have_key(:xlc) if @ohai[:languages][:c]
|
246
|
+
end
|
247
|
+
|
213
248
|
#sun pro
|
214
249
|
it "should get the cc version from running cc -V -flags" do
|
215
250
|
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", C_SUN])
|
@@ -232,6 +267,22 @@ describe Ohai::System, "plugin c" do
|
|
232
267
|
@ohai[:languages][:c].should_not have_key(:sunpro) if @ohai[:languages][:c]
|
233
268
|
end
|
234
269
|
|
270
|
+
|
271
|
+
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
|
272
|
+
fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory"
|
273
|
+
|
274
|
+
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", fedora_error_message])
|
275
|
+
@ohai._require_plugin("c")
|
276
|
+
@ohai[:languages][:c].should_not have_key(:sunpro) if @ohai[:languages][:c]
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do
|
280
|
+
hpux_error_message = "cc: warning 901: unknown option: `-flags': use +help for online documentation.\ncc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]"
|
281
|
+
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", hpux_error_message])
|
282
|
+
@ohai._require_plugin("c")
|
283
|
+
@ohai[:languages][:c].should_not have_key(:sunpro) if @ohai[:languages][:c]
|
284
|
+
end
|
285
|
+
|
235
286
|
#hpux cc
|
236
287
|
it "should get the cc version from running what cc" do
|
237
288
|
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"what /opt/ansic/bin/cc"}).and_return([0, C_HPUX, ""])
|
@@ -29,6 +29,7 @@ describe Ohai::System, "plugin cloud" do
|
|
29
29
|
it "should NOT populate the cloud data" do
|
30
30
|
@ohai[:ec2] = nil
|
31
31
|
@ohai[:rackspace] = nil
|
32
|
+
@ohai[:eucalyptus] = nil
|
32
33
|
@ohai._require_plugin("cloud")
|
33
34
|
@ohai[:cloud].should be_nil
|
34
35
|
end
|
@@ -86,4 +87,27 @@ describe Ohai::System, "plugin cloud" do
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
90
|
+
describe "with eucalyptus" do
|
91
|
+
before(:each) do
|
92
|
+
@ohai[:eucalyptus] = Mash.new()
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should populate cloud public ip" do
|
96
|
+
@ohai[:eucalyptus]['public_ipv4'] = "174.129.150.8"
|
97
|
+
@ohai._require_plugin("cloud")
|
98
|
+
@ohai[:cloud][:public_ips][0].should == @ohai[:eucalyptus]['public_ipv4']
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should populate cloud private ip" do
|
102
|
+
@ohai[:eucalyptus]['local_ipv4'] = "10.252.42.149"
|
103
|
+
@ohai._require_plugin("cloud")
|
104
|
+
@ohai[:cloud][:private_ips][0].should == @ohai[:eucalyptus]['local_ipv4']
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should populate cloud provider" do
|
108
|
+
@ohai._require_plugin("cloud")
|
109
|
+
@ohai[:cloud][:provider].should == "eucalyptus"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
89
113
|
end
|
@@ -16,58 +16,118 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
21
20
|
|
21
|
+
# NOTE: These data lines must be prefixed with one or two tabs, not spaces.
|
22
|
+
DMI_OUT = <<-EOS
|
23
|
+
# dmidecode 2.9
|
24
|
+
SMBIOS 2.4 present.
|
25
|
+
98 structures occupying 3699 bytes.
|
26
|
+
Table at 0x000E0010.
|
27
|
+
|
28
|
+
Handle 0x0000, DMI type 0, 24 bytes
|
29
|
+
BIOS Information
|
30
|
+
Vendor: Phoenix Technologies LTD
|
31
|
+
Version: 6.00
|
32
|
+
Release Date: 12/31/2009
|
33
|
+
Address: 0xEA2E0
|
34
|
+
Runtime Size: 89376 bytes
|
35
|
+
ROM Size: 64 kB
|
36
|
+
Characteristics:
|
37
|
+
ISA is supported
|
38
|
+
PCI is supported
|
39
|
+
PC Card (PCMCIA) is supported
|
40
|
+
PNP is supported
|
41
|
+
APM is supported
|
42
|
+
BIOS is upgradeable
|
43
|
+
BIOS shadowing is allowed
|
44
|
+
ESCD support is available
|
45
|
+
USB legacy is supported
|
46
|
+
Smart battery is supported
|
47
|
+
BIOS boot specification is supported
|
48
|
+
Targeted content distribution is supported
|
49
|
+
BIOS Revision: 4.6
|
50
|
+
Firmware Revision: 0.0
|
51
|
+
|
52
|
+
Handle 0x0001, DMI type 1, 27 bytes
|
53
|
+
System Information
|
54
|
+
Manufacturer: VMware, Inc.
|
55
|
+
Product Name: VMware Virtual Platform
|
56
|
+
Version: None
|
57
|
+
Serial Number: VMware-56 4d 71 d1 65 70 83 a8-df c8 14 12 19 41 71 45
|
58
|
+
UUID: 564D71D1-6570-83A8-DFC8-141219417145
|
59
|
+
Wake-up Type: Power Switch
|
60
|
+
SKU Number: Not Specified
|
61
|
+
Family: Not Specified
|
62
|
+
|
63
|
+
Handle 0x0002, DMI type 2, 15 bytes
|
64
|
+
Base Board Information
|
65
|
+
Manufacturer: Intel Corporation
|
66
|
+
Product Name: 440BX Desktop Reference Platform
|
67
|
+
Version: None
|
68
|
+
Serial Number: None
|
69
|
+
Asset Tag: Not Specified
|
70
|
+
Features: None
|
71
|
+
Location In Chassis: Not Specified
|
72
|
+
Chassis Handle: 0x0000
|
73
|
+
Type: Unknown
|
74
|
+
Contained Object Handles: 0
|
75
|
+
|
76
|
+
Handle 0x0003, DMI type 3, 21 bytes
|
77
|
+
Chassis Information
|
78
|
+
Manufacturer: No Enclosure
|
79
|
+
Type: Other
|
80
|
+
Lock: Not Present
|
81
|
+
Version: N/A
|
82
|
+
Serial Number: None
|
83
|
+
Asset Tag: No Asset Tag
|
84
|
+
Boot-up State: Safe
|
85
|
+
Power Supply State: Safe
|
86
|
+
Thermal State: Safe
|
87
|
+
Security Status: None
|
88
|
+
OEM Information: 0x00001234
|
89
|
+
Height: Unspecified
|
90
|
+
Number Of Power Cords: Unspecified
|
91
|
+
Contained Elements: 0
|
92
|
+
EOS
|
93
|
+
|
22
94
|
describe Ohai::System, "plugin dmi" do
|
23
95
|
before(:each) do
|
24
96
|
@ohai = Ohai::System.new
|
25
|
-
@ohai.stub!(:
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@ohai.stub!(:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@ohai.
|
36
|
-
@ohai.
|
37
|
-
@ohai.stub!(:from).with("dmidecode -s baseboard-serial-number").and_return("..CN137406CP0289.")
|
38
|
-
@ohai.stub!(:from).with("dmidecode -s baseboard-asset-tag").and_return("None")
|
39
|
-
@ohai.stub!(:from).with("dmidecode -s chassis-manufacturer").and_return("Dell Inc.")
|
40
|
-
@ohai.stub!(:from).with("dmidecode -s chassis-type").and_return("Mini Tower")
|
41
|
-
@ohai.stub!(:from).with("dmidecode -s chassis-version").and_return("Not Specified")
|
42
|
-
@ohai.stub!(:from).with("dmidecode -s chassis-serial-number").and_return("XXXXXXX")
|
43
|
-
@ohai.stub!(:from).with("dmidecode -s chassis-asset-tag").and_return("None")
|
44
|
-
@ohai.stub!(:from).with("dmidecode -s processor-family").and_return("Not Specified")
|
45
|
-
@ohai.stub!(:from).with("dmidecode -s processor-manufacturer").and_return("Intel")
|
46
|
-
@ohai.stub!(:from).with("dmidecode -s processor-version").and_return("Not Specified")
|
47
|
-
@ohai.stub!(:from).with("dmidecode -s processor-frequency").and_return("2000 Mhz")
|
97
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
98
|
+
@stdin = mock("STDIN", { :close => true })
|
99
|
+
@pid = 10
|
100
|
+
@stderr = mock("STDERR")
|
101
|
+
@stdout = StringIO.new(DMI_OUT)
|
102
|
+
@status = 0
|
103
|
+
@ohai.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should run dmidecode" do
|
107
|
+
@ohai.should_receive(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
108
|
+
@ohai._require_plugin("dmi")
|
48
109
|
end
|
49
110
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
it_should_check_from_deep_mash("dmi", [ "dmi", "processor" ], "frequency", "dmidecode -s processor-frequency", "2000 Mhz")
|
111
|
+
# Test some simple sample data
|
112
|
+
{
|
113
|
+
:bios => {
|
114
|
+
:vendor => "Phoenix Technologies LTD",
|
115
|
+
:release_date => "12/31/2009"
|
116
|
+
},
|
117
|
+
:system => {
|
118
|
+
:manufacturer => "VMware, Inc.",
|
119
|
+
:product_name => "VMware Virtual Platform"
|
120
|
+
},
|
121
|
+
:chassis => {
|
122
|
+
:lock => "Not Present",
|
123
|
+
:asset_tag => "No Asset Tag"
|
124
|
+
}
|
125
|
+
}.each do |id, data|
|
126
|
+
data.each do |attribute, value|
|
127
|
+
it "should have [:dmi][:#{id}][:#{attribute}] set" do
|
128
|
+
@ohai._require_plugin("dmi")
|
129
|
+
@ohai[:dmi][id][attribute].should eql(value)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
73
133
|
end
|
@@ -27,14 +27,14 @@ describe Ohai::System, "plugin ec2" do
|
|
27
27
|
@ohai[:network] = {:interfaces => {:eth0 => {} } }
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
shared_examples_for "!ec2" do
|
31
31
|
it "should NOT attempt to fetch the ec2 metadata" do
|
32
32
|
OpenURI.should_not_receive(:open)
|
33
33
|
@ohai._require_plugin("ec2")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
shared_examples_for "ec2" do
|
38
38
|
before(:each) do
|
39
39
|
OpenURI.stub!(:open_uri).
|
40
40
|
with("http://169.254.169.254/2008-02-01/meta-data/").
|
@@ -77,7 +77,7 @@ describe Ohai::System, "plugin ec2" do
|
|
77
77
|
|
78
78
|
describe "without ec2 mac and metadata address connected" do
|
79
79
|
it_should_behave_like "!ec2"
|
80
|
-
|
80
|
+
|
81
81
|
before(:each) do
|
82
82
|
@ohai[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"00:50:56:c0:00:08"}
|
83
83
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
|
+
# Author:: Christopher Brown (cb@opscode.com)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
21
|
+
require 'open-uri'
|
22
|
+
|
23
|
+
describe Ohai::System, "plugin eucalyptus" do
|
24
|
+
before(:each) do
|
25
|
+
@ohai = Ohai::System.new
|
26
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_examples_for "!eucalyptus" do
|
30
|
+
it "should NOT attempt to fetch the eucalyptus metadata" do
|
31
|
+
OpenURI.should_not_receive(:open)
|
32
|
+
@ohai._require_plugin("eucalyptus")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
shared_examples_for "eucalyptus" do
|
37
|
+
before(:each) do
|
38
|
+
OpenURI.stub!(:open_uri).
|
39
|
+
with("http://169.254.169.254/2008-02-01/meta-data/").
|
40
|
+
and_return(mock(IO, :read => "instance_type\nami_id\nsecurity-groups"))
|
41
|
+
OpenURI.stub!(:open_uri).
|
42
|
+
with("http://169.254.169.254/2008-02-01/meta-data/instance_type").
|
43
|
+
and_return(mock(IO, :read => "c1.medium"))
|
44
|
+
OpenURI.stub!(:open_uri).
|
45
|
+
with("http://169.254.169.254/2008-02-01/meta-data/ami_id").
|
46
|
+
and_return(mock(IO, :read => "ami-5d2dc934"))
|
47
|
+
OpenURI.stub!(:open_uri).
|
48
|
+
with("http://169.254.169.254/2008-02-01/meta-data/security-groups").
|
49
|
+
and_return(mock(IO, :read => "group1\ngroup2"))
|
50
|
+
OpenURI.stub!(:open_uri).
|
51
|
+
with("http://169.254.169.254/2008-02-01/user-data/").
|
52
|
+
and_return(mock(IO, :gets => "By the pricking of my thumb..."))
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should recursively fetch all the eucalyptus metadata" do
|
56
|
+
IO.stub!(:select).and_return([[],[1],[]])
|
57
|
+
t = mock("connection")
|
58
|
+
t.stub!(:connect_nonblock).and_raise(Errno::EINPROGRESS)
|
59
|
+
Socket.stub!(:new).and_return(t)
|
60
|
+
@ohai._require_plugin("eucalyptus")
|
61
|
+
@ohai[:eucalyptus].should_not be_nil
|
62
|
+
@ohai[:eucalyptus]['instance_type'].should == "c1.medium"
|
63
|
+
@ohai[:eucalyptus]['ami_id'].should == "ami-5d2dc934"
|
64
|
+
@ohai[:eucalyptus]['security_groups'].should eql ['group1', 'group2']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "with eucalyptus mac and metadata address connected" do
|
69
|
+
it_should_behave_like "eucalyptus"
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
IO.stub!(:select).and_return([[],[1],[]])
|
73
|
+
@ohai[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED"=> { "family" => "lladdr" } } } } }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "without eucalyptus mac and metadata address connected" do
|
78
|
+
it_should_behave_like "!eucalyptus"
|
79
|
+
|
80
|
+
before(:each) do
|
81
|
+
@ohai[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED"=> { "family" => "lladdr" } } } } }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
20
20
|
|
21
|
-
describe Ohai::System, "plugin java" do
|
21
|
+
describe Ohai::System, "plugin java (Java5 Client VM)" do
|
22
22
|
before(:each) do
|
23
23
|
@ohai = Ohai::System.new
|
24
24
|
@ohai.stub!(:require_plugin).and_return(true)
|
@@ -62,9 +62,62 @@ describe Ohai::System, "plugin java" do
|
|
62
62
|
it "should not set the languages[:java] tree up if java command fails" do
|
63
63
|
@status = 1
|
64
64
|
@stdout = ""
|
65
|
-
@stderr = "
|
65
|
+
@stderr = "Some error output here"
|
66
66
|
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr])
|
67
67
|
@ohai._require_plugin("java")
|
68
68
|
@ohai.languages.should_not have_key(:java)
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
describe Ohai::System, "plugin java (Java6 Server VM)" do
|
73
|
+
before(:each) do
|
74
|
+
@ohai = Ohai::System.new
|
75
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
76
|
+
@ohai[:languages] = Mash.new
|
77
|
+
@status = 0
|
78
|
+
@stdout = ""
|
79
|
+
@stderr = "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)"
|
80
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr])
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should run java -version" do
|
84
|
+
@ohai.should_receive(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([0, "", "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)"])
|
85
|
+
@ohai._require_plugin("java")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should set java[:version]" do
|
89
|
+
@ohai._require_plugin("java")
|
90
|
+
@ohai.languages[:java][:version].should eql("1.6.0_22")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should set java[:runtime][:name] to runtime name" do
|
94
|
+
@ohai._require_plugin("java")
|
95
|
+
@ohai.languages[:java][:runtime][:name].should eql("Java(TM) 2 Runtime Environment")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should set java[:runtime][:build] to runtime build" do
|
99
|
+
@ohai._require_plugin("java")
|
100
|
+
@ohai.languages[:java][:runtime][:build].should eql("1.6.0_22-b04")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should set java[:hotspot][:name] to hotspot name" do
|
104
|
+
@ohai._require_plugin("java")
|
105
|
+
@ohai.languages[:java][:hotspot][:name].should eql("Java HotSpot(TM) Server VM")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should set java[:hotspot][:build] to hotspot build" do
|
109
|
+
@ohai._require_plugin("java")
|
110
|
+
@ohai.languages[:java][:hotspot][:build].should eql("17.1-b03, mixed mode")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should not set the languages[:java] tree up if java command fails" do
|
114
|
+
@status = 1
|
115
|
+
@stdout = ""
|
116
|
+
@stderr = "Some error output here"
|
117
|
+
@ohai.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr])
|
118
|
+
@ohai._require_plugin("java")
|
119
|
+
@ohai.languages.should_not have_key(:java)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|