facter 1.6.13 → 1.6.14.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/Rakefile +1 -5
- data/bin/facter +11 -0
- data/ext/redhat/facter.spec.erb +16 -15
- data/lib/facter/application.rb +0 -1
- data/lib/facter/hardwareisa.rb +7 -2
- data/lib/facter/physicalprocessorcount.rb +13 -1
- data/lib/facter/processor.rb +37 -39
- data/lib/facter/util/ip.rb +2 -2
- data/lib/facter/util/monkey_patches.rb +32 -0
- data/lib/facter/util/processor.rb +74 -23
- data/lib/facter/util/uptime.rb +27 -16
- data/lib/facter/util/virtual.rb +15 -0
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +34 -1
- data/spec/fixtures/ifconfig/centos_5_5 +1 -1
- data/spec/fixtures/ifconfig/centos_5_5_eth0 +1 -1
- data/spec/fixtures/ifconfig/darwin_10_3_0 +1 -1
- data/spec/fixtures/ifconfig/darwin_10_3_0_en0 +1 -1
- data/spec/fixtures/ifconfig/darwin_9_8_0 +1 -1
- data/spec/fixtures/ifconfig/darwin_9_8_0_en0 +1 -1
- data/spec/fixtures/ifconfig/fedora_10 +1 -1
- data/spec/fixtures/ifconfig/fedora_10_eth0 +1 -1
- data/spec/fixtures/ifconfig/fedora_13 +1 -1
- data/spec/fixtures/ifconfig/fedora_13_eth0 +1 -1
- data/spec/fixtures/ifconfig/fedora_8 +1 -1
- data/spec/fixtures/ifconfig/fedora_8_eth0 +1 -1
- data/spec/fixtures/ifconfig/freebsd_6_0 +1 -1
- data/spec/fixtures/ifconfig/open_solaris_10 +1 -1
- data/spec/fixtures/ifconfig/open_solaris_b132 +1 -1
- data/spec/fixtures/ifconfig/ubuntu_7_04 +1 -1
- data/spec/fixtures/ifconfig/ubuntu_7_04_eth0 +1 -1
- data/spec/fixtures/netstat/centos_5_5 +1 -1
- data/spec/fixtures/netstat/darwin_10_3_0 +1 -1
- data/spec/fixtures/netstat/darwin_9_8_0 +1 -1
- data/spec/fixtures/netstat/fedora_10 +1 -1
- data/spec/fixtures/netstat/open_solaris_10 +1 -1
- data/spec/fixtures/netstat/open_solaris_b132 +1 -1
- data/spec/fixtures/netstat/ubuntu_7_04 +1 -1
- data/spec/fixtures/unit/util/ec2/centos-arp-ec2.out +1 -1
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +1 -1
- data/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig +1 -1
- data/spec/fixtures/unit/util/ip/linux_get_single_interface_ib0 +1 -1
- data/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface +1 -1
- data/spec/fixtures/unit/util/ip/linux_ifconfig_ib0 +1 -1
- data/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface +1 -1
- data/spec/integration/facter_spec.rb +1 -1
- data/spec/unit/architecture_spec.rb +1 -1
- data/spec/unit/domain_spec.rb +1 -1
- data/spec/unit/ec2_spec.rb +1 -1
- data/spec/unit/facter_spec.rb +1 -1
- data/spec/unit/hardwareisa_spec.rb +7 -0
- data/spec/unit/hostname_spec.rb +1 -1
- data/spec/unit/id_spec.rb +1 -1
- data/spec/unit/interfaces_spec.rb +1 -1
- data/spec/unit/ipaddress6_spec.rb +1 -1
- data/spec/unit/lsbdistcodename_spec.rb +1 -1
- data/spec/unit/lsbdistdescription_spec.rb +1 -1
- data/spec/unit/lsbdistid_spec.rb +1 -1
- data/spec/unit/lsbdistrelease_spec.rb +1 -1
- data/spec/unit/lsbrelease_spec.rb +1 -1
- data/spec/unit/macaddress_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +1 -1
- data/spec/unit/operatingsystem_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +1 -1
- data/spec/unit/physicalprocessorcount_spec.rb +24 -5
- data/spec/unit/processor_spec.rb +75 -9
- data/spec/unit/selinux_spec.rb +1 -1
- data/spec/unit/uptime_spec.rb +1 -1
- data/spec/unit/util/collection_spec.rb +1 -1
- data/spec/unit/util/config_spec.rb +1 -1
- data/spec/unit/util/confine_spec.rb +1 -1
- data/spec/unit/util/ec2_spec.rb +1 -1
- data/spec/unit/util/fact_spec.rb +1 -1
- data/spec/unit/util/ip_spec.rb +3 -3
- data/spec/unit/util/loader_spec.rb +1 -1
- data/spec/unit/util/macaddress_spec.rb +1 -1
- data/spec/unit/util/macosx_spec.rb +1 -1
- data/spec/unit/util/manufacturer_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +42 -0
- data/spec/unit/util/processor_spec.rb +1 -9
- data/spec/unit/util/registry_spec.rb +1 -1
- data/spec/unit/util/resolution_spec.rb +1 -1
- data/spec/unit/util/uptime_spec.rb +61 -20
- data/spec/unit/util/virtual_spec.rb +1 -1
- data/spec/unit/util/vlans_spec.rb +1 -1
- data/spec/unit/util/wmi_spec.rb +1 -1
- data/spec/unit/util/xendomains_spec.rb +1 -1
- data/spec/unit/virtual_spec.rb +66 -34
- metadata +7 -7
- data/spec/fixtures/unit/util/uptime/who_b_boottime +0 -1
data/lib/facter/util/virtual.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
module Facter::Util::Virtual
|
2
|
+
##
|
3
|
+
# virt_what is a delegating helper method intended to make it easier to stub
|
4
|
+
# the system call without affecting other calls to
|
5
|
+
# Facter::Util::Resolution.exec
|
6
|
+
def self.virt_what(command = "virt-what")
|
7
|
+
Facter::Util::Resolution.exec command
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# lspci is a delegating helper method intended to make it easier to stub the
|
12
|
+
# system call without affecting other calls to Facter::Util::Resolution.exec
|
13
|
+
def self.lspci(command = "lspci 2>/dev/null")
|
14
|
+
Facter::Util::Resolution.exec command
|
15
|
+
end
|
16
|
+
|
2
17
|
def self.openvz?
|
3
18
|
FileTest.directory?("/proc/vz") and not self.openvz_cloudlinux?
|
4
19
|
end
|
data/lib/facter/version.rb
CHANGED
data/lib/facter/virtual.rb
CHANGED
@@ -89,7 +89,7 @@ Facter.add("virtual") do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
if result == "physical"
|
92
|
-
output = Facter::Util::
|
92
|
+
output = Facter::Util::Virtual.lspci
|
93
93
|
if not output.nil?
|
94
94
|
output.each_line do |p|
|
95
95
|
# --- look for the vmware video card to determine if it is virtual => vmware.
|
@@ -153,6 +153,39 @@ Facter.add("virtual") do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
##
|
157
|
+
# virtual fact based on virt-what command.
|
158
|
+
#
|
159
|
+
# The output is mapped onto existing known values for the virtual fact in an
|
160
|
+
# effort to preserve consistency. This fact has a high weight becuase the
|
161
|
+
# virt-what tool is expected to be maintained upstream.
|
162
|
+
#
|
163
|
+
# If the virt-what command is not available, this fact will not resolve to a
|
164
|
+
# value and lower-weight virtual facts will be attempted.
|
165
|
+
#
|
166
|
+
# Only the last line of the virt-what command is returned
|
167
|
+
Facter.add("virtual") do
|
168
|
+
has_weight 500
|
169
|
+
|
170
|
+
setcode do
|
171
|
+
output = Facter::Util::Virtual.virt_what
|
172
|
+
case output
|
173
|
+
when 'linux_vserver'
|
174
|
+
Facter::Util::Virtual.vserver_type
|
175
|
+
when /xen-hvm/i
|
176
|
+
'xenhvm'
|
177
|
+
when /xen-dom0/i
|
178
|
+
'xen0'
|
179
|
+
when /xen-domU/i
|
180
|
+
'xenu'
|
181
|
+
when /ibm_systemz/i
|
182
|
+
'zlinux'
|
183
|
+
else
|
184
|
+
output.to_s.split("\n").last
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
156
189
|
# Fact: is_virtual
|
157
190
|
#
|
158
191
|
# Purpose: returning true or false for if a machine is virtualised or not.
|
@@ -5,4 +5,4 @@ eth0 Link encap:Ethernet HWaddr 16:8D:2A:15:17:91
|
|
5
5
|
RX packets:1914871 errors:0 dropped:0 overruns:0 frame:0
|
6
6
|
TX packets:3960 errors:0 dropped:0 overruns:0 carrier:0
|
7
7
|
collisions:0 txqueuelen:1000
|
8
|
-
RX bytes:178738891 (170.4 MiB) TX bytes:393862 (384.6 KiB)
|
8
|
+
RX bytes:178738891 (170.4 MiB) TX bytes:393862 (384.6 KiB)
|
@@ -23,4 +23,4 @@ vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
23
23
|
inet 172.16.95.1 netmask 0xffffff00 broadcast 172.16.95.255
|
24
24
|
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
25
25
|
ether 00:50:56:c0:00:01
|
26
|
-
inet 172.16.201.1 netmask 0xffffff00 broadcast 172.16.201.255
|
26
|
+
inet 172.16.201.1 netmask 0xffffff00 broadcast 172.16.201.255
|
@@ -3,4 +3,4 @@ en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
3
3
|
inet6 fe80::217:f2ff:fe06:e3c2%en0 prefixlen 64 scopeid 0x4
|
4
4
|
inet 100.100.104.12 netmask 0xffffff00 broadcast 100.100.104.255
|
5
5
|
media: autoselect (1000baseT <full-duplex>)
|
6
|
-
status: active
|
6
|
+
status: active
|
@@ -23,4 +23,4 @@ vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
23
23
|
ether 00:50:56:c0:00:08
|
24
24
|
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
25
25
|
inet 192.168.61.1 netmask 0xffffff00 broadcast 192.168.61.255
|
26
|
-
ether 00:50:56:c0:00:01
|
26
|
+
ether 00:50:56:c0:00:01
|
@@ -3,4 +3,4 @@ en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
3
3
|
inet 100.100.107.4 netmask 0xffffff00 broadcast 100.100.107.255
|
4
4
|
ether 00:17:f2:06:e4:2e
|
5
5
|
media: autoselect (1000baseT <full-duplex>) status: active
|
6
|
-
supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control>
|
6
|
+
supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control>
|
@@ -33,4 +33,4 @@ vmnet8 Link encap:Ethernet HWaddr 00:50:56:C0:00:08
|
|
33
33
|
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
|
34
34
|
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
|
35
35
|
collisions:0 txqueuelen:1000
|
36
|
-
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
|
36
|
+
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
|
@@ -15,4 +15,4 @@ lo Link encap:Local Loopback
|
|
15
15
|
RX packets:482 errors:0 dropped:0 overruns:0 frame:0
|
16
16
|
TX packets:482 errors:0 dropped:0 overruns:0 carrier:0
|
17
17
|
collisions:0 txqueuelen:0
|
18
|
-
RX bytes:48488 (47.3 KiB) TX bytes:48488 (47.3 KiB)
|
18
|
+
RX bytes:48488 (47.3 KiB) TX bytes:48488 (47.3 KiB)
|
@@ -35,4 +35,4 @@ lo Link encap:Local Loopback
|
|
35
35
|
RX packets:59385736 errors:0 dropped:0 overruns:0 frame:0
|
36
36
|
TX packets:59385736 errors:0 dropped:0 overruns:0 carrier:0
|
37
37
|
collisions:0 txqueuelen:0
|
38
|
-
RX bytes:3519026710 (3.2 GiB) TX bytes:3519026710 (3.2 GiB)
|
38
|
+
RX bytes:3519026710 (3.2 GiB) TX bytes:3519026710 (3.2 GiB)
|
@@ -9,4 +9,4 @@ fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
9
9
|
media: Ethernet autoselect (100baseTX <full-duplex>)
|
10
10
|
status: active
|
11
11
|
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
|
12
|
-
inet 127.0.0.1 netmask 0xff000000
|
12
|
+
inet 127.0.0.1 netmask 0xff000000
|
@@ -9,4 +9,4 @@ hme0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2
|
|
9
9
|
inet6 fe80::a00:20ff:fed1:6d79/10
|
10
10
|
ether 8:0:20:d1:6d:79
|
11
11
|
hme0:1: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
|
12
|
-
inet6 2404:130:0:1000:a00:20ff:fed1:6d79/64
|
12
|
+
inet6 2404:130:0:1000:a00:20ff:fed1:6d79/64
|
@@ -17,4 +17,4 @@ int0: flags=2100841<UP,RUNNING,MULTICAST,ROUTER,IPv6> mtu 9000 index 3
|
|
17
17
|
inet6 fe80::ff:0/10
|
18
18
|
ether 2:8:20:89:75:75
|
19
19
|
int0:1: flags=2180841<UP,RUNNING,MULTICAST,ADDRCONF,ROUTER,IPv6> mtu 9000 index 3
|
20
|
-
inet6 2404:130:40:18::ff:0/64
|
20
|
+
inet6 2404:130:40:18::ff:0/64
|
@@ -4,4 +4,4 @@ Destination Gateway Genmask Flags MSS Window irtt Iface
|
|
4
4
|
192.168.183.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
|
5
5
|
100.100.108.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
|
6
6
|
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
|
7
|
-
0.0.0.0 100.100.108.1 0.0.0.0 UG 0 0 0 eth0
|
7
|
+
0.0.0.0 100.100.108.1 0.0.0.0 UG 0 0 0 eth0
|
@@ -1 +1 @@
|
|
1
|
-
? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0
|
1
|
+
? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0
|
@@ -9,4 +9,4 @@ fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
|
9
9
|
media: Ethernet autoselect (100baseTX <full-duplex>)
|
10
10
|
status: active
|
11
11
|
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
|
12
|
-
inet 127.0.0.1 netmask 0xff000000
|
12
|
+
inet 127.0.0.1 netmask 0xff000000
|
@@ -5,4 +5,4 @@ ib0 Link encap:InfiniBand HWaddr 80:00:00:4a:fe:80:00:00:00:00:00:00:00:0
|
|
5
5
|
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
|
6
6
|
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
|
7
7
|
collisions:0 txqueuelen:1024
|
8
|
-
RX bytes:448 (448.0 b) TX bytes:0 (0.0 b)
|
8
|
+
RX bytes:448 (448.0 b) TX bytes:0 (0.0 b)
|
@@ -15,4 +15,4 @@ lo Link encap:Local Loopback
|
|
15
15
|
RX packets:1630 errors:0 dropped:0 overruns:0 frame:0
|
16
16
|
TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0
|
17
17
|
collisions:0 txqueuelen:0
|
18
|
-
RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB)
|
18
|
+
RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB)
|
@@ -5,4 +5,4 @@ ib0 Link encap:InfiniBand HWaddr 80:00:00:4A:FE:80:00:00:00:00:00:00:00:0
|
|
5
5
|
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
|
6
6
|
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
|
7
7
|
collisions:0 txqueuelen:1024
|
8
|
-
RX bytes:448 (448.0 b) TX bytes:0 (0.0 b)
|
8
|
+
RX bytes:448 (448.0 b) TX bytes:0 (0.0 b)
|
data/spec/unit/domain_spec.rb
CHANGED
data/spec/unit/ec2_spec.rb
CHANGED
data/spec/unit/facter_spec.rb
CHANGED
@@ -31,4 +31,11 @@ describe "Hardwareisa fact" do
|
|
31
31
|
|
32
32
|
Facter.fact(:hardwareisa).value.should == "Clyde"
|
33
33
|
end
|
34
|
+
|
35
|
+
it "should match uname -m on HP-UX" do
|
36
|
+
Facter.fact(:kernel).stubs(:value).returns("HP-UX")
|
37
|
+
Facter::Util::Resolution.stubs(:exec).with("uname -m").returns("Pac-Man")
|
38
|
+
|
39
|
+
Facter.fact(:hardwareisa).value.should == "Pac-Man"
|
40
|
+
end
|
34
41
|
end
|
data/spec/unit/hostname_spec.rb
CHANGED
data/spec/unit/id_spec.rb
CHANGED
data/spec/unit/lsbdistid_spec.rb
CHANGED
data/spec/unit/memory_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -48,10 +48,29 @@ describe "Physical processor count facts" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "on solaris" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
let(:psrinfo) do
|
52
|
+
"0 on-line since 10/16/2012 14:06:12\n" +
|
53
|
+
"1 on-line since 10/16/2012 14:06:14\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
%w{ 5.8 5.9 5.10 5.11 }.each do |release|
|
57
|
+
it "should use the output of psrinfo -p on #{release}" do
|
58
|
+
Facter.fact(:kernel).stubs(:value).returns(:sunos)
|
59
|
+
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
60
|
+
|
61
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo -p").returns("1")
|
62
|
+
Facter.fact(:physicalprocessorcount).value.should == "1"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
%w{ 5.5.1 5.6 5.7 }.each do |release|
|
67
|
+
it "uses psrinfo with no -p for kernelrelease #{release}" do
|
68
|
+
Facter.fact(:kernel).stubs(:value).returns(:sunos)
|
69
|
+
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
70
|
+
|
71
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").returns(psrinfo)
|
72
|
+
Facter.fact(:physicalprocessorcount).value.should == "2"
|
73
|
+
end
|
55
74
|
end
|
56
75
|
end
|
57
76
|
end
|