facter 1.6.14 → 1.6.15.rc1

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.

@@ -0,0 +1,7 @@
1
+ Net to Media Table: IPv4
2
+ Device IP Address Mask Flags Phys Addr
3
+ ------ -------------------- --------------- ----- ---------------
4
+ dnet0 pecan 255.255.255.255 08:00:20:05:21:33
5
+ dnet0 horseshoe 255.255.255.255 00:00:0c:e0:80:b1
6
+ dnet0 crab 255.255.255.255 SP 08:00:20:22:fd:51
7
+ dnet0 BASE-ADDRESS.MCAST.NET 240.0.0.0 SM 01:00:5e:00:00:00
@@ -0,0 +1,10 @@
1
+ eth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9
2
+ inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0
3
+ inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link
4
+ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
5
+ RX packets:173 errors:173 dropped:0 overruns:0 frame:0
6
+ TX packets:208 errors:0 dropped:0 overruns:0 carrier:0
7
+ collisions:0 txqueuelen:1000
8
+ RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB)
9
+ Interrupt:16 Base address:0x2024
10
+
@@ -0,0 +1,9 @@
1
+ lo Link encap:Local Loopback
2
+ inet addr:127.0.0.1 Mask:255.0.0.0
3
+ inet6 addr: ::1/128 Scope:Host
4
+ UP LOOPBACK RUNNING MTU:16436 Metric:1
5
+ RX packets:1630 errors:0 dropped:0 overruns:0 frame:0
6
+ TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0
7
+ collisions:0 txqueuelen:0
8
+ RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB)
9
+
@@ -28,11 +28,6 @@ describe "ec2 facts" do
28
28
  with("#{api_prefix}/2008-02-01/meta-data/foo").
29
29
  at_least_once.returns(StringIO.new("bar"))
30
30
 
31
- # No user-data
32
- Object.any_instance.expects(:open).
33
- with("#{api_prefix}/2008-02-01/user-data/").
34
- at_least_once.returns(StringIO.new(""))
35
-
36
31
  Facter.collection.loader.load(:ec2)
37
32
  Facter.fact(:ec2_foo).value.should == "bar"
38
33
  end
@@ -46,11 +41,6 @@ describe "ec2 facts" do
46
41
  with("#{api_prefix}/2008-02-01/meta-data/foo").
47
42
  at_least_once.returns(StringIO.new("bar\nbaz"))
48
43
 
49
- # No user-data
50
- Object.any_instance.expects(:open).
51
- with("#{api_prefix}/2008-02-01/user-data/").
52
- at_least_once.returns(StringIO.new(""))
53
-
54
44
  Facter.collection.loader.load(:ec2)
55
45
  Facter.fact(:ec2_foo).value.should == "bar,baz"
56
46
  end
@@ -68,11 +58,6 @@ describe "ec2 facts" do
68
58
  with("#{api_prefix}/2008-02-01/meta-data/foo/bar").
69
59
  at_least_once.returns(StringIO.new("baz"))
70
60
 
71
- # No user-data
72
- Object.any_instance.expects(:open).
73
- with("#{api_prefix}/2008-02-01/user-data/").
74
- at_least_once.returns(StringIO.new(""))
75
-
76
61
  Facter.collection.loader.load(:ec2)
77
62
  Facter.fact(:ec2_foo_bar).value.should == "baz"
78
63
  end
@@ -83,7 +68,7 @@ describe "ec2 facts" do
83
68
  with("#{api_prefix}/2008-02-01/meta-data/").
84
69
  at_least_once.returns(StringIO.new(""))
85
70
 
86
- Object.any_instance.expects(:open).
71
+ Facter::Util::Resolution.any_instance.expects(:open).
87
72
  with("#{api_prefix}/2008-02-01/user-data/").
88
73
  at_least_once.returns(StringIO.new("test"))
89
74
 
@@ -109,7 +94,7 @@ describe "ec2 facts" do
109
94
  with("#{api_prefix}/2008-02-01/meta-data/").\
110
95
  at_least_once.returns(StringIO.new(""))
111
96
 
112
- Object.any_instance.expects(:open).\
97
+ Facter::Util::Resolution.any_instance.expects(:open).\
113
98
  with("#{api_prefix}/2008-02-01/user-data/").\
114
99
  at_least_once.returns(StringIO.new("test"))
