facter 1.6.16 → 1.6.17.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.
- data/ext/build_defaults.yaml +1 -1
- data/ext/osx/file_mapping.yaml +2 -2
- data/lib/facter/ec2.rb +3 -1
- data/lib/facter/ipaddress.rb +7 -12
- data/lib/facter/util/ec2.rb +40 -0
- data/lib/facter/util/ip.rb +64 -6
- data/lib/facter/util/processor.rb +1 -1
- data/lib/facter/version.rb +1 -1
- data/spec/fixtures/ifconfig/linux_ifconfig_no_addr +19 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_lanscan +5 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan +5 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_lanscan +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan +9 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in +6 -0
- data/spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond0 +19 -0
- data/spec/fixtures/unit/util/processor/x86-pentium2 +41 -0
- data/spec/unit/ec2_spec.rb +12 -12
- data/spec/unit/ipaddress_spec.rb +32 -0
- data/spec/unit/util/ec2_spec.rb +26 -0
- data/spec/unit/util/ip_spec.rb +152 -51
- data/spec/unit/util/processor_spec.rb +70 -52
- metadata +74 -42
- data/spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface +0 -3
- data/spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces +0 -3
data/ext/build_defaults.yaml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
|
3
3
|
packaging_repo: 'packaging'
|
4
4
|
default_cow: 'base-squeeze-i386.cow'
|
5
|
-
cows: 'base-lucid-i386.cow base-natty-i386.cow base-oneiric-i386.cow base-precise-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
|
5
|
+
cows: 'base-lucid-i386.cow base-natty-i386.cow base-oneiric-i386.cow base-precise-i386.cow base-quantal-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
|
6
6
|
pbuild_conf: '/etc/pbuilderrc'
|
7
7
|
packager: 'puppetlabs'
|
8
8
|
gpg_name: 'info@puppetlabs.com'
|
data/ext/osx/file_mapping.yaml
CHANGED
@@ -10,12 +10,12 @@ directories:
|
|
10
10
|
group: 'wheel'
|
11
11
|
perms: '0755'
|
12
12
|
facter:
|
13
|
-
path: 'var/lib/facter'
|
13
|
+
path: 'private/var/lib/facter'
|
14
14
|
owner: 'root'
|
15
15
|
group: 'wheel'
|
16
16
|
perms: '0644'
|
17
17
|
etc:
|
18
|
-
path: 'etc'
|
18
|
+
path: 'private/etc'
|
19
19
|
owner: 'root'
|
20
20
|
group: 'wheel'
|
21
21
|
perms: '0644'
|
data/lib/facter/ec2.rb
CHANGED
data/lib/facter/ipaddress.rb
CHANGED
@@ -22,23 +22,18 @@
|
|
22
22
|
# checking this is a useful IP address.
|
23
23
|
#
|
24
24
|
|
25
|
+
require 'facter/util/ip'
|
26
|
+
|
25
27
|
Facter.add(:ipaddress) do
|
26
28
|
confine :kernel => :linux
|
27
29
|
setcode do
|
28
30
|
ip = nil
|
29
|
-
output =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
tmp = $1
|
34
|
-
unless tmp =~ /^127\./
|
35
|
-
ip = tmp
|
36
|
-
break
|
37
|
-
end
|
31
|
+
if output = Facter::Util::IP.get_ifconfig
|
32
|
+
regexp = /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
33
|
+
if match = regexp.match(output)
|
34
|
+
match[1] unless /^127/.match(match[1])
|
38
35
|
end
|
39
|
-
|
40
|
-
|
41
|
-
ip
|
36
|
+
end
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
data/lib/facter/util/ec2.rb
CHANGED
@@ -58,4 +58,44 @@ module Facter::Util::EC2
|
|
58
58
|
return false
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# userdata returns a single string containing the body of the response of the
|
64
|
+
# GET request for the URI http://169.254.169.254/latest/user-data/ If the
|
65
|
+
# metadata server responds with a 404 Not Found error code then this method
|
66
|
+
# retuns `nil`.
|
67
|
+
#
|
68
|
+
# @param version [String] containing the API version for the request.
|
69
|
+
# Defaults to "latest" and other examples are documented at
|
70
|
+
# http://aws.amazon.com/archives/Amazon%20EC2
|
71
|
+
#
|
72
|
+
# @api public
|
73
|
+
#
|
74
|
+
# @return [String] containing the response body or `nil`
|
75
|
+
def self.userdata(version="latest")
|
76
|
+
uri = "http://169.254.169.254/#{version}/user-data/"
|
77
|
+
begin
|
78
|
+
read_uri(uri)
|
79
|
+
rescue OpenURI::HTTPError => detail
|
80
|
+
case detail.message
|
81
|
+
when /404 Not Found/i
|
82
|
+
Facter.debug "No user-data present at #{uri}: server responded with #{detail.message}"
|
83
|
+
return nil
|
84
|
+
else
|
85
|
+
raise detail
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# read_uri provides a seam method to easily test the HTTP client
|
92
|
+
# functionality of a HTTP based metadata server.
|
93
|
+
#
|
94
|
+
# @api private
|
95
|
+
#
|
96
|
+
# @return [String] containing the body of the response
|
97
|
+
def self.read_uri(uri)
|
98
|
+
open(uri).read
|
99
|
+
end
|
100
|
+
private_class_method :read_uri
|
61
101
|
end
|
data/lib/facter/util/ip.rb
CHANGED
@@ -81,7 +81,14 @@ module Facter::Util::IP
|
|
81
81
|
when 'SunOS'
|
82
82
|
output = %x{/usr/sbin/ifconfig -a}
|
83
83
|
when 'HP-UX'
|
84
|
-
|
84
|
+
# (#17487)[https://projects.puppetlabs.com/issues/17487]
|
85
|
+
# Handle NIC bonding where asterisks and virtual NICs are printed.
|
86
|
+
if output = hpux_netstat_in
|
87
|
+
output.gsub!(/\*/, "") # delete asterisks.
|
88
|
+
output.gsub!(/^[^\n]*none[^\n]*\n/, "") # delete lines with 'none' instead of IPs.
|
89
|
+
output.sub!(/^[^\n]*\n/, "") # delete the header line.
|
90
|
+
output
|
91
|
+
end
|
85
92
|
when 'windows'
|
86
93
|
output = %x|#{ENV['SYSTEMROOT']}/system32/netsh.exe interface ip show interface|
|
87
94
|
output += %x|#{ENV['SYSTEMROOT']}/system32/netsh.exe interface ipv6 show interface|
|
@@ -89,6 +96,21 @@ module Facter::Util::IP
|
|
89
96
|
output
|
90
97
|
end
|
91
98
|
|
99
|
+
##
|
100
|
+
# get_ifconfig simply delegates to the ifconfig command.
|
101
|
+
#
|
102
|
+
# @return [String] the output of `/sbin/ifconfig 2>/dev/null` or nil
|
103
|
+
def self.get_ifconfig
|
104
|
+
Facter::Util::Resolution.exec("/sbin/ifconfig 2>/dev/null")
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# hpux_netstat_in is a delegate method that allows us to stub netstat -in
|
109
|
+
# without stubbing exec.
|
110
|
+
def self.hpux_netstat_in
|
111
|
+
Facter::Util::Resolution.exec("/bin/netstat -in")
|
112
|
+
end
|
113
|
+
|
92
114
|
def self.get_infiniband_macaddress(interface)
|
93
115
|
if File.exists?("/sys/class/net/#{interface}/address") then
|
94
116
|
ib_mac_address = `cat /sys/class/net/#{interface}/address`.chomp
|
@@ -123,14 +145,22 @@ module Facter::Util::IP
|
|
123
145
|
output = %x{/usr/sbin/ifconfig #{interface}}
|
124
146
|
when 'HP-UX'
|
125
147
|
mac = ""
|
126
|
-
ifc =
|
127
|
-
|
148
|
+
ifc = hpux_ifconfig_interface(interface)
|
149
|
+
hpux_lanscan.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| mac = i[0] if i.include?(interface) }
|
128
150
|
mac = mac.sub(/0x(\S+)/,'\1').scan(/../).join(":")
|
129
151
|
output = ifc + "\n" + mac
|
130
152
|
end
|
131
153
|
output
|
132
154
|
end
|
133
155
|
|
156
|
+
def self.hpux_ifconfig_interface(interface)
|
157
|
+
Facter::Util::Resolution.exec("/usr/sbin/ifconfig #{interface}")
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.hpux_lanscan
|
161
|
+
Facter::Util::Resolution.exec("/usr/sbin/lanscan")
|
162
|
+
end
|
163
|
+
|
134
164
|
def self.get_output_for_interface_and_label(interface, label)
|
135
165
|
return get_single_interface_output(interface) unless Facter.value(:kernel) == 'windows'
|
136
166
|
|
@@ -168,6 +198,19 @@ module Facter::Util::IP
|
|
168
198
|
device
|
169
199
|
end
|
170
200
|
|
201
|
+
##
|
202
|
+
# get_interface_value obtains the value of a specific attribute of a specific
|
203
|
+
# interface.
|
204
|
+
#
|
205
|
+
# @param interface [String] the interface identifier, e.g. "eth0" or "bond0"
|
206
|
+
#
|
207
|
+
# @param label [String] the attribute of the interface to obtain a value for,
|
208
|
+
# e.g. "netmask" or "ipaddress"
|
209
|
+
#
|
210
|
+
# @api private
|
211
|
+
#
|
212
|
+
# @return [String] representing the requested value. An empty array is
|
213
|
+
# returned if the kernel is not supported by the REGEX_MAP constant.
|
171
214
|
def self.get_interface_value(interface, label)
|
172
215
|
tmp1 = []
|
173
216
|
|
@@ -186,9 +229,11 @@ module Facter::Util::IP
|
|
186
229
|
# We have to dig a bit to get the original/real MAC address of the interface.
|
187
230
|
bonddev = get_bonding_master(interface)
|
188
231
|
if label == 'macaddress' and bonddev
|
189
|
-
bondinfo =
|
190
|
-
|
191
|
-
|
232
|
+
bondinfo = read_proc_net_bonding("/proc/net/bonding/#{bonddev}")
|
233
|
+
re = /^Slave Interface: #{interface}\b.*?\bPermanent HW addr: (([0-9A-F]{2}:?)*)$/im
|
234
|
+
if match = re.match(bondinfo)
|
235
|
+
value = match[1].upcase
|
236
|
+
end
|
192
237
|
else
|
193
238
|
output_int = get_output_for_interface_and_label(interface, label)
|
194
239
|
|
@@ -208,6 +253,19 @@ module Facter::Util::IP
|
|
208
253
|
end
|
209
254
|
end
|
210
255
|
|
256
|
+
##
|
257
|
+
# read_proc_net_bonding is a seam method for mocking purposes.
|
258
|
+
#
|
259
|
+
# @param path [String] representing the path to read, e.g. "/proc/net/bonding/bond0"
|
260
|
+
#
|
261
|
+
# @api private
|
262
|
+
#
|
263
|
+
# @return [String] modeling the raw file read
|
264
|
+
def self.read_proc_net_bonding(path)
|
265
|
+
File.read(path) if File.exists?(path)
|
266
|
+
end
|
267
|
+
private_class_method :read_proc_net_bonding
|
268
|
+
|
211
269
|
def self.get_network_value(interface)
|
212
270
|
require 'ipaddr'
|
213
271
|
|
@@ -217,7 +217,7 @@ module Processor
|
|
217
217
|
if File.exists?(cpuinfo)
|
218
218
|
model = Facter.value(:architecture)
|
219
219
|
case model
|
220
|
-
when "x86_64", "amd64", "i386", /parisc/, "hppa", "ia64"
|
220
|
+
when "x86_64", "amd64", "i386", "x86", /parisc/, "hppa", "ia64"
|
221
221
|
Thread::exclusive do
|
222
222
|
File.readlines(cpuinfo).each do |l|
|
223
223
|
if l =~ /processor\s+:\s+(\d+)/
|
data/lib/facter/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
2
|
+
inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255
|
3
|
+
inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0<global>
|
4
|
+
inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20<link>
|
5
|
+
ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet)
|
6
|
+
RX packets 27222144 bytes 31247414760 (29.1 GiB)
|
7
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
8
|
+
TX packets 10259038 bytes 7784519352 (7.2 GiB)
|
9
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
10
|
+
device interrupt 20 memory 0xd2600000-d2620000
|
11
|
+
|
12
|
+
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
|
13
|
+
inet 127.0.0.1 netmask 255.0.0.0
|
14
|
+
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
15
|
+
loop txqueuelen 0 (Local Loopback)
|
16
|
+
RX packets 257371 bytes 37104110 (35.3 MiB)
|
17
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
18
|
+
TX packets 257371 bytes 37104110 (35.3 MiB)
|
19
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
2
|
+
inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255
|
3
|
+
inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0<global>
|
4
|
+
inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20<link>
|
5
|
+
ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet)
|
6
|
+
RX packets 27222144 bytes 31247414760 (29.1 GiB)
|
7
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
8
|
+
TX packets 10259038 bytes 7784519352 (7.2 GiB)
|
9
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
10
|
+
device interrupt 20 memory 0xd2600000-d2620000
|
11
|
+
|
12
|
+
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
|
13
|
+
inet 127.0.0.1 netmask 255.0.0.0
|
14
|
+
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
15
|
+
loop txqueuelen 0 (Local Loopback)
|
16
|
+
RX packets 257371 bytes 37104110 (35.3 MiB)
|
17
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
18
|
+
TX packets 257371 bytes 37104110 (35.3 MiB)
|
19
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
eth0 Link encap:Ethernet HWaddr 42:01:0a:57:50:6e
|
2
|
+
inet addr:10.87.80.110 Bcast:10.87.80.110 Mask:255.255.255.255
|
3
|
+
UP BROADCAST RUNNING MULTICAST MTU:1460 Metric:1
|
4
|
+
RX packets:1609444 errors:0 dropped:0 overruns:0 frame:0
|
5
|
+
TX packets:1479569 errors:0 dropped:0 overruns:0 carrier:0
|
6
|
+
collisions:0 txqueuelen:1000
|
7
|
+
RX bytes:673812693 (673.8 MB) TX bytes:221186872 (221.1 MB)
|
8
|
+
|
9
|
+
lo Link encap:Local Loopback
|
10
|
+
inet addr:127.0.0.1 Mask:255.0.0.0
|
11
|
+
UP LOOPBACK RUNNING MTU:16436 Metric:1
|
12
|
+
RX packets:5435415 errors:0 dropped:0 overruns:0 frame:0
|
13
|
+
TX packets:5435415 errors:0 dropped:0 overruns:0 carrier:0
|
14
|
+
collisions:0 txqueuelen:0
|
15
|
+
RX bytes:734540224 (734.5 MB) TX bytes:734540224 (734.5 MB)
|
16
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
|
2
|
+
Path Address In# State NamePPA ID Type Support Mjr#
|
3
|
+
0/0/0/0 0x00307F0C79DC 0 UP lan0 snap0 1 ETHER Yes 119
|
4
|
+
0/10/0/0/6/0 0x0010797B5CDE 1 UP lan1 snap1 2 ETHER Yes 119
|
5
|
+
0/10/0/0/7/0 0x0010797B5CDF 2 UP lan2 snap2 3 ETHER Yes 119
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
|
2
|
+
Path Address In# State NamePPA ID Type Support Mjr#
|
3
|
+
0/0/0/0 0x00305D0626B2 0 UP lan0 snap0 1 ETHER Yes 119
|
4
|
+
0/4/2/0/6/0 0x0010797BBE46 1 UP lan1 snap1 2 ETHER Yes 119
|
5
|
+
0/4/2/0/7/0 0x0010797BBE47 2 DOWN lan2 snap2 3 ETHER Yes 119
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
|
2
|
+
Path Address In# State NamePPA ID Type Support Mjr#
|
3
|
+
0/1/2/0 0x001319BD1C2D 0 UP lan0 snap0 1 ETHER Yes 119
|
4
|
+
0/2/1/0 0x0012819E48DE 1 UP lan1 snap1 2 ETHER Yes 119
|
5
|
+
0/2/1/1 0x0012819E48DF 2 UP lan2 snap2 3 ETHER Yes 119
|
6
|
+
0/4/2/0/6/0 0x001165EB7385 5 UP lan5 snap5 4 ETHER Yes 119
|
7
|
+
0/5/2/0/6/0 0x001165EB73E6 3 UP lan3 snap3 5 ETHER Yes 119
|
8
|
+
0/6/1/0 0x0012819E4A7E 4 UP lan4 snap4 6 ETHER Yes 119
|
9
|
+
0/6/1/1 0x0012819E4A7F 6 UP lan6 snap6 7 ETHER Yes 119
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
|
2
|
+
lan4:1 1500 192.168.1.0 192.168.1.197 121 0 6 0 0
|
3
|
+
lan3* 1500 none none 0 0 0 0 0
|
4
|
+
lan1 1500 192.168.30.0 192.168.30.32 211188606 0 132070934 0 0
|
5
|
+
lo0 4136 127.0.0.0 127.0.0.1 513508160 0 513509185 0 0
|
6
|
+
lan4 1500 192.168.32.0 192.168.32.75 2640827721 0 2257447701 0 0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)
|
2
|
+
|
3
|
+
Bonding Mode: fault-tolerance (active-backup)
|
4
|
+
Primary Slave: None
|
5
|
+
Currently Active Slave: eth0
|
6
|
+
MII Status: up
|
7
|
+
MII Polling Interval (ms): 100
|
8
|
+
Up Delay (ms): 200
|
9
|
+
Down Delay (ms): 200
|
10
|
+
|
11
|
+
Slave Interface: eth1
|
12
|
+
MII Status: up
|
13
|
+
Link Failure Count: 0
|
14
|
+
Permanent HW addr: 00:11:22:33:44:56
|
15
|
+
|
16
|
+
Slave Interface: eth0
|
17
|
+
MII Status: up
|
18
|
+
Link Failure Count: 0
|
19
|
+
Permanent HW addr: 00:11:22:33:44:55
|
@@ -0,0 +1,41 @@
|
|
1
|
+
processor : 0
|
2
|
+
vendor_id : GenuineIntel
|
3
|
+
cpu family : 6
|
4
|
+
model : 5
|
5
|
+
model name : Pentium II (Deschutes)
|
6
|
+
stepping : 1
|
7
|
+
cpu MHz : 333.379
|
8
|
+
cache size : 512 KB
|
9
|
+
fdiv_bug : no
|
10
|
+
hlt_bug : no
|
11
|
+
f00f_bug : no
|
12
|
+
coma_bug : no
|
13
|
+
fpu : yes
|
14
|
+
fpu_exception : yes
|
15
|
+
cpuid level : 2
|
16
|
+
wp : yes
|
17
|
+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr
|
18
|
+
bogomips : 667.53
|
19
|
+
clflush size : 32
|
20
|
+
power management:
|
21
|
+
|
22
|
+
processor : 1
|
23
|
+
vendor_id : GenuineIntel
|
24
|
+
cpu family : 6
|
25
|
+
model : 5
|
26
|
+
model name : Pentium II (Deschutes)
|
27
|
+
stepping : 1
|
28
|
+
cpu MHz : 333.379
|
29
|
+
cache size : 512 KB
|
30
|
+
fdiv_bug : no
|
31
|
+
hlt_bug : no
|
32
|
+
f00f_bug : no
|
33
|
+
coma_bug : no
|
34
|
+
fpu : yes
|
35
|
+
fpu_exception : yes
|
36
|
+
cpuid level : 2
|
37
|
+
wp : yes
|
38
|
+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr
|
39
|
+
bogomips : 666.44
|
40
|
+
clflush size : 32
|
41
|
+
power management:
|
data/spec/unit/ec2_spec.rb
CHANGED
@@ -68,9 +68,9 @@ describe "ec2 facts" do
|
|
68
68
|
with("#{api_prefix}/2008-02-01/meta-data/").
|
69
69
|
at_least_once.returns(StringIO.new(""))
|
70
70
|
|
71
|
-
Facter::Util::
|
72
|
-
with("#{api_prefix}/
|
73
|
-
|
71
|
+
Facter::Util::EC2.stubs(:read_uri).
|
72
|
+
with("#{api_prefix}/latest/user-data/").
|
73
|
+
returns("test")
|
74
74
|
|
75
75
|
Facter.collection.loader.load(:ec2)
|
76
76
|
Facter.fact(:ec2_userdata).value.should == ["test"]
|
@@ -94,9 +94,9 @@ describe "ec2 facts" do
|
|
94
94
|
with("#{api_prefix}/2008-02-01/meta-data/").\
|
95
95
|
at_least_once.returns(StringIO.new(""))
|
96
96
|
|
97
|
-
Facter::Util::
|
98
|
-
with("#{api_prefix}/
|
99
|
-
|
97
|
+
Facter::Util::EC2.stubs(:read_uri).
|
98
|
+
with("#{api_prefix}/latest/user-data/").
|
99
|
+
returns("test")
|
100
100
|
|
101
101
|
# Force a fact load
|
102
102
|
Facter.collection.loader.load(:ec2)
|
@@ -122,9 +122,9 @@ describe "ec2 facts" do
|
|
122
122
|
with("#{api_prefix}/2008-02-01/meta-data/").\
|
123
123
|
at_least_once.returns(StringIO.new(""))
|
124
124
|
|
125
|
-
Facter::Util::
|
126
|
-
with("#{api_prefix}/
|
127
|
-
|
125
|
+
Facter::Util::EC2.stubs(:read_uri).
|
126
|
+
with("#{api_prefix}/latest/user-data/").
|
127
|
+
returns("test")
|
128
128
|
|
129
129
|
# Force a fact load
|
130
130
|
Facter.collection.loader.load(:ec2)
|
@@ -140,9 +140,9 @@ describe "ec2 facts" do
|
|
140
140
|
with("#{api_prefix}/2008-02-01/meta-data/").
|
141
141
|
at_least_once.raises(RuntimeError, 'host unreachable')
|
142
142
|
|
143
|
-
Facter::Util::
|
144
|
-
with("#{api_prefix}/
|
145
|
-
|
143
|
+
Facter::Util::EC2.stubs(:read_uri).
|
144
|
+
with("#{api_prefix}/latest/user-data/").
|
145
|
+
raises(RuntimeError, 'host unreachable')
|
146
146
|
|
147
147
|
# Force a fact load
|
148
148
|
Facter.collection.loader.load(:ec2)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter/util/ip'
|
5
|
+
|
6
|
+
shared_examples_for "ifconfig output" do |platform, address, fixture|
|
7
|
+
it "correctly on #{platform}" do
|
8
|
+
Facter::Util::IP.stubs(:get_ifconfig).returns(my_fixture_read(fixture))
|
9
|
+
subject.value.should == address
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.alias_it_should_behave_like_to :example_behavior_for, "parses"
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "The ipaddress fact" do
|
18
|
+
subject do
|
19
|
+
Facter.collection.loader.load(:ipaddress)
|
20
|
+
Facter.fact(:ipaddress)
|
21
|
+
end
|
22
|
+
context "on Linux" do
|
23
|
+
before :each do
|
24
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
25
|
+
end
|
26
|
+
|
27
|
+
example_behavior_for "ifconfig output",
|
28
|
+
"Ubuntu 12.04", "10.87.80.110", "ifconfig_ubuntu_1204.txt"
|
29
|
+
example_behavior_for "ifconfig output",
|
30
|
+
"Fedora 17", "131.252.209.153", "ifconfig_net_tools_1.60.txt"
|
31
|
+
end
|
32
|
+
end
|
data/spec/unit/util/ec2_spec.rb
CHANGED
@@ -151,4 +151,30 @@ describe Facter::Util::EC2 do
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
|
+
|
155
|
+
describe "Facter::Util::EC2.userdata" do
|
156
|
+
let :not_found_error do
|
157
|
+
OpenURI::HTTPError.new("404 Not Found", StringIO.new)
|
158
|
+
end
|
159
|
+
|
160
|
+
let :example_userdata do
|
161
|
+
"owner=jeff@puppetlabs.com\ngroup=platform_team"
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'returns nil when no userdata is present' do
|
165
|
+
Facter::Util::EC2.stubs(:read_uri).raises(not_found_error)
|
166
|
+
Facter::Util::EC2.userdata.should be_nil
|
167
|
+
end
|
168
|
+
|
169
|
+
it "returns the string containing the body" do
|
170
|
+
Facter::Util::EC2.stubs(:read_uri).returns(example_userdata)
|
171
|
+
Facter::Util::EC2.userdata.should == example_userdata
|
172
|
+
end
|
173
|
+
|
174
|
+
it "uses the specified API version" do
|
175
|
+
expected_uri = "http://169.254.169.254/2008-02-01/user-data/"
|
176
|
+
Facter::Util::EC2.expects(:read_uri).with(expected_uri).returns(example_userdata)
|
177
|
+
Facter::Util::EC2.userdata('2008-02-01').should == example_userdata
|
178
|
+
end
|
179
|
+
end
|
154
180
|
end
|
data/spec/unit/util/ip_spec.rb
CHANGED
@@ -42,12 +42,6 @@ describe Facter::Util::IP do
|
|
42
42
|
Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"]
|
43
43
|
end
|
44
44
|
|
45
|
-
it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do
|
46
|
-
hpux_netstat = my_fixture_read("hpux_netstat_all_interfaces")
|
47
|
-
Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat)
|
48
|
-
Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
|
49
|
-
end
|
50
|
-
|
51
45
|
it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do
|
52
46
|
kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig")
|
53
47
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig)
|
@@ -97,24 +91,6 @@ describe Facter::Util::IP do
|
|
97
91
|
Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0"
|
98
92
|
end
|
99
93
|
|
100
|
-
it "should return ipaddress information for HP-UX" do
|
101
|
-
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
102
|
-
|
103
|
-
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
104
|
-
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
105
|
-
|
106
|
-
Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should return macaddress information for HP-UX" do
|
110
|
-
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
111
|
-
|
112
|
-
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
113
|
-
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
114
|
-
|
115
|
-
Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7"
|
116
|
-
end
|
117
|
-
|
118
94
|
it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do
|
119
95
|
kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig")
|
120
96
|
|
@@ -124,24 +100,6 @@ describe Facter::Util::IP do
|
|
124
100
|
Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90"
|
125
101
|
end
|
126
102
|
|
127
|
-
it "should return netmask information for HP-UX" do
|
128
|
-
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
129
|
-
|
130
|
-
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
131
|
-
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
132
|
-
|
133
|
-
Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should return calculated network information for HP-UX" do
|
137
|
-
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
138
|
-
|
139
|
-
Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
140
|
-
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
141
|
-
|
142
|
-
Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0"
|
143
|
-
end
|
144
|
-
|
145
103
|
it "should return interface information for FreeBSD supported via an alias" do
|
146
104
|
ifconfig_interface = my_fixture_read("6.0-STABLE_FreeBSD_ifconfig")
|
147
105
|
|
@@ -178,15 +136,6 @@ describe Facter::Util::IP do
|
|
178
136
|
Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
|
179
137
|
end
|
180
138
|
|
181
|
-
it "should return a human readable netmask on HP-UX" do
|
182
|
-
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
183
|
-
|
184
|
-
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
185
|
-
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
186
|
-
|
187
|
-
Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
|
188
|
-
end
|
189
|
-
|
190
139
|
it "should return a human readable netmask on Darwin" do
|
191
140
|
darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface")
|
192
141
|
|
@@ -292,6 +241,135 @@ describe Facter::Util::IP do
|
|
292
241
|
Facter::Util::IP.get_interface_value("e1000g0", "mtu").should == "1500"
|
293
242
|
end
|
294
243
|
|
244
|
+
# (#17487) - tests for HP-UX.
|
245
|
+
# some fake data for testing robustness of regexps.
|
246
|
+
def self.fake_netstat_in_examples
|
247
|
+
examples = []
|
248
|
+
examples << ["Header row\na line with none in it\na line without\nanother line without\n",
|
249
|
+
"a line without\nanother line without\n"]
|
250
|
+
examples << ["Header row\na line without\na line with none in it\nanother line with none\nanother line without\n",
|
251
|
+
"a line without\nanother line without\n"]
|
252
|
+
examples << ["Header row\na line with * asterisks *\na line with none in it\nanother line without\n",
|
253
|
+
"a line with asterisks \nanother line without\n"]
|
254
|
+
examples << ["a line with none none none in it\na line with none in it\na line without\nanother line without\n",
|
255
|
+
"another line without\n"]
|
256
|
+
examples
|
257
|
+
end
|
258
|
+
|
259
|
+
fake_netstat_in_examples.each_with_index do |example, i|
|
260
|
+
input, expected_output = example
|
261
|
+
it "should pass regexp test on fake netstat input example #{i}" do
|
262
|
+
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
263
|
+
Facter::Util::IP.stubs(:hpux_netstat_in).returns(input)
|
264
|
+
Facter::Util::IP.get_all_interface_output().should == expected_output
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
# and some real data for exhaustive tests.
|
269
|
+
def self.hpux_examples
|
270
|
+
examples = []
|
271
|
+
examples << ["HP-UX 11.11",
|
272
|
+
["lan1", "lan0", "lo0" ],
|
273
|
+
["1500", "1500", "4136" ],
|
274
|
+
["10.1.1.6", "192.168.3.10", "127.0.0.1"],
|
275
|
+
["255.255.255.0", "255.255.255.0", "255.0.0.0"],
|
276
|
+
["00:10:79:7B:5C:DE", "00:30:7F:0C:79:DC", nil ],
|
277
|
+
[my_fixture_read("hpux_1111_ifconfig_lan1"),
|
278
|
+
my_fixture_read("hpux_1111_ifconfig_lan0"),
|
279
|
+
my_fixture_read("hpux_1111_ifconfig_lo0")],
|
280
|
+
my_fixture_read("hpux_1111_netstat_in"),
|
281
|
+
my_fixture_read("hpux_1111_lanscan")]
|
282
|
+
|
283
|
+
examples << ["HP-UX 11.31",
|
284
|
+
["lan1", "lan0", "lo0" ],
|
285
|
+
["1500", "1500", "4136" ],
|
286
|
+
["10.1.54.36", "192.168.30.152", "127.0.0.1"],
|
287
|
+
["255.255.255.0", "255.255.255.0", "255.0.0.0"],
|
288
|
+
["00:17:FD:2D:2A:57", "00:12:31:7D:62:09", nil ],
|
289
|
+
[my_fixture_read("hpux_1131_ifconfig_lan1"),
|
290
|
+
my_fixture_read("hpux_1131_ifconfig_lan0"),
|
291
|
+
my_fixture_read("hpux_1131_ifconfig_lo0")],
|
292
|
+
my_fixture_read("hpux_1131_netstat_in"),
|
293
|
+
my_fixture_read("hpux_1131_lanscan")]
|
294
|
+
|
295
|
+
examples << ["HP-UX 11.31 with an asterisk after a NIC that has an address",
|
296
|
+
["lan1", "lan0", "lo0" ],
|
297
|
+
["1500", "1500", "4136" ],
|
298
|
+
["10.10.0.5", "192.168.3.9", "127.0.0.1"],
|
299
|
+
["255.255.255.0", "255.255.255.0", "255.0.0.0"],
|
300
|
+
["00:10:79:7B:BE:46", "00:30:5D:06:26:B2", nil ],
|
301
|
+
[my_fixture_read("hpux_1131_asterisk_ifconfig_lan1"),
|
302
|
+
my_fixture_read("hpux_1131_asterisk_ifconfig_lan0"),
|
303
|
+
my_fixture_read("hpux_1131_asterisk_ifconfig_lo0")],
|
304
|
+
my_fixture_read("hpux_1131_asterisk_netstat_in"),
|
305
|
+
my_fixture_read("hpux_1131_asterisk_lanscan")]
|
306
|
+
|
307
|
+
examples << ["HP-UX 11.31 with NIC bonding and one virtual NIC",
|
308
|
+
["lan4:1", "lan1", "lo0", "lan4" ],
|
309
|
+
["1500", "1500", "4136", "1500" ],
|
310
|
+
["192.168.1.197", "192.168.30.32", "127.0.0.1", "192.168.32.75" ],
|
311
|
+
["255.255.255.0", "255.255.255.0", "255.0.0.0", "255.255.255.0" ],
|
312
|
+
[nil, "00:12:81:9E:48:DE", nil, "00:12:81:9E:4A:7E"],
|
313
|
+
[my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan4_1"),
|
314
|
+
my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan1"),
|
315
|
+
my_fixture_read("hpux_1131_nic_bonding_ifconfig_lo0"),
|
316
|
+
my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan4")],
|
317
|
+
my_fixture_read("hpux_1131_nic_bonding_netstat_in"),
|
318
|
+
my_fixture_read("hpux_1131_nic_bonding_lanscan")]
|
319
|
+
examples
|
320
|
+
end
|
321
|
+
|
322
|
+
hpux_examples.each do |example|
|
323
|
+
description, array_of_expected_ifs, array_of_expected_mtus,
|
324
|
+
array_of_expected_ips, array_of_expected_netmasks,
|
325
|
+
array_of_expected_macs, array_of_ifconfig_fixtures,
|
326
|
+
netstat_in_fixture, lanscan_fixture = example
|
327
|
+
|
328
|
+
it "should return a list three interfaces on #{description}" do
|
329
|
+
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
330
|
+
Facter::Util::IP.stubs(:hpux_netstat_in).returns(netstat_in_fixture)
|
331
|
+
Facter::Util::IP.get_interfaces().should == array_of_expected_ifs
|
332
|
+
end
|
333
|
+
|
334
|
+
array_of_expected_ifs.each_with_index do |nic, i|
|
335
|
+
ifconfig_fixture = array_of_ifconfig_fixtures[i]
|
336
|
+
expected_mtu = array_of_expected_mtus[i]
|
337
|
+
expected_ip = array_of_expected_ips[i]
|
338
|
+
expected_netmask = array_of_expected_netmasks[i]
|
339
|
+
expected_mac = array_of_expected_macs[i]
|
340
|
+
|
341
|
+
# (#17808) These tests fail because MTU facts haven't been implemented for HP-UX.
|
342
|
+
#it "should return MTU #{expected_mtu} on #{nic} for #{description} example" do
|
343
|
+
# Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
344
|
+
# Facter::Util::IP.stubs(:hpux_netstat_in).returns(netstat_in_fixture)
|
345
|
+
# Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture)
|
346
|
+
# Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture)
|
347
|
+
# Facter::Util::IP.get_interface_value(nic, "mtu").should == expected_mtu
|
348
|
+
#end
|
349
|
+
|
350
|
+
it "should return IP #{expected_ip} on #{nic} for #{description} example" do
|
351
|
+
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
352
|
+
Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture)
|
353
|
+
Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture)
|
354
|
+
Facter::Util::IP.get_interface_value(nic, "ipaddress").should == expected_ip
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should return netmask #{expected_netmask} on #{nic} for #{description} example" do
|
358
|
+
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
359
|
+
Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture)
|
360
|
+
Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture)
|
361
|
+
Facter::Util::IP.get_interface_value(nic, "netmask").should == expected_netmask
|
362
|
+
end
|
363
|
+
|
364
|
+
it "should return MAC address #{expected_mac} on #{nic} for #{description} example" do
|
365
|
+
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
366
|
+
Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture)
|
367
|
+
Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture)
|
368
|
+
Facter::Util::IP.get_interface_value(nic, "macaddress").should == expected_mac
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
295
373
|
describe "on Windows" do
|
296
374
|
before :each do
|
297
375
|
Facter.stubs(:value).with(:kernel).returns("windows")
|
@@ -330,4 +408,27 @@ describe Facter::Util::IP do
|
|
330
408
|
Facter::Util::IP.get_interface_value("Teredo Tunneling Pseudo-Interface", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527"
|
331
409
|
end
|
332
410
|
end
|
411
|
+
|
412
|
+
context "with bonded ethernet interfaces on Linux" do
|
413
|
+
before :each do
|
414
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
415
|
+
end
|
416
|
+
|
417
|
+
describe "Facter::Util::Ip.get_interface_value" do
|
418
|
+
before :each do
|
419
|
+
Facter::Util::IP.stubs(:read_proc_net_bonding).
|
420
|
+
with("/proc/net/bonding/bond0").
|
421
|
+
returns(my_fixture_read("linux_2_6_35_proc_net_bonding_bond0"))
|
422
|
+
|
423
|
+
Facter::Util::IP.stubs(:get_bonding_master).returns("bond0")
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'provides the real device macaddress for eth0' do
|
427
|
+
Facter::Util::IP.get_interface_value("eth0", "macaddress").should == "00:11:22:33:44:55"
|
428
|
+
end
|
429
|
+
it 'provides the real device macaddress for eth1' do
|
430
|
+
Facter::Util::IP.get_interface_value("eth1", "macaddress").should == "00:11:22:33:44:56"
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
333
434
|
end
|
@@ -8,68 +8,86 @@ def cpuinfo_fixture(filename)
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe Facter::Util::Processor do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
describe "on linux" do
|
12
|
+
before :each do
|
13
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
14
|
+
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
describe "with architecture amd64" do
|
18
|
+
before :each do
|
19
|
+
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual"))
|
22
|
+
it "should get the processor description from the amd64solo fixture" do
|
23
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64solo"))
|
24
|
+
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
27
|
+
it "should get the processor descriptions from the amd64dual fixture" do
|
28
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual"))
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
34
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64tri"))
|
30
|
+
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
31
|
+
Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
Facter::Util::Processor.enum_cpuinfo[2].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
39
|
-
end
|
34
|
+
it "should get the processor descriptions from the amd64tri fixture" do
|
35
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64tri"))
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad"))
|
37
|
+
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
38
|
+
Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
39
|
+
Facter::Util::Processor.enum_cpuinfo[2].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
40
|
+
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
it "should get the processor descriptions from the amd64quad fixture" do
|
43
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad"))
|
44
|
+
|
45
|
+
Facter::Util::Processor.enum_cpuinfo[0].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
|
46
|
+
Facter::Util::Processor.enum_cpuinfo[1].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
|
47
|
+
Facter::Util::Processor.enum_cpuinfo[2].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
|
48
|
+
Facter::Util::Processor.enum_cpuinfo[3].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
|
49
|
+
end
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
describe "with architecture x86" do
|
53
|
+
before :each do
|
54
|
+
Facter.fact(:architecture).stubs(:value).returns("x86")
|
55
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(my_fixture_read("x86-pentium2").lines)
|
56
|
+
end
|
57
57
|
|
58
|
-
|
58
|
+
subject { Facter::Util::Processor.enum_cpuinfo }
|
59
|
+
|
60
|
+
it "should have the correct processor titles" do
|
61
|
+
subject[0].should == "Pentium II (Deschutes)"
|
62
|
+
subject[1].should == "Pentium II (Deschutes)"
|
63
|
+
end
|
64
|
+
end
|
59
65
|
end
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
describe "on Solaris" do
|
68
|
+
before :each do
|
69
|
+
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get the processor description on Solaris (x86)" do
|
73
|
+
Facter.fact(:architecture).stubs(:value).returns("i86pc")
|
74
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-i86pc"))
|
75
|
+
|
76
|
+
Facter::Util::Processor.enum_kstat[0].should == "Intel(r) Core(tm) i5 CPU M 450 @ 2.40GHz"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should get the processor description on Solaris (SPARC64)" do
|
80
|
+
Facter.fact(:architecture).stubs(:value).returns("sun4u")
|
81
|
+
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-sun4u"))
|
82
|
+
|
83
|
+
Facter::Util::Processor.enum_kstat[0].should == "SPARC64-VII"
|
84
|
+
Facter::Util::Processor.enum_kstat[1].should == "SPARC64-VII"
|
85
|
+
Facter::Util::Processor.enum_kstat[2].should == "SPARC64-VII"
|
86
|
+
Facter::Util::Processor.enum_kstat[3].should == "SPARC64-VII"
|
87
|
+
Facter::Util::Processor.enum_kstat[4].should == "SPARC64-VII"
|
88
|
+
Facter::Util::Processor.enum_kstat[5].should == "SPARC64-VII"
|
89
|
+
Facter::Util::Processor.enum_kstat[6].should == "SPARC64-VII"
|
90
|
+
Facter::Util::Processor.enum_kstat[7].should == "SPARC64-VII"
|
91
|
+
end
|
74
92
|
end
|
75
93
|
end
|
metadata
CHANGED
@@ -1,32 +1,23 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: facter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 6
|
9
|
-
- 16
|
10
|
-
version: 1.6.16
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.17.rc1
|
5
|
+
prerelease: 7
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Puppet Labs
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-12-01 00:00:00 Z
|
12
|
+
date: 2012-12-19 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: You can prove anything with facts!
|
22
15
|
email: info@puppetlabs.com
|
23
|
-
executables:
|
16
|
+
executables:
|
24
17
|
- facter
|
25
18
|
extensions: []
|
26
|
-
|
27
19
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
20
|
+
files:
|
30
21
|
- CONTRIBUTING.md
|
31
22
|
- Gemfile
|
32
23
|
- Gemfile.lock
|
@@ -173,6 +164,7 @@ files:
|
|
173
164
|
- spec/fixtures/ifconfig/fedora_8_eth0
|
174
165
|
- spec/fixtures/ifconfig/freebsd_6_0
|
175
166
|
- spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces
|
167
|
+
- spec/fixtures/ifconfig/linux_ifconfig_no_addr
|
176
168
|
- spec/fixtures/ifconfig/linux_ifconfig_no_mac
|
177
169
|
- spec/fixtures/ifconfig/linux_ifconfig_venet
|
178
170
|
- spec/fixtures/ifconfig/open_solaris_10
|
@@ -192,6 +184,8 @@ files:
|
|
192
184
|
- spec/fixtures/netstat/ubuntu_7_04
|
193
185
|
- spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info
|
194
186
|
- spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info
|
187
|
+
- spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
|
188
|
+
- spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
|
195
189
|
- spec/fixtures/unit/selinux/selinux_sestatus
|
196
190
|
- spec/fixtures/unit/util/ec2/centos-arp-ec2.out
|
197
191
|
- spec/fixtures/unit/util/ec2/linux-arp-ec2.out
|
@@ -203,8 +197,28 @@ files:
|
|
203
197
|
- spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces
|
204
198
|
- spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface
|
205
199
|
- spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig
|
206
|
-
- spec/fixtures/unit/util/ip/
|
207
|
-
- spec/fixtures/unit/util/ip/
|
200
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan0
|
201
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan1
|
202
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo0
|
203
|
+
- spec/fixtures/unit/util/ip/hpux_1111_lanscan
|
204
|
+
- spec/fixtures/unit/util/ip/hpux_1111_netstat_in
|
205
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan0
|
206
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan1
|
207
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo0
|
208
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan
|
209
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in
|
210
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan0
|
211
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan1
|
212
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo0
|
213
|
+
- spec/fixtures/unit/util/ip/hpux_1131_lanscan
|
214
|
+
- spec/fixtures/unit/util/ip/hpux_1131_netstat_in
|
215
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan1
|
216
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4
|
217
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_1
|
218
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo0
|
219
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan
|
220
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in
|
221
|
+
- spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond0
|
208
222
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_eth0
|
209
223
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_ib0
|
210
224
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_lo
|
@@ -224,6 +238,7 @@ files:
|
|
224
238
|
- spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag
|
225
239
|
- spec/fixtures/unit/util/processor/solaris-i86pc
|
226
240
|
- spec/fixtures/unit/util/processor/solaris-sun4u
|
241
|
+
- spec/fixtures/unit/util/processor/x86-pentium2
|
227
242
|
- spec/fixtures/unit/util/uptime/kstat_boot_time
|
228
243
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin
|
229
244
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd
|
@@ -252,6 +267,7 @@ files:
|
|
252
267
|
- spec/unit/id_spec.rb
|
253
268
|
- spec/unit/interfaces_spec.rb
|
254
269
|
- spec/unit/ipaddress6_spec.rb
|
270
|
+
- spec/unit/ipaddress_spec.rb
|
255
271
|
- spec/unit/lsbdistcodename_spec.rb
|
256
272
|
- spec/unit/lsbdistdescription_spec.rb
|
257
273
|
- spec/unit/lsbdistid_spec.rb
|
@@ -290,38 +306,29 @@ files:
|
|
290
306
|
- spec/watchr.rb
|
291
307
|
homepage: https://github.com/puppetlabs/facter
|
292
308
|
licenses: []
|
293
|
-
|
294
309
|
post_install_message:
|
295
310
|
rdoc_options: []
|
296
|
-
|
297
|
-
require_paths:
|
311
|
+
require_paths:
|
298
312
|
- lib
|
299
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
313
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
300
314
|
none: false
|
301
|
-
requirements:
|
302
|
-
- -
|
303
|
-
- !ruby/object:Gem::Version
|
304
|
-
|
305
|
-
|
306
|
-
- 0
|
307
|
-
version: "0"
|
308
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
315
|
+
requirements:
|
316
|
+
- - ! '>='
|
317
|
+
- !ruby/object:Gem::Version
|
318
|
+
version: '0'
|
319
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
309
320
|
none: false
|
310
|
-
requirements:
|
311
|
-
- -
|
312
|
-
- !ruby/object:Gem::Version
|
313
|
-
|
314
|
-
segments:
|
315
|
-
- 0
|
316
|
-
version: "0"
|
321
|
+
requirements:
|
322
|
+
- - ! '>'
|
323
|
+
- !ruby/object:Gem::Version
|
324
|
+
version: 1.3.1
|
317
325
|
requirements: []
|
318
|
-
|
319
326
|
rubyforge_project:
|
320
327
|
rubygems_version: 1.8.24
|
321
328
|
signing_key:
|
322
329
|
specification_version: 3
|
323
330
|
summary: Facter, a system inventory tool
|
324
|
-
test_files:
|
331
|
+
test_files:
|
325
332
|
- spec/fixtures/cpuinfo/amd64dual
|
326
333
|
- spec/fixtures/cpuinfo/amd64quad
|
327
334
|
- spec/fixtures/cpuinfo/amd64solo
|
@@ -357,6 +364,7 @@ test_files:
|
|
357
364
|
- spec/fixtures/ifconfig/fedora_8_eth0
|
358
365
|
- spec/fixtures/ifconfig/freebsd_6_0
|
359
366
|
- spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces
|
367
|
+
- spec/fixtures/ifconfig/linux_ifconfig_no_addr
|
360
368
|
- spec/fixtures/ifconfig/linux_ifconfig_no_mac
|
361
369
|
- spec/fixtures/ifconfig/linux_ifconfig_venet
|
362
370
|
- spec/fixtures/ifconfig/open_solaris_10
|
@@ -376,6 +384,8 @@ test_files:
|
|
376
384
|
- spec/fixtures/netstat/ubuntu_7_04
|
377
385
|
- spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info
|
378
386
|
- spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info
|
387
|
+
- spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt
|
388
|
+
- spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt
|
379
389
|
- spec/fixtures/unit/selinux/selinux_sestatus
|
380
390
|
- spec/fixtures/unit/util/ec2/centos-arp-ec2.out
|
381
391
|
- spec/fixtures/unit/util/ec2/linux-arp-ec2.out
|
@@ -387,8 +397,28 @@ test_files:
|
|
387
397
|
- spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces
|
388
398
|
- spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface
|
389
399
|
- spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig
|
390
|
-
- spec/fixtures/unit/util/ip/
|
391
|
-
- spec/fixtures/unit/util/ip/
|
400
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan0
|
401
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan1
|
402
|
+
- spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo0
|
403
|
+
- spec/fixtures/unit/util/ip/hpux_1111_lanscan
|
404
|
+
- spec/fixtures/unit/util/ip/hpux_1111_netstat_in
|
405
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan0
|
406
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan1
|
407
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo0
|
408
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan
|
409
|
+
- spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in
|
410
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan0
|
411
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan1
|
412
|
+
- spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo0
|
413
|
+
- spec/fixtures/unit/util/ip/hpux_1131_lanscan
|
414
|
+
- spec/fixtures/unit/util/ip/hpux_1131_netstat_in
|
415
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan1
|
416
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4
|
417
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_1
|
418
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo0
|
419
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan
|
420
|
+
- spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in
|
421
|
+
- spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond0
|
392
422
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_eth0
|
393
423
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_ib0
|
394
424
|
- spec/fixtures/unit/util/ip/linux_get_single_interface_lo
|
@@ -408,6 +438,7 @@ test_files:
|
|
408
438
|
- spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag
|
409
439
|
- spec/fixtures/unit/util/processor/solaris-i86pc
|
410
440
|
- spec/fixtures/unit/util/processor/solaris-sun4u
|
441
|
+
- spec/fixtures/unit/util/processor/x86-pentium2
|
411
442
|
- spec/fixtures/unit/util/uptime/kstat_boot_time
|
412
443
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin
|
413
444
|
- spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd
|
@@ -436,6 +467,7 @@ test_files:
|
|
436
467
|
- spec/unit/id_spec.rb
|
437
468
|
- spec/unit/interfaces_spec.rb
|
438
469
|
- spec/unit/ipaddress6_spec.rb
|
470
|
+
- spec/unit/ipaddress_spec.rb
|
439
471
|
- spec/unit/lsbdistcodename_spec.rb
|
440
472
|
- spec/unit/lsbdistdescription_spec.rb
|
441
473
|
- spec/unit/lsbdistid_spec.rb
|