facter 1.6.1 → 1.6.2
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 +31 -0
- data/Rakefile +41 -36
- data/conf/redhat/facter.spec +11 -4
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +286 -286
- data/lib/facter.rb +211 -211
- data/lib/facter/Cfkey.rb +24 -24
- data/lib/facter/application.rb +1 -0
- data/lib/facter/architecture.rb +21 -29
- data/lib/facter/domain.rb +34 -34
- data/lib/facter/facterversion.rb +1 -1
- data/lib/facter/fqdn.rb +8 -8
- data/lib/facter/hardwareisa.rb +2 -2
- data/lib/facter/hardwaremodel.rb +12 -12
- data/lib/facter/hostname.rb +14 -14
- data/lib/facter/id.rb +3 -3
- data/lib/facter/interfaces.rb +13 -13
- data/lib/facter/ipaddress.rb +101 -101
- data/lib/facter/iphostnumber.rb +12 -12
- data/lib/facter/kernel.rb +7 -7
- data/lib/facter/kernelmajversion.rb +3 -3
- data/lib/facter/kernelrelease.rb +12 -12
- data/lib/facter/kernelversion.rb +5 -5
- data/lib/facter/lsb.rb +14 -14
- data/lib/facter/lsbmajdistrelease.rb +8 -8
- data/lib/facter/macaddress.rb +44 -44
- data/lib/facter/macosx.rb +21 -21
- data/lib/facter/manufacturer.rb +28 -28
- data/lib/facter/memory.rb +143 -115
- data/lib/facter/netmask.rb +4 -4
- data/lib/facter/network.rb +4 -4
- data/lib/facter/operatingsystem.rb +73 -69
- data/lib/facter/operatingsystemrelease.rb +85 -79
- data/lib/facter/osfamily.rb +31 -0
- data/lib/facter/path.rb +3 -3
- data/lib/facter/physicalprocessorcount.rb +8 -0
- data/lib/facter/processor.rb +91 -72
- data/lib/facter/ps.rb +3 -3
- data/lib/facter/puppetversion.rb +7 -7
- data/lib/facter/rubysitedir.rb +5 -5
- data/lib/facter/rubyversion.rb +1 -1
- data/lib/facter/ssh.rb +16 -16
- data/lib/facter/timezone.rb +3 -3
- data/lib/facter/uniqueid.rb +2 -2
- data/lib/facter/util/collection.rb +96 -96
- data/lib/facter/util/confine.rb +30 -30
- data/lib/facter/util/fact.rb +95 -95
- data/lib/facter/util/ip.rb +173 -173
- data/lib/facter/util/loader.rb +88 -88
- data/lib/facter/util/macosx.rb +46 -46
- data/lib/facter/util/manufacturer.rb +78 -78
- data/lib/facter/util/memory.rb +63 -63
- data/lib/facter/util/netmask.rb +34 -34
- data/lib/facter/util/plist.rb +1 -1
- data/lib/facter/util/plist/generator.rb +177 -177
- data/lib/facter/util/plist/parser.rb +166 -166
- data/lib/facter/util/processor.rb +88 -0
- data/lib/facter/util/resolution.rb +154 -154
- data/lib/facter/util/uptime.rb +42 -42
- data/lib/facter/util/values.rb +9 -9
- data/lib/facter/util/virtual.rb +68 -58
- data/lib/facter/util/vlans.rb +17 -17
- data/lib/facter/virtual.rb +105 -110
- data/lib/facter/vlans.rb +6 -6
- data/spec/fixtures/cpuinfo/amd64dual +57 -0
- data/spec/fixtures/cpuinfo/amd64quad +79 -0
- data/spec/fixtures/cpuinfo/amd64solo +23 -0
- data/spec/fixtures/cpuinfo/amd64tri +86 -0
- data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
- data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
- data/spec/fixtures/cpuinfo/panda-armel +17 -0
- data/spec/fixtures/cpuinfo/ppc64 +19 -0
- data/spec/fixtures/cpuinfo/sparc +10 -0
- data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
- data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
- data/spec/integration/facter_spec.rb +18 -18
- data/spec/spec_helper.rb +10 -1
- data/spec/unit/architecture_spec.rb +54 -0
- data/spec/unit/domain_spec.rb +23 -0
- data/spec/unit/memory_spec.rb +78 -1
- data/spec/unit/physicalprocessorcount_spec.rb +41 -35
- data/spec/unit/processor_spec.rb +183 -2
- data/spec/unit/util/processor_spec.rb +62 -0
- data/spec/unit/util/uptime_spec.rb +4 -4
- data/spec/unit/util/virtual_spec.rb +26 -5
- data/spec/unit/virtual_spec.rb +47 -2
- data/spec/watchr.rb +125 -0
- metadata +20 -4
data/lib/facter/util/virtual.rb
CHANGED
@@ -1,76 +1,86 @@
|
|
1
1
|
module Facter::Util::Virtual
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
def self.openvz?
|
3
|
+
FileTest.directory?("/proc/vz") and not self.openvz_cloudlinux?
|
4
|
+
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
result = "openvzve"
|
12
|
-
end
|
13
|
-
end
|
6
|
+
# So one can either have #6728 work on OpenVZ or Cloudlinux. Whoo.
|
7
|
+
def self.openvz_type
|
8
|
+
return false unless self.openvz?
|
9
|
+
return false unless FileTest.exists?( '/proc/self/status' )
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
envid = Facter::Util::Resolution.exec( 'grep "envID" /proc/self/status' )
|
12
|
+
if envid =~ /^envID:\s+0$/i
|
13
|
+
return 'openvzhn'
|
14
|
+
elsif envid =~ /^envID:\s+(\d+)$/i
|
15
|
+
return 'openvzve'
|
20
16
|
end
|
17
|
+
end
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
19
|
+
# Cloudlinux uses OpenVZ to a degree, but always has an empty /proc/vz/ and
|
20
|
+
# has /proc/lve/list present
|
21
|
+
def self.openvz_cloudlinux?
|
22
|
+
FileTest.file?("/proc/lve/list") or Dir.glob('/proc/vz/*').empty?
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
25
|
+
def self.zone?
|
26
|
+
return true if FileTest.directory?("/.SUNWnative")
|
27
|
+
z = Facter::Util::Resolution.exec("/sbin/zonename")
|
28
|
+
return false unless z
|
29
|
+
return z.chomp != 'global'
|
30
|
+
end
|
38
31
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
def self.vserver?
|
33
|
+
return false unless FileTest.exists?("/proc/self/status")
|
34
|
+
txt = File.read("/proc/self/status")
|
35
|
+
return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/
|
36
|
+
return false
|
37
|
+
end
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
def self.vserver_type
|
40
|
+
if self.vserver?
|
41
|
+
if FileTest.exists?("/proc/virtual")
|
42
|
+
"vserver_host"
|
43
|
+
else
|
44
|
+
"vserver"
|
45
|
+
end
|
52
46
|
end
|
47
|
+
end
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# require a special binary
|
58
|
-
"kvm"
|
49
|
+
def self.xen?
|
50
|
+
["/proc/sys/xen", "/sys/bus/xen", "/proc/xen" ].detect do |f|
|
51
|
+
FileTest.exists?(f)
|
59
52
|
end
|
53
|
+
end
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
def self.kvm?
|
56
|
+
txt = if FileTest.exists?("/proc/cpuinfo")
|
57
|
+
File.read("/proc/cpuinfo")
|
58
|
+
elsif Facter.value(:kernel)=="FreeBSD"
|
59
|
+
Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model")
|
60
|
+
end
|
61
|
+
(txt =~ /QEMU Virtual CPU/) ? true : false
|
62
|
+
end
|
68
63
|
|
69
|
-
|
70
|
-
|
64
|
+
def self.kvm_type
|
65
|
+
# TODO Tell the difference between kvm and qemu
|
66
|
+
# Can't work out a way to do this at the moment that doesn't
|
67
|
+
# require a special binary
|
68
|
+
"kvm"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.jail?
|
72
|
+
path = case Facter.value(:kernel)
|
73
|
+
when "FreeBSD" then "/sbin"
|
74
|
+
when "GNU/kFreeBSD" then "/bin"
|
71
75
|
end
|
76
|
+
Facter::Util::Resolution.exec("#{path}/sysctl -n security.jail.jailed") == "1"
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.hpvm?
|
80
|
+
Facter::Util::Resolution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/
|
81
|
+
end
|
72
82
|
|
73
83
|
def self.zlinux?
|
74
|
-
|
84
|
+
"zlinux"
|
75
85
|
end
|
76
86
|
end
|
data/lib/facter/util/vlans.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# A module to gather vlan facts
|
2
2
|
#
|
3
3
|
module Facter::Util::Vlans
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def self.get_vlan_config
|
5
|
+
output = ""
|
6
|
+
if File.exists?('/proc/net/vlan/config') and File.readable?('/proc/net/vlan/config')
|
7
|
+
output = File.open('/proc/net/vlan/config').read
|
8
|
+
end
|
9
|
+
output
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
12
|
+
def self.get_vlans
|
13
|
+
vlans = Array.new
|
14
|
+
if self.get_vlan_config
|
15
|
+
self.get_vlan_config.each_line do |line|
|
16
|
+
if line =~ /^([0-9A-Za-z]+)\.([0-9]+) /
|
17
|
+
vlans.insert(-1, $~[2]) if $~[2]
|
20
18
|
end
|
21
|
-
|
22
|
-
vlans.join(',')
|
19
|
+
end
|
23
20
|
end
|
21
|
+
|
22
|
+
vlans.join(',')
|
23
|
+
end
|
24
24
|
end
|
data/lib/facter/virtual.rb
CHANGED
@@ -10,142 +10,137 @@
|
|
10
10
|
# display.
|
11
11
|
#
|
12
12
|
# On Linux, BSD, Solaris and HPUX:
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# Much of the logic here is obscured behind util/virtual.rb, which rather
|
14
|
+
# than document here, which would encourage drift, just refer to it.
|
15
15
|
# The Xen tests in here rely on /sys and /proc, and check for the presence and
|
16
16
|
# contents of files in there.
|
17
17
|
# If after all the other tests, it's still seen as physical, then it tries to
|
18
18
|
# parse the output of the "lspci", "dmidecode" and "prtdiag" and parses them
|
19
|
-
# for obvious signs of being under VMWare or
|
19
|
+
# for obvious signs of being under VMWare, Parallels or VirtualBox.
|
20
20
|
# Finally it checks for the existence of vmware-vmx, which would hint it's
|
21
21
|
# VMWare.
|
22
22
|
#
|
23
23
|
# Caveats:
|
24
|
-
# Virtualbox detection isn't implemented.
|
25
24
|
# Many checks rely purely on existence of files.
|
26
25
|
#
|
27
26
|
|
28
27
|
require 'facter/util/virtual'
|
29
28
|
|
30
29
|
Facter.add("virtual") do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
result
|
30
|
+
confine :kernel => "Darwin"
|
31
|
+
|
32
|
+
setcode do
|
33
|
+
require 'facter/util/macosx'
|
34
|
+
result = "physical"
|
35
|
+
output = Facter::Util::Macosx.profiler_data("SPDisplaysDataType")
|
36
|
+
if output.is_a?(Hash)
|
37
|
+
result = "parallels" if output["spdisplays_vendor-id"] =~ /0x1ab8/
|
38
|
+
result = "parallels" if output["spdisplays_vendor"] =~ /[Pp]arallels/
|
39
|
+
result = "vmware" if output["spdisplays_vendor-id"] =~ /0x15ad/
|
40
|
+
result = "vmware" if output["spdisplays_vendor"] =~ /VM[wW]are/
|
41
|
+
result = "virtualbox" if output["spdisplays_vendor-id"] =~ /0x80ee/
|
44
42
|
end
|
43
|
+
result
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|
47
47
|
|
48
48
|
Facter.add("virtual") do
|
49
|
-
|
49
|
+
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX GNU/kFreeBSD}
|
50
50
|
|
51
|
-
|
51
|
+
result = "physical"
|
52
52
|
|
53
|
-
|
53
|
+
setcode do
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
if Facter.value(:operatingsystem) == "Solaris" and Facter::Util::Virtual.zone?
|
56
|
+
result = "zone"
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
if Facter.value(:kernel)=="HP-UX"
|
60
|
+
result = "hpvm" if Facter::Util::Virtual.hpvm?
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
if Facter.value(:architecture)=="s390x"
|
64
|
+
result = "zlinux" if Facter::Util::Virtual.zlinux?
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
if Facter::Util::Virtual.openvz?
|
68
|
+
result = Facter::Util::Virtual.openvz_type()
|
69
|
+
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
if Facter::Util::Virtual.vserver?
|
72
|
+
result = Facter::Util::Virtual.vserver_type()
|
73
|
+
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
75
|
+
if Facter::Util::Virtual.xen?
|
76
|
+
if FileTest.exists?("/proc/xen/xsd_kva")
|
77
|
+
result = "xen0"
|
78
|
+
elsif FileTest.exists?("/proc/xen/capabilities")
|
79
|
+
result = "xenu"
|
80
|
+
end
|
81
|
+
end
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
result = "xen0"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
83
|
+
if Facter::Util::Virtual.kvm?
|
84
|
+
result = Facter::Util::Virtual.kvm_type()
|
85
|
+
end
|
91
86
|
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
if ["FreeBSD", "GNU/kFreeBSD"].include? Facter.value(:kernel)
|
88
|
+
result = "jail" if Facter::Util::Virtual.jail?
|
89
|
+
end
|
95
90
|
|
96
|
-
|
97
|
-
|
91
|
+
if result == "physical"
|
92
|
+
output = Facter::Util::Resolution.exec('lspci')
|
93
|
+
if not output.nil?
|
94
|
+
output.each_line do |p|
|
95
|
+
# --- look for the vmware video card to determine if it is virtual => vmware.
|
96
|
+
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
|
97
|
+
result = "vmware" if p =~ /VM[wW]are/
|
98
|
+
# --- look for virtualbox video card to determine if it is virtual => virtualbox.
|
99
|
+
# --- 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
|
100
|
+
result = "virtualbox" if p =~ /VirtualBox/
|
101
|
+
# --- look for pci vendor id used by Parallels video card
|
102
|
+
# --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
|
103
|
+
result = "parallels" if p =~ /1ab8:|[Pp]arallels/
|
104
|
+
# --- look for pci vendor id used by Xen HVM device
|
105
|
+
# --- 00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)
|
106
|
+
result = "xenhvm" if p =~ /XenSource/
|
107
|
+
# --- look for Hyper-V video card
|
108
|
+
# --- 00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA
|
109
|
+
result = "hyperv" if p =~ /Microsoft Corporation Hyper-V/
|
98
110
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
output.each_line do |pd|
|
121
|
-
result = "parallels" if pd =~ /Parallels/
|
122
|
-
result = "vmware" if pd =~ /VMware/
|
123
|
-
result = "virtualbox" if pd =~ /VirtualBox/
|
124
|
-
result = "xenhvm" if pd =~ /HVM domU/
|
125
|
-
end
|
126
|
-
elsif Facter.value(:kernel) == 'SunOS'
|
127
|
-
res = Facter::Util::Resolution.new('prtdiag')
|
128
|
-
res.timeout = 6
|
129
|
-
res.setcode('prtdiag')
|
130
|
-
output = res.value
|
131
|
-
if not output.nil?
|
132
|
-
output.each_line do |pd|
|
133
|
-
result = "parallels" if pd =~ /Parallels/
|
134
|
-
result = "vmware" if pd =~ /VMware/
|
135
|
-
result = "virtualbox" if pd =~ /VirtualBox/
|
136
|
-
result = "xenhvm" if pd =~ /HVM domU/
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
if output = Facter::Util::Resolution.exec("vmware -v")
|
143
|
-
result = output.sub(/(\S+)\s+(\S+).*/) { | text | "#{$1}_#{$2}"}.downcase
|
111
|
+
else
|
112
|
+
output = Facter::Util::Resolution.exec('dmidecode')
|
113
|
+
if not output.nil?
|
114
|
+
output.each_line do |pd|
|
115
|
+
result = "parallels" if pd =~ /Parallels/
|
116
|
+
result = "vmware" if pd =~ /VMware/
|
117
|
+
result = "virtualbox" if pd =~ /VirtualBox/
|
118
|
+
result = "xenhvm" if pd =~ /HVM domU/
|
119
|
+
result = "hyperv" if pd =~ /Product Name: Virtual Machine/
|
120
|
+
end
|
121
|
+
elsif Facter.value(:kernel) == 'SunOS'
|
122
|
+
res = Facter::Util::Resolution.new('prtdiag')
|
123
|
+
res.timeout = 6
|
124
|
+
res.setcode('prtdiag')
|
125
|
+
output = res.value
|
126
|
+
if not output.nil?
|
127
|
+
output.each_line do |pd|
|
128
|
+
result = "parallels" if pd =~ /Parallels/
|
129
|
+
result = "vmware" if pd =~ /VMware/
|
130
|
+
result = "virtualbox" if pd =~ /VirtualBox/
|
131
|
+
result = "xenhvm" if pd =~ /HVM domU/
|
144
132
|
end
|
133
|
+
end
|
145
134
|
end
|
146
|
-
|
147
|
-
|
135
|
+
end
|
136
|
+
|
137
|
+
if output = Facter::Util::Resolution.exec("vmware -v")
|
138
|
+
result = output.sub(/(\S+)\s+(\S+).*/) { | text | "#{$1}_#{$2}"}.downcase
|
139
|
+
end
|
148
140
|
end
|
141
|
+
|
142
|
+
result
|
143
|
+
end
|
149
144
|
end
|
150
145
|
|
151
146
|
# Fact: is_virtual
|
@@ -160,15 +155,15 @@ end
|
|
160
155
|
#
|
161
156
|
|
162
157
|
Facter.add("is_virtual") do
|
163
|
-
|
158
|
+
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin GNU/kFreeBSD}
|
164
159
|
|
165
|
-
|
166
|
-
|
160
|
+
setcode do
|
161
|
+
physical_types = %w{physical xen0 vmware_server vmware_workstation openvzhn}
|
167
162
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
163
|
+
if physical_types.include? Facter.value(:virtual)
|
164
|
+
"false"
|
165
|
+
else
|
166
|
+
"true"
|
173
167
|
end
|
168
|
+
end
|
174
169
|
end
|
data/lib/facter/vlans.rb
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
|
11
11
|
require 'facter/util/vlans'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
Facter.add("vlans") do
|
14
|
+
confine :kernel => :linux
|
15
|
+
setcode do
|
16
|
+
Facter::Util::Vlans.get_vlans
|
17
|
+
end
|
18
|
+
end
|