facter 2.0.2-universal-darwin → 2.1.0-universal-darwin
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.
- checksums.yaml +4 -4
- data/Gemfile +14 -0
- data/ext/project_data.yaml +9 -6
- data/lib/facter/core/execution/base.rb +3 -3
- data/lib/facter/core/suitable.rb +1 -5
- data/lib/facter/dhcp_servers.rb +39 -0
- data/lib/facter/ec2.rb +33 -26
- data/lib/facter/ec2/rest.rb +130 -0
- data/lib/facter/fqdn.rb +2 -0
- data/lib/facter/gce.rb +16 -0
- data/lib/facter/gce/metadata.rb +87 -0
- data/lib/facter/kernelmajversion.rb +8 -0
- data/lib/facter/kernelrelease.rb +8 -0
- data/lib/facter/memory.rb +21 -15
- data/lib/facter/netmask.rb +1 -1
- data/lib/facter/operatingsystem.rb +20 -0
- data/lib/facter/operatingsystemmajrelease.rb +2 -1
- data/lib/facter/operatingsystemrelease.rb +19 -0
- data/lib/facter/osfamily.rb +3 -1
- data/lib/facter/partitions.rb +35 -0
- data/lib/facter/physicalprocessorcount.rb +9 -0
- data/lib/facter/processor.rb +25 -25
- data/lib/facter/util/config.rb +3 -1
- data/lib/facter/util/dhcp_servers.rb +43 -0
- data/lib/facter/util/ec2.rb +5 -0
- data/lib/facter/util/formatter.rb +2 -1
- data/lib/facter/util/ip.rb +1 -1
- data/lib/facter/util/loader.rb +10 -1
- data/lib/facter/util/manufacturer.rb +15 -16
- data/lib/facter/util/memory.rb +12 -12
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/operatingsystem.rb +21 -0
- data/lib/facter/util/partitions.rb +41 -0
- data/lib/facter/util/partitions/linux.rb +65 -0
- data/lib/facter/util/posix.rb +16 -0
- data/lib/facter/util/processor.rb +8 -10
- data/lib/facter/util/resolution.rb +4 -0
- data/lib/facter/util/values.rb +29 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/util/windows_root.rb +2 -32
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +53 -12
- data/spec/fixtures/ifconfig/openbsd_bridge_rules +11 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp +36 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static +24 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp +49 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static +37 -0
- data/spec/fixtures/unit/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/ec2/rest/meta-data/root +20 -0
- data/spec/fixtures/unit/gce/metadata/metadata.json +69 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3 +2 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3-current +3 -0
- data/spec/fixtures/unit/memory/aix-svmon +9 -0
- data/spec/fixtures/unit/memory/aix-swap_l +2 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-multiple +3 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-single +2 -0
- data/spec/fixtures/unit/memory/darwin-vm_stat +13 -0
- data/spec/fixtures/unit/memory/dragonfly-vmstat +3 -0
- data/spec/fixtures/unit/memory/freebsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/linux-proc_meminfo +10 -0
- data/spec/fixtures/unit/memory/openbsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/smartos_zone_swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-prtconf +4 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-multiple +3 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-vmstat +3 -0
- data/spec/fixtures/unit/netmask/ifconfig_aix_7.txt +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/util/manufacturer/smartos_smbios +533 -0
- data/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt +8 -0
- data/spec/fixtures/unit/util/operatingsystem/redhat-7.txt +12 -0
- data/spec/fixtures/unit/util/operatingsystem/sabayon.txt +7 -0
- data/spec/fixtures/unit/util/operatingsystem/wheezy.txt +9 -0
- data/spec/fixtures/unit/util/partitions/partitions/mount +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_container +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container +8 -0
- data/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container +9 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/core/execution/base_spec.rb +3 -5
- data/spec/unit/core/execution/posix_spec.rb +2 -2
- data/spec/unit/core/suitable_spec.rb +10 -0
- data/spec/unit/dhcp_servers_spec.rb +152 -0
- data/spec/unit/ec2/rest_spec.rb +145 -0
- data/spec/unit/ec2_spec.rb +87 -147
- data/spec/unit/fqdn_spec.rb +16 -0
- data/spec/unit/gce/metadata_spec.rb +49 -0
- data/spec/unit/gce_spec.rb +34 -0
- data/spec/unit/interfaces_spec.rb +9 -9
- data/spec/unit/kernelmajversion_spec.rb +14 -9
- data/spec/unit/kernelrelease_spec.rb +16 -0
- data/spec/unit/macaddress_spec.rb +12 -0
- data/spec/unit/memory_spec.rb +53 -122
- data/spec/unit/netmask_spec.rb +11 -0
- data/spec/unit/operatingsystem_spec.rb +19 -0
- data/spec/unit/operatingsystemmajrelease_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +8 -0
- data/spec/unit/osfamily_spec.rb +62 -0
- data/spec/unit/partitions_spec.rb +48 -0
- data/spec/unit/physicalprocessorcount_spec.rb +9 -0
- data/spec/unit/processor_spec.rb +15 -7
- data/spec/unit/util/config_spec.rb +13 -0
- data/spec/unit/util/dhcp_servers_spec.rb +63 -0
- data/spec/unit/util/ec2_spec.rb +4 -0
- data/spec/unit/util/formatter_spec.rb +50 -0
- data/spec/unit/util/loader_spec.rb +4 -4
- data/spec/unit/util/macosx_spec.rb +3 -2
- data/spec/unit/util/manufacturer_spec.rb +44 -0
- data/spec/unit/util/operatingsystem_spec.rb +92 -0
- data/spec/unit/util/partitions/partitions_spec.rb +67 -0
- data/spec/unit/util/partitions_spec.rb +19 -0
- data/spec/unit/util/posix_spec.rb +11 -0
- data/spec/unit/util/values_spec.rb +40 -0
- data/spec/unit/util/virtual_spec.rb +72 -2
- data/spec/unit/virtual_spec.rb +67 -18
- metadata +116 -4
- data/spec/fixtures/unit/util/loader/nosuchfact.rb +0 -1
@@ -50,4 +50,20 @@ describe "Kernel release fact" do
|
|
50
50
|
Facter.fact(:kernelrelease).value.should == "test_kernel"
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
describe 'on OpenBSD' do
|
55
|
+
before do
|
56
|
+
Facter.fact(:kernel).stubs(:value).returns :openbsd
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'parses 5.3-current sysctl output' do
|
60
|
+
Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3-current'))
|
61
|
+
Facter.value(:kernelrelease).should == '5.3-current'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'parses 5.3 sysctl output' do
|
65
|
+
Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3'))
|
66
|
+
Facter.value(:kernelrelease).should == '5.3'
|
67
|
+
end
|
68
|
+
end
|
53
69
|
end
|
@@ -58,4 +58,16 @@ describe "macaddress fact" do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
describe "when run on OpenBSD with bridge(4) rules" do
|
62
|
+
it "should return macaddress information" do
|
63
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
64
|
+
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
65
|
+
Facter::Util::IP.stubs(:exec_ifconfig).
|
66
|
+
returns(ifconfig_fixture('openbsd_bridge_rules'))
|
67
|
+
|
68
|
+
proc { Facter.value(:macaddress) }.should_not raise_error
|
69
|
+
Facter.value(:macaddress).should be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
end
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -48,24 +48,9 @@ describe "Memory facts" do
|
|
48
48
|
before(:each) do
|
49
49
|
Facter.clear
|
50
50
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
51
|
-
Facter::
|
52
|
-
|
53
|
-
|
54
|
-
Pages free: 28430.
|
55
|
-
Pages active: 1152576.
|
56
|
-
Pages inactive: 489054.
|
57
|
-
Pages speculative: 7076.
|
58
|
-
Pages wired down: 418217.
|
59
|
-
"Translation faults": 1340091228.
|
60
|
-
Pages copy-on-write: 16851357.
|
61
|
-
Pages zero filled: 665168768.
|
62
|
-
Pages reactivated: 3082708.
|
63
|
-
Pageins: 13862917.
|
64
|
-
Pageouts: 1384383.
|
65
|
-
Object cache: 14 hits of 2619925 lookups (0% hit rate)
|
66
|
-
VMSTAT
|
67
|
-
Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(sample_vm_stat)
|
68
|
-
Facter::Core::Execution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 1.00M free = 63.00M (encrypted)")
|
51
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.memsize').returns('8589934592')
|
52
|
+
Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(my_fixture_read('darwin-vm_stat'))
|
53
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swapusage').returns("vm.swapusage: total = 64.00M used = 1.00M free = 63.00M (encrypted)")
|
69
54
|
|
70
55
|
Facter.collection.internal_loader.load(:memory)
|
71
56
|
end
|
@@ -104,20 +89,10 @@ VMSTAT
|
|
104
89
|
before(:each) do
|
105
90
|
Facter.clear
|
106
91
|
Facter.fact(:kernel).stubs(:value).returns(kernel)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Cached: 115124 kB
|
112
|
-
SwapCached: 0 kB
|
113
|
-
Active: 92700 kB
|
114
|
-
Inactive: 63792 kB
|
115
|
-
SwapTotal: 524280 kB
|
116
|
-
SwapFree: 524280 kB
|
117
|
-
Dirty: 4 kB
|
118
|
-
INFO
|
119
|
-
|
120
|
-
File.stubs(:readlines).with("/proc/meminfo").returns(meminfo.split("\n"))
|
92
|
+
|
93
|
+
meminfo_contents = my_fixture_read('linux-proc_meminfo').split("\n")
|
94
|
+
|
95
|
+
File.stubs(:readlines).with("/proc/meminfo").returns(meminfo_contents)
|
121
96
|
|
122
97
|
Facter.collection.internal_loader.load(:memory)
|
123
98
|
end
|
@@ -149,26 +124,8 @@ INFO
|
|
149
124
|
Facter.clear
|
150
125
|
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
151
126
|
|
152
|
-
|
153
|
-
|
154
|
-
/dev/hd6 10, 2 512MB 508MB
|
155
|
-
SWAP
|
156
|
-
|
157
|
-
Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
|
158
|
-
|
159
|
-
svmon = <<SVMON
|
160
|
-
Unit: KB
|
161
|
-
--------------------------------------------------------------------------------------
|
162
|
-
size inuse free pin virtual available mmode
|
163
|
-
memory 32768000 9948408 22819592 2432080 4448928 27231828 Ded
|
164
|
-
pg space 34078720 15000
|
165
|
-
|
166
|
-
work pers clnt other
|
167
|
-
pin 1478228 0 0 953852
|
168
|
-
in use 4448928 0 5499480
|
169
|
-
SVMON
|
170
|
-
|
171
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon)
|
127
|
+
Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(my_fixture_read('aix-swap_l'))
|
128
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(my_fixture_read('aix-svmon'))
|
172
129
|
|
173
130
|
Facter.collection.internal_loader.load(:memory)
|
174
131
|
end
|
@@ -221,17 +178,13 @@ SVMON
|
|
221
178
|
Facter.clear
|
222
179
|
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
223
180
|
|
224
|
-
swapusage = "total:
|
181
|
+
swapusage = "total: 4080510 512-blocks allocated, 461832 used, 3618678 available"
|
225
182
|
Facter::Core::Execution.stubs(:exec).with('swapctl -s').returns(swapusage)
|
226
183
|
|
227
|
-
vmstat
|
228
|
-
procs memory page disks traps cpu
|
229
|
-
r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id
|
230
|
-
0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100
|
231
|
-
EOS
|
232
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
184
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('openbsd-vmstat'))
|
233
185
|
|
234
|
-
Facter::
|
186
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns('267321344')
|
187
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swapencrypt.enable').returns('1')
|
235
188
|
|
236
189
|
Facter.collection.internal_loader.load(:memory)
|
237
190
|
end
|
@@ -241,11 +194,11 @@ EOS
|
|
241
194
|
end
|
242
195
|
|
243
196
|
it "should return the current swap free in MB" do
|
244
|
-
Facter.fact(:swapfree_mb).value.should == "
|
197
|
+
Facter.fact(:swapfree_mb).value.should == "1766.93"
|
245
198
|
end
|
246
199
|
|
247
200
|
it "should return the current swap size in MB" do
|
248
|
-
Facter.fact(:swapsize_mb).value.should == "
|
201
|
+
Facter.fact(:swapsize_mb).value.should == "1992.44"
|
249
202
|
end
|
250
203
|
|
251
204
|
it "should return the current memory free in MB" do
|
@@ -255,26 +208,20 @@ EOS
|
|
255
208
|
it "should return the current memory size in MB" do
|
256
209
|
Facter.fact(:memorysize_mb).value.should == "254.94"
|
257
210
|
end
|
211
|
+
|
212
|
+
it "should return whether swap is encrypted" do
|
213
|
+
Facter.fact(:swapencrypted).value.should == true
|
214
|
+
end
|
258
215
|
end
|
259
216
|
|
217
|
+
|
260
218
|
describe "on Solaris" do
|
261
219
|
before(:each) do
|
262
220
|
Facter.clear
|
263
221
|
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
264
|
-
sample_prtconf = <<PRTCONF
|
265
|
-
System Configuration: Sun Microsystems sun4u
|
266
|
-
Memory size: 2048 Megabytes
|
267
|
-
System Peripherals (Software Nodes):
|
268
|
-
|
269
|
-
PRTCONF
|
270
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns sample_prtconf
|
271
222
|
|
272
|
-
|
273
|
-
|
274
|
-
r b w swap free re mf pi po fr de sr s0 s3 -- -- in sy cs us sy id
|
275
|
-
0 0 0 1154552 476224 8 19 0 0 0 0 0 0 0 0 0 460 294 236 1 2 97
|
276
|
-
VMSTAT
|
277
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat_lines)
|
223
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns(my_fixture_read('solaris-prtconf'))
|
224
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('solaris-vmstat'))
|
278
225
|
end
|
279
226
|
|
280
227
|
after(:each) do
|
@@ -283,11 +230,7 @@ VMSTAT
|
|
283
230
|
|
284
231
|
describe "when single swap exists" do
|
285
232
|
before(:each) do
|
286
|
-
|
287
|
-
swapfile dev swaplo blocks free
|
288
|
-
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
289
|
-
SWAP
|
290
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
233
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-single')
|
291
234
|
|
292
235
|
Facter.collection.internal_loader.load(:memory)
|
293
236
|
end
|
@@ -307,16 +250,12 @@ SWAP
|
|
307
250
|
it "should return the current swap size in MB" do
|
308
251
|
Facter.fact(:swapsize_mb).value.should == "1023.99"
|
309
252
|
end
|
253
|
+
|
310
254
|
end
|
311
255
|
|
312
256
|
describe "when multiple swaps exist" do
|
313
257
|
before(:each) do
|
314
|
-
|
315
|
-
swapfile dev swaplo blocks free
|
316
|
-
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
317
|
-
/dev/swap2 4294967295,4294967295 16 2097136 2097136
|
318
|
-
SWAP
|
319
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
258
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-multiple')
|
320
259
|
Facter.collection.internal_loader.load(:memory)
|
321
260
|
end
|
322
261
|
|
@@ -360,6 +299,22 @@ SWAP
|
|
360
299
|
Facter.fact(:swapsize_mb).value.should == "0.00"
|
361
300
|
end
|
362
301
|
end
|
302
|
+
|
303
|
+
describe "when in a SmartOS zone" do
|
304
|
+
before(:each) do
|
305
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('smartos_zone_swap_l-single')
|
306
|
+
Facter.collection.internal_loader.load(:memory)
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should return the current swap size in MB" do
|
310
|
+
Facter.fact(:swapsize_mb).value.should == "49152.00"
|
311
|
+
end
|
312
|
+
|
313
|
+
it "should return the current swap free in MB" do
|
314
|
+
Facter.fact(:swapfree_mb).value.should == "33676.06"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
363
318
|
end
|
364
319
|
|
365
320
|
describe "on DragonFly BSD" do
|
@@ -368,19 +323,14 @@ SWAP
|
|
368
323
|
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
369
324
|
|
370
325
|
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
371
|
-
Facter::
|
372
|
-
Facter::
|
373
|
-
Facter::
|
374
|
-
Facter::
|
326
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.pagesize').returns("4096")
|
327
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_size').returns("128461")
|
328
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_anon_use').returns("2635")
|
329
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_cache_use').returns("0")
|
375
330
|
|
376
|
-
vmstat
|
377
|
-
procs memory page disks faults cpu
|
378
|
-
r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id
|
379
|
-
0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9
|
380
|
-
EOS
|
381
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
331
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns my_fixture_read('dragonfly-vmstat')
|
382
332
|
|
383
|
-
Facter::
|
333
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.physmem").returns('248512512')
|
384
334
|
|
385
335
|
Facter.collection.internal_loader.load(:memory)
|
386
336
|
end
|
@@ -411,16 +361,8 @@ EOS
|
|
411
361
|
Facter.clear
|
412
362
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
413
363
|
|
414
|
-
|
415
|
-
|
416
|
-
r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id
|
417
|
-
1 0 0 207600 656640 10 0 0 0 13 0 0 0 51 164 257 0 1 99
|
418
|
-
VM_STAT
|
419
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns sample_vmstat
|
420
|
-
sample_physmem = <<PHYSMEM
|
421
|
-
1056276480
|
422
|
-
PHYSMEM
|
423
|
-
Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns sample_physmem
|
364
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns my_fixture_read('freebsd-vmstat')
|
365
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns '1056276480'
|
424
366
|
end
|
425
367
|
|
426
368
|
after(:each) do
|
@@ -429,11 +371,9 @@ PHYSMEM
|
|
429
371
|
|
430
372
|
describe "with no swap" do
|
431
373
|
before(:each) do
|
432
|
-
sample_swapinfo =
|
433
|
-
Device 1K-blocks Used Avail Capacity
|
434
|
-
SWAP
|
435
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
374
|
+
sample_swapinfo = 'Device 1K-blocks Used Avail Capacity'
|
436
375
|
|
376
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
437
377
|
Facter.collection.internal_loader.load(:memory)
|
438
378
|
end
|
439
379
|
|
@@ -456,11 +396,7 @@ SWAP
|
|
456
396
|
|
457
397
|
describe "with one swap" do
|
458
398
|
before(:each) do
|
459
|
-
|
460
|
-
Device 1K-blocks Used Avail Capacity
|
461
|
-
/dev/da0p3 2048540 0 1048540 0%
|
462
|
-
SWAP
|
463
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
399
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-single')
|
464
400
|
|
465
401
|
Facter.collection.internal_loader.load(:memory)
|
466
402
|
end
|
@@ -484,12 +420,7 @@ SWAP
|
|
484
420
|
|
485
421
|
describe "with multiple swaps" do
|
486
422
|
before(:each) do
|
487
|
-
|
488
|
-
Device 1K-blocks Used Avail Capacity
|
489
|
-
/dev/da0p3 2048540 0 1048540 0%
|
490
|
-
/dev/da0p4 3048540 0 1048540 0%
|
491
|
-
SWAP
|
492
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
423
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-multiple')
|
493
424
|
|
494
425
|
Facter.collection.internal_loader.load(:memory)
|
495
426
|
end
|
data/spec/unit/netmask_spec.rb
CHANGED
@@ -27,6 +27,17 @@ describe "The netmask fact" do
|
|
27
27
|
"ifconfig_ubuntu_1204.txt"
|
28
28
|
end
|
29
29
|
|
30
|
+
context "on AIX" do
|
31
|
+
before :each do
|
32
|
+
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
33
|
+
end
|
34
|
+
|
35
|
+
example_behavior_for "netmask from ifconfig output",
|
36
|
+
"AIX 7", "255.255.255.0",
|
37
|
+
"ifconfig_aix_7.txt"
|
38
|
+
|
39
|
+
end
|
40
|
+
|
30
41
|
context "on Darwin" do
|
31
42
|
before :each do
|
32
43
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
@@ -58,6 +58,7 @@ describe "Operating System fact" do
|
|
58
58
|
"Debian" => "/etc/debian_version",
|
59
59
|
"Gentoo" => "/etc/gentoo-release",
|
60
60
|
"Fedora" => "/etc/fedora-release",
|
61
|
+
"Mageia" => "/etc/mageia-release",
|
61
62
|
"Mandriva" => "/etc/mandriva-release",
|
62
63
|
"Mandrake" => "/etc/mandrake-release",
|
63
64
|
"MeeGo" => "/etc/meego-release",
|
@@ -89,6 +90,13 @@ describe "Operating System fact" do
|
|
89
90
|
Facter.fact(:operatingsystem).value.should == "Ubuntu"
|
90
91
|
end
|
91
92
|
|
93
|
+
it "on LinuxMint should use the lsbdistid fact" do
|
94
|
+
FileUtils.stubs(:exists?).with("/etc/debian_version").returns true
|
95
|
+
|
96
|
+
Facter.stubs(:value).with(:lsbdistid).returns("LinuxMint")
|
97
|
+
Facter.fact(:operatingsystem).value.should == "LinuxMint"
|
98
|
+
end
|
99
|
+
|
92
100
|
end
|
93
101
|
|
94
102
|
|
@@ -137,5 +145,16 @@ describe "Operating System fact" do
|
|
137
145
|
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)")
|
138
146
|
Facter.fact(:operatingsystem).value.should == "SLC"
|
139
147
|
end
|
148
|
+
|
149
|
+
it "should identify Cumulus Linux" do
|
150
|
+
Facter::Util::Operatingsystem.expects(:os_release).returns({'NAME' => 'Cumulus Linux'})
|
151
|
+
Facter.fact(:operatingsystem).value.should == "CumulusLinux"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should not use '/etc/os-release' on platforms other than Cumulus Linux" do
|
155
|
+
Facter::Util::Operatingsystem.expects(:os_release).returns({'NAME' => 'Debian GNU/Linux'})
|
156
|
+
FileTest.expects(:exists?).with('/etc/debian_version').returns true
|
157
|
+
Facter.fact(:operatingsystem).value.should == "Debian"
|
158
|
+
end
|
140
159
|
end
|
141
160
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
require 'facter'
|
4
4
|
|
5
5
|
describe "OS Major Release fact" do
|
6
|
-
['Amazon','CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC'].each do |operatingsystem|
|
6
|
+
['Amazon','CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux'].each do |operatingsystem|
|
7
7
|
context "on #{operatingsystem} operatingsystems" do
|
8
8
|
it "should be derived from operatingsystemrelease" do
|
9
9
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
@@ -17,6 +17,7 @@ describe "Operating System Release fact" do
|
|
17
17
|
"OpenWrt" => "/etc/openwrt_version",
|
18
18
|
"CentOS" => "/etc/redhat-release",
|
19
19
|
"RedHat" => "/etc/redhat-release",
|
20
|
+
"LinuxMint" => "/etc/linuxmint/info",
|
20
21
|
"Scientific" => "/etc/redhat-release",
|
21
22
|
"Fedora" => "/etc/fedora-release",
|
22
23
|
"MeeGo" => "/etc/meego-release",
|
@@ -225,4 +226,11 @@ describe "Operating System Release fact" do
|
|
225
226
|
Facter.fact(:operatingsystemrelease).value.should == "10.04"
|
226
227
|
end
|
227
228
|
end
|
229
|
+
|
230
|
+
it "uses '/etc/os-release for Cumulus Linux" do
|
231
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
232
|
+
Facter.fact(:operatingsystem).stubs(:value).returns("CumulusLinux")
|
233
|
+
Facter::Util::Operatingsystem.expects(:os_release).returns({'VERSION_ID' => '1.5.0'})
|
234
|
+
Facter.fact(:operatingsystemrelease).value.should == "1.5.0"
|
235
|
+
end
|
228
236
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "OS Family fact" do
|
6
|
+
|
7
|
+
{
|
8
|
+
'Archlinux' => 'Archlinux',
|
9
|
+
'SmartOS' => 'Solaris',
|
10
|
+
'OpenIndiana' => 'Solaris',
|
11
|
+
'OmniOS' => 'Solaris',
|
12
|
+
'Nexenta' => 'Solaris',
|
13
|
+
'Solaris' => 'Solaris',
|
14
|
+
'Ubuntu' => 'Debian',
|
15
|
+
'Debian' => 'Debian',
|
16
|
+
'LinuxMint' => 'Debian',
|
17
|
+
'Gentoo' => 'Gentoo',
|
18
|
+
'Fedora' => 'RedHat',
|
19
|
+
'Amazon' => 'RedHat',
|
20
|
+
'OracleLinux' => 'RedHat',
|
21
|
+
'OVS' => 'RedHat',
|
22
|
+
'OEL' => 'RedHat',
|
23
|
+
'CentOS' => 'RedHat',
|
24
|
+
'SLC' => 'RedHat',
|
25
|
+
'Scientific' => 'RedHat',
|
26
|
+
'CloudLinux' => 'RedHat',
|
27
|
+
'PSBM' => 'RedHat',
|
28
|
+
'Ascendos' => 'RedHat',
|
29
|
+
'XenServer' => 'RedHat',
|
30
|
+
'RedHat' => 'RedHat',
|
31
|
+
'SLES' => 'Suse',
|
32
|
+
'SLED' => 'Suse',
|
33
|
+
'OpenSuSE' => 'Suse',
|
34
|
+
'SuSE' => 'Suse',
|
35
|
+
'Mageia' => 'Mandrake',
|
36
|
+
'Mandriva' => 'Mandrake',
|
37
|
+
'Mandrake' => 'Mandrake',
|
38
|
+
}.each do |os,family|
|
39
|
+
it "should return #{family} on operatingsystem #{os}" do
|
40
|
+
Facter.fact(:operatingsystem).stubs(:value).returns os
|
41
|
+
Facter.fact(:osfamily).value.should == family
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
[
|
46
|
+
'MeeGo',
|
47
|
+
'VMWareESX',
|
48
|
+
'Bluewhite64',
|
49
|
+
'Slamd64',
|
50
|
+
'Slackware',
|
51
|
+
'Alpine',
|
52
|
+
'ESXi',
|
53
|
+
'windows',
|
54
|
+
'HP-UX'
|
55
|
+
].each do |os|
|
56
|
+
it "should return the kernel fact on operatingsystem #{os}" do
|
57
|
+
Facter.fact(:operatingsystem).stubs(:value).returns os
|
58
|
+
Facter.fact(:kernel).stubs(:value).returns 'random_kernel_fact'
|
59
|
+
Facter.fact(:osfamily).value.should == 'random_kernel_fact'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|