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
data/spec/unit/id_spec.rb
CHANGED
@@ -4,25 +4,25 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
4
4
|
|
5
5
|
describe "id fact" do
|
6
6
|
|
7
|
-
|
7
|
+
kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
kernel.each do |k|
|
10
|
+
describe "with kernel reported as #{k}" do
|
11
|
+
it "should return the current user" do
|
12
|
+
Facter.fact(:kernel).stubs(:value).returns(k)
|
13
|
+
Facter::Util::Config.stubs(:is_windows?).returns(k == 'windows')
|
14
|
+
Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
16
|
+
Facter.fact(:id).value.should == 'bar'
|
17
|
+
end
|
19
18
|
end
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
it "should return the current user on Solaris" do
|
22
|
+
Facter::Util::Config.stubs(:is_windows?).returns(false)
|
23
|
+
Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
|
24
|
+
Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar'
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
Facter.fact(:id).value.should == 'bar'
|
27
|
+
end
|
28
28
|
end
|
@@ -6,13 +6,13 @@ require 'facter'
|
|
6
6
|
require 'facter/util/ip'
|
7
7
|
|
8
8
|
describe "Per Interface IP facts" do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
it "should replace the ':' in an interface list with '_'" do
|
10
|
+
# So we look supported
|
11
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Facter::Util::IP.stubs(:get_interfaces).returns %w{eth0:1 eth1:2}
|
14
|
+
Facter.fact(:interfaces).value.should == %{eth0_1,eth1_2}
|
15
|
+
end
|
16
16
|
|
17
17
|
it "should replace non-alphanumerics in an interface list with '_'" do
|
18
18
|
Facter.fact(:kernel).stubs(:value).returns("windows")
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -5,146 +5,146 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
5
5
|
require 'facter'
|
6
6
|
|
7
7
|
describe "Memory facts" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
before do
|
9
|
+
# We need these facts loaded, but they belong to a file with a
|
10
|
+
# different name, so load the file explicitly.
|
11
|
+
Facter.collection.loader.load(:memory)
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
after do
|
15
|
+
Facter.clear
|
16
|
+
end
|
17
17
|
|
18
|
-
|
18
|
+
it "should return the current swap size" do
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
21
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
22
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
24
|
+
if swapusage =~ /total = (\S+).*/
|
25
|
+
Facter.fact(:swapfree).value.should == $1
|
27
26
|
end
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
it "should return the current swap free" do
|
30
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
31
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
32
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
34
|
+
if swapusage =~ /free = (\S+).*/
|
35
|
+
Facter.fact(:swapfree).value.should == $1
|
37
36
|
end
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
it "should return whether swap is encrypted" do
|
40
|
+
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
41
|
+
Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)")
|
42
|
+
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
swapusage =~ /\(encrypted\)/
|
45
|
+
Facter.fact(:swapencrypted).value.should == true
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
describe "on OpenBSD" do
|
49
|
+
before :each do
|
50
|
+
Facter.clear
|
51
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
54
|
+
Facter::Util::Resolution.stubs(:exec).with('swapctl -s').returns(swapusage)
|
55
55
|
|
56
|
-
|
57
|
-
procs
|
58
|
-
r b w
|
59
|
-
0 0 0 11048 181028 39 0 0 0 0 0 0 1
|
56
|
+
vmstat = <<EOS
|
57
|
+
procs memory page disks traps cpu
|
58
|
+
r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id
|
59
|
+
0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100
|
60
60
|
EOS
|
61
|
-
|
62
|
-
|
63
|
-
Facter::Util::Resolution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344')
|
61
|
+
Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat)
|
64
62
|
|
65
|
-
|
66
|
-
end
|
63
|
+
Facter::Util::Resolution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344')
|
67
64
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should return the current swap free" do
|
73
|
-
Facter.fact(:swapfree).value.should == "144.87 MB"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should return the current swap size" do
|
77
|
-
Facter.fact(:swapsize).value.should == "144.87 MB"
|
78
|
-
end
|
65
|
+
Facter.collection.loader.load(:memory)
|
66
|
+
end
|
79
67
|
|
80
|
-
|
81
|
-
|
82
|
-
end
|
68
|
+
after :each do
|
69
|
+
Facter.clear
|
83
70
|
end
|
84
71
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
72
|
+
it "should return the current swap free" do
|
73
|
+
Facter.fact(:swapfree).value.should == "144.87 MB"
|
74
|
+
end
|
89
75
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635")
|
94
|
-
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0")
|
76
|
+
it "should return the current swap size" do
|
77
|
+
Facter.fact(:swapsize).value.should == "144.87 MB"
|
78
|
+
end
|
95
79
|
|
96
|
-
|
97
|
-
|
98
|
-
|
80
|
+
it "should return the current memorysize" do
|
81
|
+
Facter.fact(:memorytotal).value.should == "254.94 MB"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "on DragonFly BSD" do
|
86
|
+
before :each do
|
87
|
+
Facter.clear
|
88
|
+
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
89
|
+
|
90
|
+
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
91
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096")
|
92
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461")
|
93
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635")
|
94
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0")
|
95
|
+
|
96
|
+
vmstat = <<EOS
|
97
|
+
procs memory page disks faults cpu
|
98
|
+
r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id
|
99
99
|
0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9
|
100
100
|
EOS
|
101
|
-
|
101
|
+
Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat)
|
102
102
|
|
103
|
-
|
103
|
+
Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512')
|
104
104
|
|
105
|
-
|
106
|
-
|
105
|
+
Facter.collection.loader.load(:memory)
|
106
|
+
end
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
after :each do
|
109
|
+
Facter.clear
|
110
|
+
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
it "should return the current swap free" do
|
113
|
+
Facter.fact(:swapfree).value.should == "491.51 MB"
|
114
|
+
end
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
it "should return the current swap size" do
|
117
|
+
Facter.fact(:swapsize).value.should == "501.80 MB"
|
118
|
+
end
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
end
|
120
|
+
it "should return the current memorysize" do
|
121
|
+
Facter.fact(:memorytotal).value.should == "237.00 MB"
|
123
122
|
end
|
123
|
+
end
|
124
124
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
describe "on Windows" do
|
126
|
+
before :each do
|
127
|
+
Facter.clear
|
128
|
+
Facter.fact(:kernel).stubs(:value).returns("windows")
|
129
|
+
Facter.collection.loader.load(:memory)
|
130
130
|
|
131
|
-
|
132
|
-
|
131
|
+
require 'facter/util/wmi'
|
132
|
+
end
|
133
133
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
it "should return free memory" do
|
135
|
+
os = stubs 'os'
|
136
|
+
os.stubs(:FreePhysicalMemory).returns("3415624")
|
137
|
+
Facter::Util::WMI.stubs(:execquery).returns([os])
|
138
138
|
|
139
|
-
|
140
|
-
|
139
|
+
Facter.fact(:MemoryFree).value.should == '3.26 GB'
|
140
|
+
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
it "should return total memory" do
|
143
|
+
computer = stubs 'computer'
|
144
|
+
computer.stubs(:TotalPhysicalMemory).returns("4193837056")
|
145
|
+
Facter::Util::WMI.stubs(:execquery).returns([computer])
|
146
146
|
|
147
|
-
|
148
|
-
end
|
147
|
+
Facter.fact(:MemoryTotal).value.should == '3.91 GB'
|
149
148
|
end
|
149
|
+
end
|
150
150
|
end
|
@@ -6,78 +6,87 @@ require 'facter'
|
|
6
6
|
|
7
7
|
describe "Operating System fact" do
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
before do
|
10
|
+
Facter.clear
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
after do
|
14
|
+
Facter.clear
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
it "should default to the kernel name" do
|
18
|
+
Facter.fact(:kernel).stubs(:value).returns("Nutmeg")
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
Facter.fact(:operatingsystem).value.should == "Nutmeg"
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
it "should be Solaris for SunOS" do
|
24
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
Facter.fact(:operatingsystem).value.should == "Solaris"
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
it "should be ESXi for VMkernel" do
|
30
|
+
Facter.fact(:kernel).stubs(:value).returns("VMkernel")
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
Facter.fact(:operatingsystem).value.should == "ESXi"
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
it "should identify Oracle VM as OVS" do
|
36
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
37
|
+
Facter.stubs(:value).with(:lsbdistid).returns(nil)
|
38
|
+
FileTest.stubs(:exists?).returns false
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
FileTest.expects(:exists?).with("/etc/ovs-release").returns true
|
41
|
+
FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
Facter.fact(:operatingsystem).value.should == "OVS"
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
46
|
+
it "should identify VMWare ESX" do
|
47
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
48
|
+
Facter.stubs(:value).with(:lsbdistid).returns(nil)
|
49
|
+
FileTest.stubs(:exists?).returns false
|
50
|
+
|
51
|
+
FileTest.expects(:exists?).with("/etc/vmware-release").returns true
|
52
|
+
|
53
|
+
Facter.fact(:operatingsystem).value.should == "VMWareESX"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should identify Alpine Linux" do
|
57
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
58
|
+
|
59
|
+
FileTest.stubs(:exists?).returns false
|
60
|
+
|
61
|
+
FileTest.expects(:exists?).with("/etc/alpine-release").returns true
|
62
|
+
|
63
|
+
Facter.fact(:operatingsystem).value.should == "Alpine"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should identify Scientific Linux" do
|
67
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
68
|
+
FileTest.stubs(:exists?).returns false
|
69
|
+
|
70
|
+
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
71
|
+
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux SLC 5.7 (Boron)")
|
72
|
+
Facter.fact(:operatingsystem).value.should == "Scientific"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should differentiate between Scientific Linux CERN and Scientific Linux" do
|
76
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
77
|
+
FileTest.stubs(:exists?).returns false
|
78
|
+
|
79
|
+
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
80
|
+
File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)")
|
81
|
+
Facter.fact(:operatingsystem).value.should == "SLC"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should identify Ascendos Linux" do
|
85
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
86
|
+
FileTest.stubs(:exists?).returns false
|
87
|
+
|
88
|
+
FileTest.expects(:exists?).with("/etc/redhat-release").returns true
|
89
|
+
File.expects(:read).with("/etc/redhat-release").returns("Ascendos release 6.0 (Nameless)")
|
90
|
+
Facter.fact(:operatingsystem).value.should == "Ascendos"
|
91
|
+
end
|
83
92
|
end
|