facter 1.5.8 → 1.5.9
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 +94 -0
- data/INSTALL +1 -1
- data/README +1 -1
- data/README.rst +3 -3
- data/Rakefile +9 -6
- data/bin/facter +18 -123
- data/conf/redhat/facter.spec +21 -3
- data/conf/solaris/pkginfo +2 -2
- data/install.rb +18 -10
- data/lib/facter.rb +27 -1
- data/lib/facter/application.rb +123 -0
- data/lib/facter/arp.rb +28 -0
- data/lib/facter/ec2.rb +32 -11
- data/lib/facter/hardwareisa.rb +1 -1
- data/lib/facter/id.rb +2 -9
- data/lib/facter/interfaces.rb +1 -1
- data/lib/facter/ipaddress.rb +2 -33
- data/lib/facter/ipaddress6.rb +68 -0
- data/lib/facter/lsb.rb +5 -5
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +4 -14
- data/lib/facter/manufacturer.rb +9 -0
- data/lib/facter/memory.rb +110 -6
- data/lib/facter/netmask.rb +1 -1
- data/lib/facter/operatingsystem.rb +17 -2
- data/lib/facter/operatingsystemrelease.rb +34 -0
- data/lib/facter/processor.rb +8 -5
- data/lib/facter/selinux.rb +37 -4
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/util/#uptime.rb# +64 -0
- data/lib/facter/util/ip.rb +23 -15
- data/lib/facter/util/loader.rb +2 -2
- data/lib/facter/util/macaddress.rb +28 -0
- data/lib/facter/util/manufacturer.rb +39 -2
- data/lib/facter/util/memory.rb +43 -0
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/resolution.rb +7 -0
- data/lib/facter/util/uptime.rb +11 -1
- data/lib/facter/util/virtual.rb +13 -2
- data/lib/facter/util/vlans.rb +2 -2
- data/lib/facter/util/xendomains.rb +10 -0
- data/lib/facter/virtual.rb +45 -13
- data/lib/facter/xendomains.rb +10 -0
- data/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces +18 -0
- data/spec/fixtures/ifconfig/centos_5_5 +17 -0
- data/spec/fixtures/ifconfig/centos_5_5_eth0 +8 -0
- data/spec/fixtures/ifconfig/darwin_10_3_0 +26 -0
- data/spec/fixtures/ifconfig/darwin_10_3_0_en0 +6 -0
- data/spec/fixtures/ifconfig/darwin_10_6_4 +28 -0
- data/spec/fixtures/ifconfig/darwin_10_6_4_en1 +6 -0
- data/spec/fixtures/ifconfig/darwin_10_6_6_dualstack +8 -0
- data/spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en1 +7 -0
- data/spec/fixtures/ifconfig/darwin_9_8_0 +26 -0
- data/spec/fixtures/ifconfig/darwin_9_8_0_en0 +6 -0
- data/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces +23 -0
- data/spec/fixtures/ifconfig/fedora_10 +36 -0
- data/spec/fixtures/ifconfig/fedora_10_eth0 +9 -0
- data/spec/fixtures/ifconfig/fedora_13 +18 -0
- data/spec/fixtures/ifconfig/fedora_13_eth0 +9 -0
- data/spec/fixtures/ifconfig/fedora_8 +38 -0
- data/spec/fixtures/ifconfig/fedora_8_eth0 +9 -0
- data/spec/fixtures/ifconfig/freebsd_6_0 +12 -0
- data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces +19 -0
- data/spec/fixtures/ifconfig/open_solaris_10 +12 -0
- data/spec/fixtures/ifconfig/open_solaris_b132 +20 -0
- data/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces +10 -0
- data/spec/fixtures/ifconfig/ubuntu_7_04 +38 -0
- data/spec/fixtures/ifconfig/ubuntu_7_04_eth0 +9 -0
- data/spec/fixtures/netstat/centos_5_5 +5 -0
- data/spec/fixtures/netstat/darwin_10_3_0 +35 -0
- data/spec/fixtures/netstat/darwin_10_6_4 +29 -0
- data/spec/fixtures/netstat/darwin_10_6_6_dualstack +34 -0
- data/spec/fixtures/netstat/darwin_9_8_0 +28 -0
- data/spec/fixtures/netstat/fedora_10 +7 -0
- data/spec/fixtures/netstat/open_solaris_10 +16 -0
- data/spec/fixtures/netstat/open_solaris_b132 +17 -0
- data/spec/fixtures/netstat/ubuntu_7_04 +7 -0
- data/spec/fixtures/uptime/kstat_boot_time +1 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_1/guest +37 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_1/host +36 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_3/guest +39 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_3/host +39 -0
- data/spec/integration/{facter.rb → facter_spec.rb} +1 -1
- data/spec/spec_helper.rb +8 -3
- data/spec/unit/data/debian_kfreebsd_ifconfig +40 -0
- data/spec/unit/data/hpux_netstat_all_interfaces +3 -6
- data/spec/unit/data/selinux_sestatus +6 -0
- data/spec/unit/data/xendomains +4 -0
- data/spec/unit/{facter.rb → facter_spec.rb} +28 -1
- data/spec/unit/id_spec.rb +27 -0
- data/spec/unit/{interfaces.rb → interfaces_spec.rb} +1 -1
- data/spec/unit/ipaddress6_spec.rb +36 -0
- data/spec/unit/memory_spec.rb +45 -0
- data/spec/unit/{operatingsystem.rb → operatingsystem_spec.rb} +22 -8
- data/spec/unit/operatingsystemrelease_spec.rb +49 -0
- data/spec/unit/selinux_spec.rb +89 -0
- data/spec/unit/{uptime.rb → uptime_spec.rb} +4 -4
- data/spec/unit/util/{collection.rb → collection_spec.rb} +1 -1
- data/spec/unit/util/{confine.rb → confine_spec.rb} +1 -1
- data/spec/unit/util/{fact.rb → fact_spec.rb} +1 -1
- data/spec/unit/util/{ip.rb → ip_spec.rb} +47 -12
- data/spec/unit/util/{loader.rb → loader_spec.rb} +51 -1
- data/spec/unit/util/macaddress_spec.rb +68 -0
- data/spec/unit/util/{macosx.rb → macosx_spec.rb} +1 -1
- data/spec/unit/util/{manufacturer.rb → manufacturer_spec.rb} +15 -4
- data/spec/unit/util/{resolution.rb → resolution_spec.rb} +1 -1
- data/spec/unit/util/uptime_spec.rb +73 -0
- data/spec/unit/util/{virtual.rb → virtual_spec.rb} +37 -3
- data/spec/unit/util/{vlans.rb → vlans_spec.rb} +1 -1
- data/spec/unit/util/xendomains_spec.rb +23 -0
- data/spec/unit/virtual_spec.rb +196 -0
- metadata +149 -98
- data/spec/Rakefile +0 -18
- data/spec/unit/data/hpux_ifconfig +0 -3
- data/spec/unit/data/hpux_netscan +0 -4
- data/spec/unit/operatingsystemrelease.rb +0 -39
- data/spec/unit/selinux.rb +0 -48
- data/spec/unit/util/uptime.rb +0 -53
- data/spec/unit/virtual.rb +0 -71
@@ -0,0 +1,17 @@
|
|
1
|
+
Routing Table: IPv4
|
2
|
+
Destination Gateway Flags Ref Use Interface
|
3
|
+
-------------------- -------------------- ----- ----- ---------- ---------
|
4
|
+
default 202.78.241.102 UG 4 56215415
|
5
|
+
127.0.0.1 127.0.0.1 UH 2 15396 lo0
|
6
|
+
172.31.255.0 172.31.255.254 U 12 62487076 int0
|
7
|
+
202.78.241.96 202.78.241.97 U 6 2213722 bge0
|
8
|
+
|
9
|
+
Routing Table: IPv6
|
10
|
+
Destination/Mask Gateway Flags Ref Use If
|
11
|
+
--------------------------- --------------------------- ----- --- ------- -----
|
12
|
+
::1 ::1 UH 2 4 lo0
|
13
|
+
2404:130:40:10::/64 2404:130:40:10::ff:0 U 4 1050430 bge0
|
14
|
+
2404:130:40:18::/64 2404:130:40:18::ff:0 U 4 1302106 int0
|
15
|
+
fe80::/10 fe80::ff:0 U 3 16283 int0
|
16
|
+
fe80::/10 fe80::ff:0 U 5 314822 bge0
|
17
|
+
default fe80::20d:edff:fe9d:782e UG 2 420100 bge0
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Kernel IP routing table
|
2
|
+
Destination Gateway Genmask Flags MSS Window irtt Iface
|
3
|
+
100.100.106.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
|
4
|
+
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 ath0
|
5
|
+
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
|
6
|
+
0.0.0.0 100.100.106.1 0.0.0.0 UG 0 0 0 eth0
|
7
|
+
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ath0
|
@@ -0,0 +1 @@
|
|
1
|
+
unix:0:system_misc:boot_time 1236919980
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Name: cat
|
2
|
+
State: R (running)
|
3
|
+
SleepAVG: 58%
|
4
|
+
Tgid: 24671
|
5
|
+
Pid: 24671
|
6
|
+
PPid: 24670
|
7
|
+
TracerPid: 0
|
8
|
+
Uid: 0 0 0 0
|
9
|
+
Gid: 0 0 0 0
|
10
|
+
FDSize: 32
|
11
|
+
Groups: 0
|
12
|
+
VmPeak: 1580 kB
|
13
|
+
VmSize: 1580 kB
|
14
|
+
VmLck: 0 kB
|
15
|
+
VmHWM: 372 kB
|
16
|
+
VmRSS: 372 kB
|
17
|
+
VmData: 152 kB
|
18
|
+
VmStk: 88 kB
|
19
|
+
VmExe: 16 kB
|
20
|
+
VmLib: 1280 kB
|
21
|
+
VmPTE: 12 kB
|
22
|
+
Threads: 1
|
23
|
+
SigQ: 0/4294967295
|
24
|
+
SigPnd: 0000000000000000
|
25
|
+
ShdPnd: 0000000000000000
|
26
|
+
SigBlk: 0000000000000000
|
27
|
+
SigIgn: 0000000000000000
|
28
|
+
SigCgt: 0000000000000000
|
29
|
+
CapInh: 0000000000000000
|
30
|
+
CapPrm: 00000000344c04ff
|
31
|
+
CapEff: 00000000344c04ff
|
32
|
+
s_context: 40074
|
33
|
+
ctxflags: 1602020010
|
34
|
+
initpid: 0
|
35
|
+
ipv4root: 4a00007f/ffffffff 4a24f6d5/00ffffff
|
36
|
+
ipv4root_bcast: 00000000
|
37
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Name: cat
|
2
|
+
State: R (running)
|
3
|
+
SleepAVG: 88%
|
4
|
+
Tgid: 24625
|
5
|
+
Pid: 24625
|
6
|
+
PPid: 24618
|
7
|
+
TracerPid: 0
|
8
|
+
Uid: 47000 47000 47000 47000
|
9
|
+
Gid: 4733 4733 4733 4733
|
10
|
+
FDSize: 32
|
11
|
+
Groups: 0 4733
|
12
|
+
VmPeak: 1768 kB
|
13
|
+
VmSize: 1768 kB
|
14
|
+
VmLck: 0 kB
|
15
|
+
VmHWM: 396 kB
|
16
|
+
VmRSS: 396 kB
|
17
|
+
VmData: 160 kB
|
18
|
+
VmStk: 88 kB
|
19
|
+
VmExe: 28 kB
|
20
|
+
VmLib: 1468 kB
|
21
|
+
VmPTE: 12 kB
|
22
|
+
Threads: 1
|
23
|
+
SigQ: 0/4294967295
|
24
|
+
SigPnd: 0000000000000000
|
25
|
+
ShdPnd: 0000000000000000
|
26
|
+
SigBlk: 0000000000000000
|
27
|
+
SigIgn: 0000000000000000
|
28
|
+
SigCgt: 0000000000000000
|
29
|
+
CapInh: 0000000000000000
|
30
|
+
CapPrm: 0000000000000000
|
31
|
+
CapEff: 0000000000000000
|
32
|
+
s_context: 0
|
33
|
+
ctxflags: none
|
34
|
+
initpid: none
|
35
|
+
ipv4root: 0
|
36
|
+
ipv4root_bcast: 0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Name: cat
|
2
|
+
State: R (running)
|
3
|
+
Tgid: 21149
|
4
|
+
Pid: 21149
|
5
|
+
PPid: 21142
|
6
|
+
TracerPid: 0
|
7
|
+
Uid: 0 0 0 0
|
8
|
+
Gid: 0 0 0 0
|
9
|
+
FDSize: 64
|
10
|
+
Groups: 0
|
11
|
+
VmPeak: 1564 kB
|
12
|
+
VmSize: 1564 kB
|
13
|
+
VmLck: 0 kB
|
14
|
+
VmHWM: 384 kB
|
15
|
+
VmRSS: 384 kB
|
16
|
+
VmData: 160 kB
|
17
|
+
VmStk: 84 kB
|
18
|
+
VmExe: 16 kB
|
19
|
+
VmLib: 1284 kB
|
20
|
+
VmPTE: 20 kB
|
21
|
+
Threads: 1
|
22
|
+
SigQ: 0/71680
|
23
|
+
SigPnd: 0000000000000000
|
24
|
+
ShdPnd: 0000000000000000
|
25
|
+
SigBlk: 0000000000000000
|
26
|
+
SigIgn: 0000000000000000
|
27
|
+
SigCgt: 0000000000000000
|
28
|
+
CapInh: 0000000000000000
|
29
|
+
CapPrm: fffffffffffffeff
|
30
|
+
CapEff: fffffffffffffeff
|
31
|
+
CapBnd: fffffffffffffeff
|
32
|
+
Cpus_allowed: ff
|
33
|
+
Cpus_allowed_list: 0-7
|
34
|
+
Mems_allowed: 1
|
35
|
+
Mems_allowed_list: 0
|
36
|
+
VxID: 40128
|
37
|
+
NxID: 40128
|
38
|
+
voluntary_ctxt_switches: 1
|
39
|
+
nonvoluntary_ctxt_switches: 0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Name: cat
|
2
|
+
State: R (running)
|
3
|
+
Tgid: 21074
|
4
|
+
Pid: 21074
|
5
|
+
PPid: 21020
|
6
|
+
TracerPid: 0
|
7
|
+
Uid: 47000 47000 47000 47000
|
8
|
+
Gid: 4733 4733 4733 4733
|
9
|
+
FDSize: 64
|
10
|
+
Groups: 0 4733
|
11
|
+
VmPeak: 3800 kB
|
12
|
+
VmSize: 3800 kB
|
13
|
+
VmLck: 0 kB
|
14
|
+
VmHWM: 468 kB
|
15
|
+
VmRSS: 468 kB
|
16
|
+
VmData: 176 kB
|
17
|
+
VmStk: 84 kB
|
18
|
+
VmExe: 32 kB
|
19
|
+
VmLib: 1432 kB
|
20
|
+
VmPTE: 28 kB
|
21
|
+
Threads: 1
|
22
|
+
SigQ: 0/71680
|
23
|
+
SigPnd: 0000000000000000
|
24
|
+
ShdPnd: 0000000000000000
|
25
|
+
SigBlk: 0000000000000000
|
26
|
+
SigIgn: 0000000000000000
|
27
|
+
SigCgt: 0000000000000000
|
28
|
+
CapInh: 0000000000000000
|
29
|
+
CapPrm: 0000000000000000
|
30
|
+
CapEff: 0000000000000000
|
31
|
+
CapBnd: fffffffffffffeff
|
32
|
+
Cpus_allowed: ff
|
33
|
+
Cpus_allowed_list: 0-7
|
34
|
+
Mems_allowed: 1
|
35
|
+
Mems_allowed_list: 0
|
36
|
+
VxID: 0
|
37
|
+
NxID: 0
|
38
|
+
voluntary_ctxt_switches: 2
|
39
|
+
nonvoluntary_ctxt_switches: 0
|
data/spec/spec_helper.rb
CHANGED
@@ -7,12 +7,17 @@ $LOAD_PATH.unshift("#{dir}/../lib")
|
|
7
7
|
|
8
8
|
require 'rubygems'
|
9
9
|
require 'mocha'
|
10
|
-
require '
|
10
|
+
require 'rspec'
|
11
11
|
require 'facter'
|
12
12
|
|
13
13
|
# load any monkey-patches
|
14
14
|
Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file }
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.mock_with :mocha
|
18
|
+
|
19
|
+
# Ensure that we don't accidentally cache between test cases.
|
20
|
+
config.before :each do
|
21
|
+
Facter.clear
|
22
|
+
end
|
18
23
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
2
|
+
options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
|
3
|
+
ether 0:11:a:59:67:90
|
4
|
+
inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1
|
5
|
+
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
|
6
|
+
media: Ethernet autoselect (1000baseT <full-duplex>)
|
7
|
+
status: active
|
8
|
+
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
9
|
+
options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
|
10
|
+
ether 0:11:a:59:67:91
|
11
|
+
inet6 fe80::211:aff:fe59:6791%em1 prefixlen 64 scopeid 0x2
|
12
|
+
inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255
|
13
|
+
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
|
14
|
+
media: Ethernet autoselect (100baseTX <full-duplex>)
|
15
|
+
status: active
|
16
|
+
bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
17
|
+
options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
|
18
|
+
ether 0:14:c2:3f:ea:e4
|
19
|
+
media: Ethernet autoselect (none)
|
20
|
+
status: no carrier
|
21
|
+
bge1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
22
|
+
options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
|
23
|
+
ether 0:14:c2:3f:ea:e3
|
24
|
+
media: Ethernet autoselect (none)
|
25
|
+
status: no carrier
|
26
|
+
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
|
27
|
+
options=3<RXCSUM,TXCSUM>
|
28
|
+
inet6 ::1 prefixlen 128
|
29
|
+
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
|
30
|
+
inet 127.0.0.1 netmask 0xff000000
|
31
|
+
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
|
32
|
+
vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
33
|
+
options=3<RXCSUM,TXCSUM>
|
34
|
+
ether 0:11:a:59:67:90
|
35
|
+
inet6 fe80::211:aff:fe59:6790%vlan0 prefixlen 64 scopeid 0x6
|
36
|
+
inet 192.168.192.2 netmask 0xffffff00 broadcast 192.168.192.255
|
37
|
+
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
|
38
|
+
media: Ethernet autoselect (1000baseT <full-duplex>)
|
39
|
+
status: active
|
40
|
+
vlan: 192 parent interface: em0
|
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
lan0 1500 172.54.85.0 host2.default.com
|
5
|
-
519222647 0 329127145 0 0
|
6
|
-
lo0 4136 loopback localhost 14281117 0 14281125 0 0
|
1
|
+
lan1 1500 192.168.100.0 192.168.100.182 12964 0 900 0 0
|
2
|
+
lan0 1500 192.168.100.0 192.168.100.181 12964 0 715 0 0
|
3
|
+
lo0 4136 127.0.0.0 127.0.0.1 98 0 98 0 0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
4
|
|
5
5
|
describe Facter do
|
6
6
|
|
@@ -135,6 +135,14 @@ describe Facter do
|
|
135
135
|
Facter.should respond_to(:debugging?)
|
136
136
|
end
|
137
137
|
|
138
|
+
it "should have a method to query timing mode" do
|
139
|
+
Facter.should respond_to(:timing?)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should have a method to show timing information" do
|
143
|
+
Facter.should respond_to(:show_time)
|
144
|
+
end
|
145
|
+
|
138
146
|
it "should have a method to warn" do
|
139
147
|
Facter.should respond_to(:warn)
|
140
148
|
end
|
@@ -204,6 +212,25 @@ describe Facter do
|
|
204
212
|
end
|
205
213
|
end
|
206
214
|
|
215
|
+
describe "when setting timing mode" do
|
216
|
+
it "should have timing enabled using 1" do
|
217
|
+
Facter.timing(1)
|
218
|
+
Facter.should be_timing
|
219
|
+
end
|
220
|
+
it "should have timing enabled using true" do
|
221
|
+
Facter.timing(true)
|
222
|
+
Facter.should be_timing
|
223
|
+
end
|
224
|
+
it "should have timing disabled using 0" do
|
225
|
+
Facter.timing(0)
|
226
|
+
Facter.should_not be_timing
|
227
|
+
end
|
228
|
+
it "should have timing disabled using false" do
|
229
|
+
Facter.timing(false)
|
230
|
+
Facter.should_not be_timing
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
207
234
|
describe "when registering directories to search" do
|
208
235
|
after { Facter.instance_variable_set("@search_path", []) }
|
209
236
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
describe "id fact" do
|
6
|
+
|
7
|
+
kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ]
|
8
|
+
|
9
|
+
kernel.each do |k|
|
10
|
+
describe "with kernel reported as #{k}" do
|
11
|
+
it "should return the current user" do
|
12
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns(k)
|
13
|
+
Facter::Util::Resolution.stubs(:exec).with('lsb_release -a 2>/dev/null').returns('foo')
|
14
|
+
Facter::Util::Resolution.expects(:exec).once.with('whoami', '/bin/sh').returns 'bar'
|
15
|
+
|
16
|
+
Facter.fact(:id).value.should == 'bar'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return the current user on Solaris" do
|
22
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
|
23
|
+
Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un', '/bin/sh').returns 'bar'
|
24
|
+
|
25
|
+
Facter.fact(:id).value.should == 'bar'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$basedir = File.expand_path(File.dirname(__FILE__) + '/..')
|
4
|
+
require File.join($basedir, 'spec_helper')
|
5
|
+
|
6
|
+
require 'facter'
|
7
|
+
|
8
|
+
def ifconfig_fixture(filename)
|
9
|
+
ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "IPv6 address fact" do
|
13
|
+
it "should return ipaddress6 information for Darwin" do
|
14
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Darwin')
|
15
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a').
|
16
|
+
returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces'))
|
17
|
+
|
18
|
+
Facter.value(:ipaddress6).should == "2610:10:20:209:223:32ff:fed5:ee34"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return ipaddress6 information for Linux" do
|
22
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux')
|
23
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig').
|
24
|
+
returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces'))
|
25
|
+
|
26
|
+
Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return ipaddress6 information for Solaris" do
|
30
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
|
31
|
+
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/ifconfig -a').
|
32
|
+
returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces'))
|
33
|
+
|
34
|
+
Facter.value(:ipaddress6).should == "2610:10:20:209:203:baff:fe27:a7c"
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
require 'facter'
|
6
|
+
|
7
|
+
describe "Memory facts" do
|
8
|
+
before do
|
9
|
+
Facter.loadfacts
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
Facter.clear
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return the current swap size" do
|
17
|
+
|
18
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
19
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
20
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
21
|
+
|
22
|
+
if swapusage =~ /total = (\S+).*/
|
23
|
+
Facter.fact(:swapfree).value.should == $1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the current swap free" do
|
28
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
29
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
30
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
31
|
+
|
32
|
+
if swapusage =~ /free = (\S+).*/
|
33
|
+
Facter.fact(:swapfree).value.should == $1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return whether swap is encrypted" do
|
38
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
39
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
40
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
41
|
+
|
42
|
+
swapusage =~ /\(encrypted\)/
|
43
|
+
Facter.fact(:swapencrypted).value.should == true
|
44
|
+
end
|
45
|
+
end
|