115
100
 
@@ -137,7 +122,7 @@ describe "ec2 facts" do
137
122
  with("#{api_prefix}/2008-02-01/meta-data/").\
138
123
  at_least_once.returns(StringIO.new(""))
139
124
 
140
- Object.any_instance.expects(:open).\
125
+ Facter::Util::Resolution.any_instance.expects(:open).\
141
126
  with("#{api_prefix}/2008-02-01/user-data/").\
142
127
  at_least_once.returns(StringIO.new("test"))
143
128
 
@@ -146,6 +131,25 @@ describe "ec2 facts" do
146
131
 
147
132
  Facter.fact(:ec2_userdata).value.should == ["test"]
148
133
  end
134
+
135
+ it "should return nil if open fails" do
136
+ Facter.expects(:warn).with('Could not retrieve ec2 metadata: host unreachable').twice
137
+ Facter::Util::Resolution.any_instance.stubs(:warn) # do not pollute test output
138
+
139
+ Object.any_instance.expects(:open).
140
+ with("#{api_prefix}/2008-02-01/meta-data/").
141
+ at_least_once.raises(RuntimeError, 'host unreachable')
142
+
143
+ Facter::Util::Resolution.any_instance.expects(:open).
144
+ with("#{api_prefix}/2008-02-01/user-data/").
145
+ at_least_once.raises(RuntimeError, 'host unreachable')
146
+
147
+ # Force a fact load
148
+ Facter.collection.loader.load(:ec2)
149
+
150
+ Facter.fact(:ec2_userdata).value.should be_nil
151
+ end
152
+
149
153
  end
150
154
 
151
155
  describe "when api connect test fails" do
@@ -309,4 +309,100 @@ describe "processorX facts" do
309
309
  end
310
310
  end
311
311
  end
