ohai 0.5.8 → 0.6.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -33,6 +33,7 @@ describe Ohai::System, "Linux plugin platform" do
|
|
33
33
|
File.stub!(:exists?).with("/etc/SuSE-release").and_return(false)
|
34
34
|
File.stub!(:exists?).with("/etc/arch-release").and_return(false)
|
35
35
|
File.stub!(:exists?).with("/etc/system-release").and_return(false)
|
36
|
+
File.stub!(:exists?).with("/etc/slackware-version").and_return(false)
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should require the lsb plugin" do
|
@@ -81,6 +82,18 @@ describe Ohai::System, "Linux plugin platform" do
|
|
81
82
|
|
82
83
|
end
|
83
84
|
|
85
|
+
describe "on slackware" do
|
86
|
+
before(:each) do
|
87
|
+
@ohai.lsb = nil
|
88
|
+
File.should_receive(:exists?).with("/etc/slackware-version").and_return(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should set platform to slackware" do
|
92
|
+
@ohai._require_plugin("linux::platform")
|
93
|
+
@ohai[:platform].should == "slackware"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
84
97
|
describe "on arch" do
|
85
98
|
before(:each) do
|
86
99
|
@ohai.lsb = nil
|
@@ -31,6 +31,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
31
31
|
File.stub!(:exists?).with("/proc/modules").and_return(false)
|
32
32
|
File.stub!(:exists?).with("/proc/cpuinfo").and_return(false)
|
33
33
|
File.stub!(:exists?).with("/usr/sbin/dmidecode").and_return(false)
|
34
|
+
File.stub!(:exists?).with("/proc/self/status").and_return(false)
|
34
35
|
end
|
35
36
|
|
36
37
|
describe "when we are checking for xen" do
|
@@ -38,14 +39,14 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
38
39
|
File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
39
40
|
File.stub!(:read).with("/proc/xen/capabilities").and_return("control_d")
|
40
41
|
@ohai._require_plugin("linux::virtualization")
|
41
|
-
@ohai[:virtualization][:
|
42
|
+
@ohai[:virtualization][:system].should == "xen"
|
42
43
|
@ohai[:virtualization][:role].should == "host"
|
43
44
|
end
|
44
45
|
|
45
46
|
it "should set xen guest if /proc/sys/xen/independent_wallclock exists" do
|
46
47
|
File.should_receive(:exists?).with("/proc/sys/xen/independent_wallclock").and_return(true)
|
47
48
|
@ohai._require_plugin("linux::virtualization")
|
48
|
-
@ohai[:virtualization][:
|
49
|
+
@ohai[:virtualization][:system].should == "xen"
|
49
50
|
@ohai[:virtualization][:role].should == "guest"
|
50
51
|
end
|
51
52
|
|
@@ -61,7 +62,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
61
62
|
File.should_receive(:exists?).with("/proc/modules").and_return(true)
|
62
63
|
File.stub!(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
|
63
64
|
@ohai._require_plugin("linux::virtualization")
|
64
|
-
@ohai[:virtualization][:
|
65
|
+
@ohai[:virtualization][:system].should == "kvm"
|
65
66
|
@ohai[:virtualization][:role].should == "host"
|
66
67
|
end
|
67
68
|
|
@@ -69,7 +70,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
69
70
|
File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
70
71
|
File.stub!(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
|
71
72
|
@ohai._require_plugin("linux::virtualization")
|
72
|
-
@ohai[:virtualization][:
|
73
|
+
@ohai[:virtualization][:system].should == "kvm"
|
73
74
|
@ohai[:virtualization][:role].should == "guest"
|
74
75
|
end
|
75
76
|
|
@@ -109,7 +110,7 @@ MSVPC
|
|
109
110
|
|
110
111
|
@ohai.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
111
112
|
@ohai._require_plugin("linux::virtualization")
|
112
|
-
@ohai[:virtualization][:
|
113
|
+
@ohai[:virtualization][:system].should == "virtualpc"
|
113
114
|
@ohai[:virtualization][:role].should == "guest"
|
114
115
|
end
|
115
116
|
|
@@ -128,7 +129,7 @@ VMWARE
|
|
128
129
|
@stdout.stub!(:read).and_return(vmware_dmidecode)
|
129
130
|
@ohai.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
130
131
|
@ohai._require_plugin("linux::virtualization")
|
131
|
-
@ohai[:virtualization][:
|
132
|
+
@ohai[:virtualization][:system].should == "vmware"
|
132
133
|
@ohai[:virtualization][:role].should == "guest"
|
133
134
|
end
|
134
135
|
|
@@ -139,6 +140,46 @@ VMWARE
|
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
143
|
+
describe "when we are checking for Linux-VServer" do
|
144
|
+
it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do
|
145
|
+
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
146
|
+
File.stub!(:read).with("/proc/self/status").and_return("s_context: 0")
|
147
|
+
@ohai._require_plugin("linux::virtualization")
|
148
|
+
@ohai[:virtualization][:system].should == "linux-vserver"
|
149
|
+
@ohai[:virtualization][:role].should == "host"
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
|
153
|
+
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
154
|
+
File.stub!(:read).with("/proc/self/status").and_return("VxID: 0")
|
155
|
+
@ohai._require_plugin("linux::virtualization")
|
156
|
+
@ohai[:virtualization][:system].should == "linux-vserver"
|
157
|
+
@ohai[:virtualization][:role].should == "host"
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
|
161
|
+
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
162
|
+
File.stub!(:read).with("/proc/self/status").and_return("s_context: 2")
|
163
|
+
@ohai._require_plugin("linux::virtualization")
|
164
|
+
@ohai[:virtualization][:system].should == "linux-vserver"
|
165
|
+
@ohai[:virtualization][:role].should == "guest"
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
|
169
|
+
File.should_receive(:exists?).with("/proc/self/status").and_return(true)
|
170
|
+
File.stub!(:read).with("/proc/self/status").and_return("VxID: 2")
|
171
|
+
@ohai._require_plugin("linux::virtualization")
|
172
|
+
@ohai[:virtualization][:system].should == "linux-vserver"
|
173
|
+
@ohai[:virtualization][:role].should == "guest"
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should not set virtualization if Linux-VServer isn't there" do
|
177
|
+
File.should_receive(:exists?).at_least(:once).and_return(false)
|
178
|
+
@ohai._require_plugin("linux::virtualization")
|
179
|
+
@ohai[:virtualization].should == {}
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
142
183
|
it "should not set virtualization if no tests match" do
|
143
184
|
@ohai._require_plugin("linux::virtualization")
|
144
185
|
@ohai[:virtualization].should == {}
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -23,12 +23,13 @@ describe Ohai::System, "plugin perl" do
|
|
23
23
|
@ohai = Ohai::System.new
|
24
24
|
@ohai[:languages] = Mash.new
|
25
25
|
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
-
@pid =
|
27
|
-
@stderr =
|
28
|
-
@stdout =
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
@pid = 2342
|
27
|
+
@stderr = StringIO.new
|
28
|
+
@stdout = StringIO.new(<<-OUT)
|
29
|
+
version='5.8.8';
|
30
|
+
archname='darwin-thread-multi-2level';
|
31
|
+
OUT
|
32
|
+
@stdin = StringIO.new
|
32
33
|
@status = 0
|
33
34
|
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([
|
34
35
|
@status,
|
@@ -36,12 +37,12 @@ describe Ohai::System, "plugin perl" do
|
|
36
37
|
@stderr
|
37
38
|
])
|
38
39
|
end
|
39
|
-
|
40
|
+
|
40
41
|
it "should run perl -V:version -V:archname" do
|
41
42
|
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return(true)
|
42
43
|
@ohai._require_plugin("perl")
|
43
44
|
end
|
44
|
-
|
45
|
+
|
45
46
|
it "should iterate over each line of perl command's stdout" do
|
46
47
|
@stdout.should_receive(:each_line).and_return(true)
|
47
48
|
@ohai._require_plugin("perl")
|
@@ -50,13 +51,13 @@ describe Ohai::System, "plugin perl" do
|
|
50
51
|
it "should set languages[:perl][:version]" do
|
51
52
|
@ohai._require_plugin("perl")
|
52
53
|
@ohai.languages[:perl][:version].should eql("5.8.8")
|
53
|
-
end
|
54
|
-
|
54
|
+
end
|
55
|
+
|
55
56
|
it "should set languages[:perl][:archname]" do
|
56
57
|
@ohai._require_plugin("perl")
|
57
58
|
@ohai.languages[:perl][:archname].should eql("darwin-thread-multi-2level")
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
it "should set languages[:perl] if perl command succeeds" do
|
61
62
|
@status = 0
|
62
63
|
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([
|
@@ -67,7 +68,7 @@ describe Ohai::System, "plugin perl" do
|
|
67
68
|
@ohai._require_plugin("perl")
|
68
69
|
@ohai.languages.should have_key(:perl)
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
it "should not set languages[:perl] if perl command fails" do
|
72
73
|
@status = 1
|
73
74
|
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([
|
@@ -38,8 +38,8 @@ describe Ohai::System, "plugin rackspace" do
|
|
38
38
|
}}
|
39
39
|
}
|
40
40
|
}
|
41
|
-
|
42
|
-
@ohai[:network][:interfaces][:eth1] = {:addresses => {
|
41
|
+
|
42
|
+
@ohai[:network][:interfaces][:eth1] = {:addresses => {
|
43
43
|
"fe80::4240:f5ff:feab:2836" => {
|
44
44
|
"scope"=> "Link",
|
45
45
|
"prefixlen"=> "64",
|
@@ -56,20 +56,20 @@ describe Ohai::System, "plugin rackspace" do
|
|
56
56
|
}}
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
shared_examples_for "!rackspace" do
|
60
60
|
it "should NOT create rackspace" do
|
61
61
|
@ohai._require_plugin("rackspace")
|
62
62
|
@ohai[:rackspace].should be_nil
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
|
66
|
+
shared_examples_for "rackspace" do
|
67
|
+
|
68
68
|
it "should create rackspace" do
|
69
69
|
@ohai._require_plugin("rackspace")
|
70
70
|
@ohai[:rackspace].should_not be_nil
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should have all required attributes" do
|
74
74
|
@ohai._require_plugin("rackspace")
|
75
75
|
@ohai[:rackspace][:public_ip].should_not be_nil
|
@@ -81,22 +81,22 @@ describe Ohai::System, "plugin rackspace" do
|
|
81
81
|
@ohai[:rackspace][:public_ip].should == "1.2.3.4"
|
82
82
|
@ohai[:rackspace][:private_ip].should == "5.6.7.8"
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
end
|
86
86
|
|
87
87
|
describe "with rackspace mac and hostname" do
|
88
88
|
it_should_behave_like "rackspace"
|
89
|
-
|
89
|
+
|
90
90
|
before(:each) do
|
91
91
|
IO.stub!(:select).and_return([[],[1],[]])
|
92
92
|
@ohai[:hostname] = "slice74976"
|
93
|
-
@ohai[:network][:interfaces][:eth0][:arp] = {"67.23.20.1" => "00:00:0c:07:ac:01"}
|
93
|
+
@ohai[:network][:interfaces][:eth0][:arp] = {"67.23.20.1" => "00:00:0c:07:ac:01"}
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
describe "without rackspace mac" do
|
98
98
|
it_should_behave_like "!rackspace"
|
99
|
-
|
99
|
+
|
100
100
|
before(:each) do
|
101
101
|
@ohai[:hostname] = "slice74976"
|
102
102
|
@ohai[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"}
|
@@ -105,10 +105,10 @@ describe Ohai::System, "plugin rackspace" do
|
|
105
105
|
|
106
106
|
describe "without rackspace hostname" do
|
107
107
|
it_should_behave_like "rackspace"
|
108
|
-
|
108
|
+
|
109
109
|
before(:each) do
|
110
110
|
@ohai[:hostname] = "bubba"
|
111
|
-
@ohai[:network][:interfaces][:eth0][:arp] = {"67.23.20.1" => "00:00:0c:07:ac:01"}
|
111
|
+
@ohai[:network][:interfaces][:eth0][:arp] = {"67.23.20.1" => "00:00:0c:07:ac:01"}
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -24,18 +24,13 @@ describe Ohai::System, "Solaris2.X hostname plugin" do
|
|
24
24
|
@ohai.stub!(:require_plugin).and_return(true)
|
25
25
|
@ohai[:os] = "solaris2"
|
26
26
|
@ohai.stub!(:from).with("hostname").and_return("kitteh")
|
27
|
-
|
27
|
+
Socket.stub!(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
|
28
28
|
end
|
29
29
|
|
30
30
|
it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh")
|
31
31
|
|
32
|
-
it "should get the fqdn value from
|
33
|
-
|
34
|
-
@ohai.should_receive(:from).with("domainname").and_return("inurfridge.eatinurfoodz")
|
35
|
-
@ohai._require_plugin("solaris2::hostname")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should set the fqdn to the value from 'hostname' and 'domainname'" do
|
32
|
+
it "should get the fqdn value from socket getaddrinfo" do
|
33
|
+
Socket.should_receive(:getaddrinfo)
|
39
34
|
@ohai._require_plugin("solaris2::hostname")
|
40
35
|
@ohai["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
|
41
36
|
end
|
@@ -132,18 +132,18 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
132
132
|
145 12138e4 15e4 4 1 RT (realtime scheduling class)
|
133
133
|
146 121719e 28c - 1 RT_DPTBL (realtime dispatch table)
|
134
134
|
TOOMUCH
|
135
|
-
|
135
|
+
|
136
136
|
before(:each) do
|
137
137
|
@ohai = Ohai::System.new
|
138
138
|
@ohai.stub!(:require_plugin).and_return(true)
|
139
139
|
@ohai[:kernel] = Mash.new
|
140
140
|
@ohai.stub(:from).with("uname -s").and_return("SunOS")
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", "SunOS")
|
144
144
|
|
145
145
|
it "gives excruciating detail about kernel modules" do
|
146
|
-
stdin =
|
146
|
+
stdin = StringIO.new
|
147
147
|
@modinfo_stdout = StringIO.new(MODINFO)
|
148
148
|
@ohai.stub!(:popen4).with("modinfo").and_yield(nil, stdin, @modinfo_stdout, nil)
|
149
149
|
|
@@ -159,6 +159,6 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
159
159
|
@ohai[:kernel][:modules].keys.should_not include("Module")
|
160
160
|
@ohai[:kernel][:modules]["specfs"].should == teh_daterz
|
161
161
|
end
|
162
|
-
|
163
|
-
|
164
|
-
end
|
162
|
+
|
163
|
+
|
164
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
2
|
# Author:: Daniel DeLeo <dan@opscode.com>
|
3
3
|
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
20
20
|
|
21
21
|
describe Ohai::System, "Solaris2.X network plugin" do
|
22
|
-
|
22
|
+
|
23
23
|
before do
|
24
24
|
solaris_ifconfig = <<-ENDIFCONFIG
|
25
25
|
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
@@ -60,17 +60,17 @@ ENDIFCONFIG
|
|
60
60
|
|
61
61
|
solaris_netstat_rn = <<-NETSTAT_RN
|
62
62
|
Routing Table: IPv4
|
63
|
-
Destination Gateway Flags Ref Use Interface
|
64
|
-
-------------------- -------------------- ----- ----- ---------- ---------
|
65
|
-
default 10.13.37.1 UG 1 0 e1000g0
|
66
|
-
10.13.37.0 10.13.37.157 U 1 2 e1000g0
|
67
|
-
127.0.0.1 127.0.0.1 UH 1 35 lo0
|
68
|
-
|
63
|
+
Destination Gateway Flags Ref Use Interface
|
64
|
+
-------------------- -------------------- ----- ----- ---------- ---------
|
65
|
+
default 10.13.37.1 UG 1 0 e1000g0
|
66
|
+
10.13.37.0 10.13.37.157 U 1 2 e1000g0
|
67
|
+
127.0.0.1 127.0.0.1 UH 1 35 lo0
|
68
|
+
|
69
69
|
Routing Table: IPv6
|
70
|
-
Destination/Mask Gateway Flags Ref Use If
|
71
|
-
--------------------------- --------------------------- ----- --- ------- -----
|
72
|
-
fe80::/10 fe80::250:56ff:fe13:3757 U 1 0 e1000g0
|
73
|
-
::1 ::1 UH 1 0 lo0
|
70
|
+
Destination/Mask Gateway Flags Ref Use If
|
71
|
+
--------------------------- --------------------------- ----- --- ------- -----
|
72
|
+
fe80::/10 fe80::250:56ff:fe13:3757 U 1 0 e1000g0
|
73
|
+
::1 ::1 UH 1 0 lo0
|
74
74
|
NETSTAT_RN
|
75
75
|
|
76
76
|
@solaris_route_get = <<-ROUTE_GET
|
@@ -81,20 +81,20 @@ destination: default
|
|
81
81
|
interface: e1000g0
|
82
82
|
flags: <UP,GATEWAY,DONE,STATIC>
|
83
83
|
recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire
|
84
|
-
0 0 0 0 0 0 1500 0
|
84
|
+
0 0 0 0 0 0 1500 0
|
85
85
|
ROUTE_GET
|
86
86
|
|
87
|
-
@stdin =
|
87
|
+
@stdin = StringIO.new
|
88
88
|
@ifconfig_lines = solaris_ifconfig.split("\n")
|
89
89
|
|
90
90
|
@ohai = Ohai::System.new
|
91
91
|
@ohai.stub!(:require_plugin).and_return(true)
|
92
92
|
@ohai[:network] = Mash.new
|
93
|
-
|
93
|
+
|
94
94
|
@ohai.stub(:popen4).with("ifconfig -a")
|
95
95
|
@ohai.stub(:popen4).with("arp -an")
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
describe "gathering IP layer address info" do
|
99
99
|
before do
|
100
100
|
@ohai.stub!(:popen4).with("ifconfig -a").and_yield(nil, @stdin, @ifconfig_lines, nil)
|
@@ -123,7 +123,7 @@ ROUTE_GET
|
|
123
123
|
describe "setting the node's default IP address attribute" do
|
124
124
|
before do
|
125
125
|
@stdout = mock("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
|
126
|
-
@ohai.stub!(:popen4).with("route get default").and_yield(nil,@stdin, @stdout, nil)
|
126
|
+
@ohai.stub!(:popen4).with("route -n get default").and_yield(nil,@stdin, @stdout, nil)
|
127
127
|
@ohai._require_plugin("solaris2::network")
|
128
128
|
end
|
129
129
|
|
@@ -132,4 +132,4 @@ ROUTE_GET
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
135
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sean Walbran (<seanwalbran@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
20
|
+
|
21
|
+
describe Ohai::System, "Solaris virtualization platform" do
|
22
|
+
before(:each) do
|
23
|
+
@ohai = Ohai::System.new
|
24
|
+
@ohai[:os] = "solaris2"
|
25
|
+
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
+
@ohai.extend(SimpleFromFile)
|
27
|
+
|
28
|
+
# default to all requested Files not existing
|
29
|
+
File.stub!(:exists?).with("/usr/sbin/psrinfo").and_return(false)
|
30
|
+
File.stub!(:exists?).with("/usr/sbin/smbios").and_return(false)
|
31
|
+
File.stub!(:exists?).with("/usr/sbin/zoneadm").and_return(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "when we are checking for kvm" do
|
35
|
+
before(:each) do
|
36
|
+
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
|
+
end
|
43
|
+
|
44
|
+
it "should run psrinfo -pv" do
|
45
|
+
@ohai.should_receive(:popen4).with("/usr/sbin/psrinfo -pv").and_return(true)
|
46
|
+
@ohai._require_plugin("solaris2::virtualization")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
|
50
|
+
@stdout.stub!(:read).and_return("QEMU Virtual CPU")
|
51
|
+
@ohai.stub!(:popen4).with("/usr/sbin/psrinfo -pv").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
52
|
+
@ohai._require_plugin("solaris2::virtualization")
|
53
|
+
@ohai[:virtualization][:system].should == "kvm"
|
54
|
+
@ohai[:virtualization][:role].should == "guest"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not set virtualization if kvm isn't there" do
|
58
|
+
@ohai.should_receive(:popen4).with("/usr/sbin/psrinfo -pv").and_return(true)
|
59
|
+
@ohai._require_plugin("solaris2::virtualization")
|
60
|
+
@ohai[:virtualization].should == {}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "when we are parsing smbios" do
|
65
|
+
before(:each) do
|
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
|
+
end
|
73
|
+
|
74
|
+
it "should run smbios" do
|
75
|
+
@ohai.should_receive(:popen4).with("/usr/sbin/smbios").and_return(true)
|
76
|
+
@ohai._require_plugin("solaris2::virtualization")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should set virtualpc guest if smbios detects Microsoft Virtual Machine" do
|
80
|
+
ms_vpc_smbios=<<-MSVPC
|
81
|
+
ID SIZE TYPE
|
82
|
+
1 72 SMB_TYPE_SYSTEM (system information)
|
83
|
+
|
84
|
+
Manufacturer: Microsoft Corporation
|
85
|
+
Product: Virtual Machine
|
86
|
+
Version: VS2005R2
|
87
|
+
Serial Number: 1688-7189-5337-7903-2297-1012-52
|
88
|
+
|
89
|
+
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
90
|
+
Wake-Up Event: 0x6 (power switch)
|
91
|
+
MSVPC
|
92
|
+
@stdout.stub!(:read).and_return(ms_vpc_smbios)
|
93
|
+
|
94
|
+
@ohai.stub!(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
95
|
+
@ohai._require_plugin("solaris2::virtualization")
|
96
|
+
@ohai[:virtualization][:system].should == "virtualpc"
|
97
|
+
@ohai[:virtualization][:role].should == "guest"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should set vmware guest if smbios detects VMware Virtual Platform" do
|
101
|
+
vmware_smbios=<<-VMWARE
|
102
|
+
ID SIZE TYPE
|
103
|
+
1 72 SMB_TYPE_SYSTEM (system information)
|
104
|
+
|
105
|
+
Manufacturer: VMware, Inc.
|
106
|
+
Product: VMware Virtual Platform
|
107
|
+
Version: None
|
108
|
+
Serial Number: VMware-50 3f f7 14 42 d1 f1 da-3b 46 27 d0 29 b4 74 1d
|
109
|
+
|
110
|
+
UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
|
111
|
+
Wake-Up Event: 0x6 (power switch)
|
112
|
+
VMWARE
|
113
|
+
@stdout.stub!(:read).and_return(vmware_smbios)
|
114
|
+
@ohai.stub!(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
115
|
+
@ohai._require_plugin("solaris2::virtualization")
|
116
|
+
@ohai[:virtualization][:system].should == "vmware"
|
117
|
+
@ohai[:virtualization][:role].should == "guest"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should run smbios and not set virtualization if nothing is detected" do
|
121
|
+
@ohai.should_receive(:popen4).with("/usr/sbin/smbios").and_return(true)
|
122
|
+
@ohai._require_plugin("solaris2::virtualization")
|
123
|
+
@ohai[:virtualization].should == {}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should not set virtualization if no tests match" do
|
128
|
+
@ohai._require_plugin("solaris2::virtualization")
|
129
|
+
@ohai[:virtualization].should == {}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|