facter 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +11 -0
- data/LICENSE +1 -1
- data/conf/osx/createpackage.sh +1 -1
- data/conf/redhat/facter.spec +9 -6
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +1 -1
- data/lib/facter.rb +2 -2
- data/lib/facter/architecture.rb +1 -2
- data/lib/facter/augeasversion.rb +1 -2
- data/lib/facter/domain.rb +3 -3
- data/lib/facter/hardwareisa.rb +1 -1
- data/lib/facter/ipaddress.rb +2 -2
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +2 -2
- data/lib/facter/manufacturer.rb +1 -1
- data/lib/facter/netmask.rb +0 -3
- data/lib/facter/network.rb +2 -3
- data/lib/facter/operatingsystem.rb +5 -2
- data/lib/facter/operatingsystemrelease.rb +3 -3
- data/lib/facter/osfamily.rb +1 -1
- data/lib/facter/processor.rb +2 -2
- data/lib/facter/selinux.rb +3 -3
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/uptime_days.rb +0 -1
- data/lib/facter/uptime_hours.rb +0 -1
- data/lib/facter/util/manufacturer.rb +2 -3
- data/lib/facter/util/processor.rb +3 -3
- data/lib/facter/util/resolution.rb +3 -3
- data/lib/facter/util/values.rb +1 -1
- data/lib/facter/virtual.rb +2 -2
- data/lib/facter/vlans.rb +1 -2
- data/lib/facter/xendomains.rb +0 -1
- data/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag +33 -0
- data/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag +136 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/unit/architecture_spec.rb +40 -40
- data/spec/unit/facter_spec.rb +220 -220
- data/spec/unit/id_spec.rb +16 -16
- data/spec/unit/interfaces_spec.rb +6 -6
- data/spec/unit/memory_spec.rb +105 -105
- data/spec/unit/operatingsystem_spec.rb +72 -63
- data/spec/unit/operatingsystemrelease_spec.rb +44 -43
- data/spec/unit/processor_spec.rb +2 -2
- data/spec/unit/selinux_spec.rb +53 -53
- data/spec/unit/util/collection_spec.rb +183 -183
- data/spec/unit/util/confine_spec.rb +92 -92
- data/spec/unit/util/fact_spec.rb +96 -96
- data/spec/unit/util/ip_spec.rb +218 -218
- data/spec/unit/util/loader_spec.rb +193 -193
- data/spec/unit/util/macosx_spec.rb +63 -63
- data/spec/unit/util/manufacturer_spec.rb +124 -107
- data/spec/unit/util/resolution_spec.rb +235 -235
- data/spec/unit/util/virtual_spec.rb +167 -167
- data/spec/unit/util/vlans_spec.rb +6 -6
- data/spec/unit/virtual_spec.rb +246 -246
- data/spec/watchr.rb +1 -1
- metadata +6 -4
@@ -19,273 +19,273 @@ end
|
|
19
19
|
|
20
20
|
|
21
21
|
describe Facter::Util::Loader do
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
before :each do
|
23
|
+
Facter::Util::Loader.any_instance.unstub(:load_all)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
yield
|
35
|
-
values.each do |var, value|
|
36
|
-
if old.include?(var)
|
37
|
-
ENV[var] = old[var]
|
38
|
-
else
|
39
|
-
ENV.delete(var)
|
40
|
-
end
|
41
|
-
end
|
26
|
+
def with_env(values)
|
27
|
+
old = {}
|
28
|
+
values.each do |var, value|
|
29
|
+
if old_val = ENV[var]
|
30
|
+
old[var] = old_val
|
31
|
+
end
|
32
|
+
ENV[var] = value
|
42
33
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
yield
|
35
|
+
values.each do |var, value|
|
36
|
+
if old.include?(var)
|
37
|
+
ENV[var] = old[var]
|
38
|
+
else
|
39
|
+
ENV.delete(var)
|
40
|
+
end
|
46
41
|
end
|
42
|
+
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
it "should have a method for loading individual facts by name" do
|
45
|
+
Facter::Util::Loader.new.should respond_to(:load)
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
it "should have a method for loading all facts" do
|
49
|
+
Facter::Util::Loader.new.should respond_to(:load_all)
|
50
|
+
end
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@settings = mock 'settings'
|
60
|
-
@settings.stubs(:value).returns "/eh"
|
61
|
-
end
|
52
|
+
it "should have a method for returning directories containing facts" do
|
53
|
+
Facter::Util::Loader.new.should respond_to(:search_path)
|
54
|
+
end
|
62
55
|
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
describe "when determining the search path" do
|
57
|
+
before do
|
58
|
+
@loader = Facter::Util::Loader.new
|
59
|
+
@settings = mock 'settings'
|
60
|
+
@settings.stubs(:value).returns "/eh"
|
61
|
+
end
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
63
|
+
it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do
|
64
|
+
dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
|
65
|
+
paths = @loader.search_path
|
71
66
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
paths.should be_include("/two")
|
77
|
-
end
|
67
|
+
dirs.each do |dir|
|
68
|
+
paths.should be_include(dir)
|
69
|
+
end
|
70
|
+
end
|
78
71
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
paths.should be_include(dir)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
72
|
+
it "should include all search paths registered with Facter" do
|
73
|
+
Facter.expects(:search_path).returns %w{/one /two}
|
74
|
+
paths = @loader.search_path
|
75
|
+
paths.should be_include("/one")
|
76
|
+
paths.should be_include("/two")
|
89
77
|
end
|
90
78
|
|
91
|
-
describe "
|
92
|
-
|
93
|
-
|
94
|
-
|
79
|
+
describe "and the FACTERLIB environment variable is set" do
|
80
|
+
it "should include all paths in FACTERLIB" do
|
81
|
+
with_env "FACTERLIB" => "/one/path:/two/path" do
|
82
|
+
paths = @loader.search_path
|
83
|
+
%w{/one/path /two/path}.each do |dir|
|
84
|
+
paths.should be_include(dir)
|
85
|
+
end
|
95
86
|
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
96
90
|
|
97
|
-
|
98
|
-
|
91
|
+
describe "when loading facts" do
|
92
|
+
before do
|
93
|
+
@loader = Facter::Util::Loader.new
|
94
|
+
@loader.stubs(:search_path).returns []
|
95
|
+
end
|
99
96
|
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
97
|
+
it "should load values from the matching environment variable if one is present" do
|
98
|
+
Facter.expects(:add).with("testing")
|
104
99
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true
|
100
|
+
with_env "facter_testing" => "yayness" do
|
101
|
+
@loader.load(:testing)
|
102
|
+
end
|
103
|
+
end
|
110
104
|
|
111
|
-
|
112
|
-
|
105
|
+
it "should load any files in the search path with names matching the fact name" do
|
106
|
+
@loader.expects(:search_path).returns %w{/one/dir /two/dir}
|
107
|
+
FileTest.stubs(:exist?).returns false
|
108
|
+
FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true
|
109
|
+
FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true
|
113
110
|
|
114
|
-
|
115
|
-
|
111
|
+
Kernel.expects(:load).with("/one/dir/testing.rb")
|
112
|
+
Kernel.expects(:load).with("/two/dir/testing.rb")
|
116
113
|
|
117
|
-
|
118
|
-
|
114
|
+
@loader.load(:testing)
|
115
|
+
end
|
119
116
|
|
120
|
-
|
121
|
-
|
122
|
-
FileTest.stubs(:directory?).with("/one/dir/testing").returns true
|
123
|
-
@loader.stubs(:search_path).returns %w{/one/dir}
|
117
|
+
it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do
|
118
|
+
@loader = TestLoader.new
|
124
119
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
120
|
+
@loader.stubs(:search_path).returns %w{/one/dir}
|
121
|
+
FileTest.stubs(:exist?).returns false
|
122
|
+
FileTest.stubs(:directory?).with("/one/dir/testing").returns true
|
123
|
+
@loader.stubs(:search_path).returns %w{/one/dir}
|
130
124
|
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb}
|
126
|
+
%w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f|
|
127
|
+
File.stubs(:directory?).with(f).returns false
|
128
|
+
Kernel.stubs(:load).with(f)
|
129
|
+
end
|
134
130
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
FileTest.expects(:directory?).with("/one/dir/testing").returns true
|
131
|
+
@loader.load(:testing)
|
132
|
+
@loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb}
|
133
|
+
end
|
139
134
|
|
140
|
-
|
135
|
+
it "should load any ruby files in directories matching the fact name in the search path" do
|
136
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
137
|
+
FileTest.stubs(:exist?).returns false
|
138
|
+
FileTest.expects(:directory?).with("/one/dir/testing").returns true
|
141
139
|
|
142
|
-
|
140
|
+
Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb}
|
143
141
|
|
144
|
-
|
145
|
-
end
|
142
|
+
Kernel.expects(:load).with("/one/dir/testing/two.rb")
|
146
143
|
|
147
|
-
|
148
|
-
|
149
|
-
FileTest.stubs(:exist?).returns false
|
150
|
-
FileTest.expects(:directory?).with("/one/dir/testing").returns true
|
144
|
+
@loader.load(:testing)
|
145
|
+
end
|
151
146
|
|
152
|
-
|
147
|
+
it "should not load files that don't end in '.rb'" do
|
148
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
149
|
+
FileTest.stubs(:exist?).returns false
|
150
|
+
FileTest.expects(:directory?).with("/one/dir/testing").returns true
|
153
151
|
|
154
|
-
|
152
|
+
Dir.expects(:entries).with("/one/dir/testing").returns %w{one}
|
155
153
|
|
156
|
-
|
157
|
-
|
154
|
+
Kernel.expects(:load).never
|
155
|
+
|
156
|
+
@loader.load(:testing)
|
158
157
|
end
|
158
|
+
end
|
159
159
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
160
|
+
describe "when loading all facts" do
|
161
|
+
before do
|
162
|
+
@loader = Facter::Util::Loader.new
|
163
|
+
@loader.stubs(:search_path).returns []
|
164
164
|
|
165
|
-
|
166
|
-
|
165
|
+
FileTest.stubs(:directory?).returns true
|
166
|
+
end
|
167
167
|
|
168
|
-
|
169
|
-
|
168
|
+
it "should skip directories that do not exist" do
|
169
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
170
170
|
|
171
|
-
|
171
|
+
FileTest.expects(:directory?).with("/one/dir").returns false
|
172
172
|
|
173
|
-
|
173
|
+
Dir.expects(:entries).with("/one/dir").never
|
174
174
|
|
175
|
-
|
176
|
-
|
175
|
+
@loader.load_all
|
176
|
+
end
|
177
177
|
|
178
|
-
|
179
|
-
|
178
|
+
it "should load all files in all search paths" do
|
179
|
+
@loader.expects(:search_path).returns %w{/one/dir /two/dir}
|
180
180
|
|
181
|
-
|
182
|
-
|
181
|
+
Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb}
|
182
|
+
Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb}
|
183
183
|
|
184
|
-
|
184
|
+
%w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) }
|
185
185
|
|
186
|
-
|
187
|
-
|
186
|
+
@loader.load_all
|
187
|
+
end
|
188
188
|
|
189
|
-
|
190
|
-
|
189
|
+
it "should load all files in all subdirectories in all search paths" do
|
190
|
+
@loader.expects(:search_path).returns %w{/one/dir /two/dir}
|
191
191
|
|
192
|
-
|
193
|
-
|
192
|
+
Dir.expects(:entries).with("/one/dir").returns %w{a}
|
193
|
+
Dir.expects(:entries).with("/two/dir").returns %w{b}
|
194
194
|
|
195
|
-
|
195
|
+
%w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true }
|
196
196
|
|
197
|
-
|
198
|
-
|
197
|
+
Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb}
|
198
|
+
Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb}
|
199
199
|
|
200
|
-
|
200
|
+
%w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) }
|
201
201
|
|
202
|
-
|
203
|
-
|
202
|
+
@loader.load_all
|
203
|
+
end
|
204
204
|
|
205
|
-
|
206
|
-
|
205
|
+
it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do
|
206
|
+
@loader = TestLoader.new
|
207
207
|
|
208
|
-
|
209
|
-
|
208
|
+
@loader.stubs(:search_path).returns %w{/one/dir}
|
209
|
+
Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb}
|
210
210
|
|
211
|
-
|
211
|
+
%w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true }
|
212
212
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
213
|
+
%w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f|
|
214
|
+
File.stubs(:directory?).with(f).returns false
|
215
|
+
Kernel.expects(:load).with(f)
|
216
|
+
end
|
217
217
|
|
218
|
-
|
218
|
+
@loader.load_all
|
219
219
|
|
220
|
-
|
221
|
-
|
220
|
+
@loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb}
|
221
|
+
end
|
222
222
|
|
223
|
-
|
224
|
-
|
223
|
+
it "should not load files in the util subdirectory" do
|
224
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
225
225
|
|
226
|
-
|
226
|
+
Dir.expects(:entries).with("/one/dir").returns %w{util}
|
227
227
|
|
228
|
-
|
228
|
+
File.expects(:directory?).with("/one/dir/util").returns true
|
229
229
|
|
230
|
-
|
230
|
+
Dir.expects(:entries).with("/one/dir/util").never
|
231
231
|
|
232
|
-
|
233
|
-
|
232
|
+
@loader.load_all
|
233
|
+
end
|
234
234
|
|
235
|
-
|
236
|
-
|
235
|
+
it "should not load files in a lib subdirectory" do
|
236
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
237
237
|
|
238
|
-
|
238
|
+
Dir.expects(:entries).with("/one/dir").returns %w{lib}
|
239
239
|
|
240
|
-
|
240
|
+
File.expects(:directory?).with("/one/dir/lib").returns true
|
241
241
|
|
242
|
-
|
242
|
+
Dir.expects(:entries).with("/one/dir/lib").never
|
243
243
|
|
244
|
-
|
245
|
-
|
244
|
+
@loader.load_all
|
245
|
+
end
|
246
246
|
|
247
|
-
|
248
|
-
|
247
|
+
it "should not load files in '.' or '..'" do
|
248
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
249
249
|
|
250
|
-
|
250
|
+
Dir.expects(:entries).with("/one/dir").returns %w{. ..}
|
251
251
|
|
252
|
-
|
253
|
-
|
252
|
+
File.expects(:entries).with("/one/dir/.").never
|
253
|
+
File.expects(:entries).with("/one/dir/..").never
|
254
254
|
|
255
|
-
|
256
|
-
|
255
|
+
@loader.load_all
|
256
|
+
end
|
257
257
|
|
258
|
-
|
259
|
-
|
260
|
-
|
258
|
+
it "should not raise an exception when a file is unloadable" do
|
259
|
+
@loader.expects(:search_path).returns %w{/one/dir}
|
260
|
+
Dir.expects(:entries).with("/one/dir").returns %w{a.rb}
|
261
261
|
|
262
|
-
|
263
|
-
|
262
|
+
Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError)
|
263
|
+
@loader.expects(:warn)
|
264
264
|
|
265
|
-
|
266
|
-
|
265
|
+
lambda { @loader.load_all }.should_not raise_error
|
266
|
+
end
|
267
267
|
|
268
|
-
|
269
|
-
|
270
|
-
|
268
|
+
it "should load all facts from the environment" do
|
269
|
+
Facter.expects(:add).with('one')
|
270
|
+
Facter.expects(:add).with('two')
|
271
271
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
272
|
+
with_env "facter_one" => "yayness", "facter_two" => "boo" do
|
273
|
+
@loader.load_all
|
274
|
+
end
|
275
|
+
end
|
276
276
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
end
|
277
|
+
it "should only load all facts one time" do
|
278
|
+
@loader.expects(:load_env).once
|
279
|
+
@loader.load_all
|
280
|
+
@loader.load_all
|
282
281
|
end
|
282
|
+
end
|
283
283
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
end
|
284
|
+
it "should load facts on the facter search path only once" do
|
285
|
+
facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader')
|
286
|
+
with_env 'FACTERLIB' => facterlibdir do
|
287
|
+
Facter::Util::Loader.new.load_all
|
288
|
+
Facter.value(:nosuchfact).should be_nil
|
290
289
|
end
|
290
|
+
end
|
291
291
|
end
|