312
+
313
+ describe "on HP-UX" do
314
+ def self.machinfo_examples
315
+ examples = []
316
+ examples << [File.read(fixtures('hpux','machinfo','ia64-rx2620')), "Intel(R) Itanium 2 processor"]
317
+ examples << [File.read(fixtures('hpux','machinfo','ia64-rx6600')), "Intel(R) Itanium 2 9100 series processor (1.59 GHz, 18 MB)"]
318
+ examples << [File.read(fixtures('hpux','machinfo','ia64-rx8640')), "Intel(R) Itanium 2 9100 series"]
319
+ examples << [File.read(fixtures('hpux','machinfo','hppa-rp4440')), "PA-RISC 8800 processor (1000 MHz, 64 MB)"]
320
+ examples
321
+ end
322
+
323
+ let(:ioscan) do
324
+ "Class I H/W Path Driver S/W State H/W Type Description\n" +
325
+ "===================================================================\n" +
326
+ "processor 0 0/120 processor CLAIMED PROCESSOR Processor\n" +
327
+ "processor 1 0/123 processor CLAIMED PROCESSOR Processor\n"
328
+ end
329
+
330
+ describe "when machinfo is available" do
331
+ machinfo_examples.each_with_index do |example, i|
332
+ machinfo_example, expected_cpu = example
333
+ context "machinfo example ##{i}" do
334
+ before :each do
335
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
336
+ Facter::Util::Processor.stubs(:ioscan).returns(ioscan)
337
+ Facter::Util::Processor.stubs(:machinfo).returns(machinfo_example)
338
+ Facter.collection.loader.load(:processor)
339
+ end
340
+
341
+ %w{ 0 1 }.each do |j|
342
+ it "should find #{expected_cpu}" do
343
+ Facter.value("processor#{j}").should == expected_cpu
344
+ end
345
+ end
346
+ end
347
+ end
348
+ end
349
+
350
+ def self.model_and_getconf_examples
351
+ examples = []
352
+ examples << ["9000/800/L3000-5x", "sched.models_present", "unistd.h_present", "532", "616", "PA-RISC 8600 processor"]
353
+ examples << ["9000/800/L3000-5x", "", "unistd.h_present", "532", "616", "HP PA-RISC2.0 CHIP TYPE #616"]
354
+ examples << ["9000/800/L3000-5x", "", "", "532", "616", "CPU v532 CHIP TYPE #616"]
355
+ examples << ["ia64 hp server rx2660", "sched.models_present", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"]
356
+ examples << ["ia64 hp server rx2660", "", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"]
357
+ examples << ["ia64 hp server rx2660", "", "", "768", "536936708", "CPU v768 CHIP TYPE #536936708"]
358
+ examples
359
+ end
360
+
361
+ sched_models = File.readlines(fixtures('hpux','sched.models'))
362
+ unistd_h = File.readlines(fixtures('hpux','unistd.h'))
363
+
364
+ describe "when machinfo is not available" do
365
+ model_and_getconf_examples.each_with_index do |example, i|
366
+ model_example, sm, unistd, getconf_cpu_ver, getconf_chip_type, expected_cpu = example
367
+ context "and model and getconf example ##{i}" do
368
+ before :each do
369
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
370
+ Facter::Util::Processor.stubs(:ioscan).returns(ioscan)
371
+ Facter::Util::Processor.stubs(:getconf_cpu_version).returns(getconf_cpu_ver)
372
+ Facter::Util::Processor.stubs(:getconf_cpu_chip_type).returns(getconf_chip_type)
373
+ Facter::Util::Processor.stubs(:machinfo).returns(nil)
374
+ Facter::Util::Processor.stubs(:model).returns(model_example)
375
+ end
376
+
377
+ if unistd == "unistd.h_present" then
378
+ before :each do
379
+ Facter::Util::Processor.stubs(:read_unistd_h).returns(unistd_h)
380
+ end
381
+ else
382
+ before :each do
383
+ Facter::Util::Processor.stubs(:read_unistd_h).returns(nil)
384
+ end
385
+ end
386
+
387
+ if sm == "sched.models_present" then
388
+ before :each do
389
+ Facter::Util::Processor.stubs(:read_sched_models).returns(sched_models)
390
+ Facter.collection.loader.load(:processor)
391
+ end
392
+ else
393
+ before :each do
394
+ Facter::Util::Processor.stubs(:read_sched_models).returns(nil)
395
+ Facter.collection.loader.load(:processor)
396
+ end
397
+ end
398
+
399
+ %w{ 0 1 }.each do |j|
400
+ it "should find #{expected_cpu}" do
401
+ Facter.value("processor#{j}").should == expected_cpu
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
312
408
  end
@@ -57,6 +57,21 @@ describe Facter::Util::EC2 do
57
57
  Facter::Util::EC2.has_ec2_arp?.should == false
58
58
  end
59
59
  end
60
+
61
+ describe "on solaris" do
62
+ before :each do
63
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
64
+ end
65
+
66
+ it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do
67
+ ec2arp = my_fixture_read("solaris8_arp_a_not_ec2.out")
68
+
69
+ Facter::Util::Resolution.expects(:exec).with("arp -a").
70
+ at_least_once.returns(ec2arp)
71
+
72
+ Facter::Util::EC2.has_ec2_arp?.should == false
73
+ end
74
+ end
60
75
  end
61
76
 
62
77
  describe "is_euca_mac? method" do
@@ -110,41 +125,29 @@ describe Facter::Util::EC2 do
110
125
  describe "can_connect? method" do
111
126
  it "returns true if api responds" do
112
127
  # Return something upon connecting to the root
113
- Module.any_instance.expects(:open).with("#{api_prefix}:80/").\
128
+ Module.any_instance.expects(:open).with("#{api_prefix}:80/").
114
129
  at_least_once.returns("2008-02-01\nlatest")
115
130
 
116
- Facter::Util::EC2.can_connect?.should == true
131
+ Facter::Util::EC2.can_connect?.should be_true
117
132
  end
118
133
 
119
134
  describe "when connection times out" do
120
- before :each do
135
+ it "should return false" do
121
136
  # Emulate a timeout when connecting by throwing an exception
122
- Module.any_instance.expects(:open).with("#{api_prefix}:80/").\
123
- at_least_once.raises(Timeout::Error)
124
- end
137
+ Module.any_instance.expects(:open).with("#{api_prefix}:80/").
138
+ at_least_once.raises(RuntimeError)
125
139
 
126
- it "should not raise exception" do
127
- expect { Facter::Util::EC2.can_connect? }.to_not raise_error
128
- end
129
-
130
- it "should return false" do
131
- Facter::Util::EC2.can_connect?.should == false
140
+ Facter::Util::EC2.can_connect?.should be_false
132
141
  end
133
142
  end
134
143
 
135
144
  describe "when connection is refused" do
136
- before :each do
145
+ it "should return false" do
137
146
  # Emulate a connection refused
138
- Module.any_instance.expects(:open).with("#{api_prefix}:80/").\
147
+ Module.any_instance.expects(:open).with("#{api_prefix}:80/").
139
148
  at_least_once.raises(Errno::ECONNREFUSED)
140
- end
141
149
 
142
- it "should not raise exception" do
143
- expect { Facter::Util::EC2.can_connect? }.to_not raise_error
144
- end
145
-
146
- it "should return false" do
147
- Facter::Util::EC2.can_connect?.should == false
150
+ Facter::Util::EC2.can_connect?.should be_false
148
151
  end
149
152
  end
150
153
  end
@@ -261,6 +261,37 @@ describe Facter::Util::IP do
261
261
  Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04"
262
262
  end
263
263
 
264
+ it "should return mtu information on Linux" do
265
+ linux_ifconfig = my_fixture_read("linux_ifconfig_all_with_single_interface")
266
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
267
+ Facter::Util::IP.stubs(:get_single_interface_output).with("eth0").
268
+ returns(my_fixture_read("linux_get_single_interface_eth0"))
269
+ Facter::Util::IP.stubs(:get_single_interface_output).with("lo").
270
+ returns(my_fixture_read("linux_get_single_interface_lo"))
271
+ Facter.stubs(:value).with(:kernel).returns("Linux")
272
+
273
+ Facter::Util::IP.get_interface_value("eth0", "mtu").should == "1500"
274
+ Facter::Util::IP.get_interface_value("lo", "mtu").should == "16436"
275
+ end
276
+
277
+ it "should return mtu information on Darwin" do
278
+ darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface")
279
+
280
+ Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface)
281
+ Facter.stubs(:value).with(:kernel).returns("Darwin")
282
+
283
+ Facter::Util::IP.get_interface_value("en1", "mtu").should == "1500"
284
+ end
285
+
286
+ it "should return mtu information for Solaris" do
287
+ solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface")
288
+
289
+ Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
290
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
291
+
292
+ Facter::Util::IP.get_interface_value("e1000g0", "mtu").should == "1500"
293
+ end
294
+
264
295
  describe "on Windows" do
265
296
  before :each do
266
297
  Facter.stubs(:value).with(:kernel).returns("windows")
metadata CHANGED
@@ -1,23 +1,34 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: facter
3
- version: !ruby/object:Gem::Version
4
- version: 1.6.14
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3742991977
5
+ prerelease: 7
6
+ segments:
7
+ - 1
8
+ - 6
9
+ - 15
10
+ - rc
11
+ - 1
12
+ version: 1.6.15.rc1
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Puppet Labs
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
19
+
20
+ date: 2012-11-21 00:00:00 Z
13
21
  dependencies: []
22
+
14
23
  description: You can prove anything with facts!
15
24
  email: info@puppetlabs.com
16
- executables:
25
+ executables:
17
26
  - facter
18
27
  extensions: []
28
+
19
29
  extra_rdoc_files: []
20
- files:
30
+
31
+ files:
21
32
  - CONTRIBUTING.md
22
33
  - Gemfile
23
34
  - Gemfile.lock
@@ -138,6 +149,12 @@ files:
138
149
  - spec/fixtures/cpuinfo/panda-armel
139
150
  - spec/fixtures/cpuinfo/ppc64
140
151
  - spec/fixtures/cpuinfo/sparc
152
+ - spec/fixtures/hpux/machinfo/hppa-rp4440
153
+ - spec/fixtures/hpux/machinfo/ia64-rx2620
154
+ - spec/fixtures/hpux/machinfo/ia64-rx6600
155
+ - spec/fixtures/hpux/machinfo/ia64-rx8640
156
+ - spec/fixtures/hpux/sched.models
157
+ - spec/fixtures/hpux/unistd.h
141
158
  - spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces
142
159
  - spec/fixtures/ifconfig/centos_5_5
143
160
  - spec/fixtures/ifconfig/centos_5_5_eth0
@@ -181,6 +198,7 @@ files:
181
198
  - spec/fixtures/unit/util/ec2/centos-arp-ec2.out
182
199
  - spec/fixtures/unit/util/ec2/linux-arp-ec2.out
183
200
  - spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out
201
+ - spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out
184
202
  - spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out
185
203
  - spec/fixtures/unit/util/ec2/windows-2008-arp-a.out
186
204
  - spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig
@@ -189,7 +207,9 @@ files:
189
207
  - spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig
190
208
  - spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface
191
209
  - spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces
210
+ - spec/fixtures/unit/util/ip/linux_get_single_interface_eth0
192
211
  - spec/fixtures/unit/util/ip/linux_get_single_interface_ib0
212
+ - spec/fixtures/unit/util/ip/linux_get_single_interface_lo
193
213
  - spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface
194
214
  - spec/fixtures/unit/util/ip/linux_ifconfig_ib0
195
215
  - spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig
@@ -272,29 +292,40 @@ files:
272
292
  - spec/watchr.rb
273
293
  homepage: https://github.com/puppetlabs/facter
274
294
  licenses: []
295
+
275
296
  post_install_message:
276
297
  rdoc_options: []
277
- require_paths:
298
+
299
+ require_paths:
278
300
  - lib
279
- required_ruby_version: !ruby/object:Gem::Requirement
301
+ required_ruby_version: !ruby/object:Gem::Requirement
280
302
  none: false
281
- requirements:
282
- - - ! '>='
283
- - !ruby/object:Gem::Version
284
- version: '0'
285
- required_rubygems_version: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ hash: 3
307
+ segments:
308
+ - 0
309
+ version: "0"
310
+ required_rubygems_version: !ruby/object:Gem::Requirement
286
311
  none: false
287
- requirements:
288
- - - ! '>='
289
- - !ruby/object:Gem::Version
290
- version: '0'
312
+ requirements:
313
+ - - ">"
314
+ - !ruby/object:Gem::Version
315
+ hash: 25
316
+ segments:
317
+ - 1
318
+ - 3
319
+ - 1
320
+ version: 1.3.1
291
321
  requirements: []
322
+
292
323
  rubyforge_project:
293
324
  rubygems_version: 1.8.24
294
325
  signing_key:
295
326
  specification_version: 3
296
327
  summary: Facter, a system inventory tool
297
- test_files:
328
+ test_files:
298
329
  - spec/fixtures/cpuinfo/amd64dual
299
330
  - spec/fixtures/cpuinfo/amd64quad
300
331
  - spec/fixtures/cpuinfo/amd64solo
@@ -304,6 +335,12 @@ test_files:
304
335
  - spec/fixtures/cpuinfo/panda-armel
305
336
  - spec/fixtures/cpuinfo/ppc64
306
337
  - spec/fixtures/cpuinfo/sparc
338
+ - spec/fixtures/hpux/machinfo/hppa-rp4440
339
+ - spec/fixtures/hpux/machinfo/ia64-rx2620
340
+ - spec/fixtures/hpux/machinfo/ia64-rx6600
341
+ - spec/fixtures/hpux/machinfo/ia64-rx8640
342
+ - spec/fixtures/hpux/sched.models
343
+ - spec/fixtures/hpux/unistd.h
307
344
  - spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces
308
345
  - spec/fixtures/ifconfig/centos_5_5
309
346
  - spec/fixtures/ifconfig/centos_5_5_eth0
@@ -347,6 +384,7 @@ test_files:
347
384
  - spec/fixtures/unit/util/ec2/centos-arp-ec2.out
348
385
  - spec/fixtures/unit/util/ec2/linux-arp-ec2.out
349
386
  - spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out
387
+ - spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out
350
388
  - spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out
351
389
  - spec/fixtures/unit/util/ec2/windows-2008-arp-a.out
352
390
  - spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig
@@ -355,7 +393,9 @@ test_files:
355
393
  - spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig
356
394
  - spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface
357
395
  - spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces
396
+ - spec/fixtures/unit/util/ip/linux_get_single_interface_eth0
358
397
  - spec/fixtures/unit/util/ip/linux_get_single_interface_ib0
398
+ - spec/fixtures/unit/util/ip/linux_get_single_interface_lo
359
399
  - spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface
360
400
  - spec/fixtures/unit/util/ip/linux_ifconfig_ib0
361
401
  - spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig