Codebase list facter / upstream/1.6.7
Imported Upstream version 1.6.7 Stig Sandbeck Mathisen 12 years ago
10 changed file(s) with 285 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
0 1.6.7
1 ===
2 ab9e26c Updating CHANGELOG and lib/facter.rb for Facter 1.6.7rc1
3 bdbf332 (#12720) Add Solaris CPU info to 'processorN' fact.
4 a7f5924 (#12813) Redirect lspci output to /dev/null
5 6ec2863 (#12669) Preserve timestamps when installing files
6
07 1.6.6
18 ===
29 e046144 Updated CHANGELOG for 1.6.6rc2
102102 op = File.dirname(olf)
103103 FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
104104 FileUtils.chmod(0755, op)
105 FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
105 FileUtils.install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true})
106106 end
107107 end
108108
113113 om = File.dirname(omf)
114114 FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
115115 FileUtils.chmod(0755, om)
116 FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
116 FileUtils.install(mf, omf, {:mode => 0644, :preserve => true, :verbose => true})
117117 gzip = %x{which gzip}
118118 gzip.chomp!
119119 %x{#{gzip} -f #{omf}}
399399 installed_wrapper = false
400400
401401 if File.exists?("#{from}.bat")
402 FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
402 FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true)
403403 installed_wrapper = true
404404 end
405405
406406 if File.exists?("#{from}.cmd")
407 FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
407 FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :preserve => true, :verbose => true)
408408 installed_wrapper = true
409409 end
410410
418418 "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %*
419419 EOS
420420 File.open(tmp_file2.path, "w") { |cw| cw.puts cwv }
421 FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
421 FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true)
422422
423423 tmp_file2.unlink
424424 installed_wrapper = true
425425 end
426426 end
427 FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :verbose => true)
427 FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true)
428428 tmp_file.unlink
429429 end
430430
44 #
55 # Resolution:
66 # On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor.
7 # On AIX, parse the output of 'lsdev' for it's processor section.
7 # On AIX, parse the output of 'lsdev' for its processor section.
8 # On Solaris, parse the output of 'kstat' for each processor.
89 # On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU
910 # count.
1011 #
8081 ## (but we need them inside the Facter.add block above for tests on processorcount to work)
8182 processor_list = Facter::Util::Processor.enum_cpuinfo
8283 processor_list_aix = Facter::Util::Processor.enum_lsdev
84 processor_list_sunos = Facter::Util::Processor.enum_kstat
8385
8486 if processor_list.length != 0
8587 processor_list.each_with_index do |desc, i|
9496 processor_list_aix.each_with_index do |desc, i|
9597 Facter.add("Processor#{i}") do
9698 confine :kernel => [ :aix ]
99 setcode do
100 desc
101 end
102 end
103 end
104 elsif processor_list_sunos.length != 0
105 processor_list_sunos.each_with_index do |desc, i|
106 Facter.add("Processor#{i}") do
107 confine :kernel => [ :sunos ]
97108 setcode do
98109 desc
99110 end
8484 end
8585 processor_list
8686 end
87
88 def self.enum_kstat
89 processor_num = -1
90 processor_list = []
91 Thread::exclusive do
92 kstat = Facter::Util::Resolution.exec('/usr/bin/kstat cpu_info')
93 if kstat
94 kstat.each_line do |l|
95 if l =~ /cpu_info(\d+)/
96 processor_num = $1.to_i
97 elsif l =~ /brand\s+(.*)\s*$/
98 processor_list[processor_num] = $1 unless processor_num == -1
99 processor_num = -1
100 end
101 end
102 end
103 end
104 processor_list
105 end
87106 end
8888 end
8989
9090 if result == "physical"
91 output = Facter::Util::Resolution.exec('lspci')
91 output = Facter::Util::Resolution.exec('lspci 2>/dev/null')
9292 if not output.nil?
9393 output.each_line do |p|
9494 # --- look for the vmware video card to determine if it is virtual => vmware.
2424 include Comparable
2525 include Enumerable
2626
27 FACTERVERSION = '1.6.6'
27 FACTERVERSION = '1.6.7'
2828 # = Facter
2929 # Functions as a hash of 'facts' you might care about about your
3030 # system, such as mac address, IP address, Video card, etc.
0 module: cpu_info instance: 0
1 name: cpu_info0 class: misc
2 brand Intel(r) Core(tm) i5 CPU M 450 @ 2.40GHz
3 cache_id 0
4 chip_id 0
5 clock_MHz 2375
6 clog_id 0
7 core_id 0
8 cpu_type i386
9 crtime 70.899819526
10 current_clock_Hz 2374891267
11 current_cstate 0
12 family 6
13 fpu_type i387 compatible
14 implementation x86 (GenuineIntel family 6 model 37 step 5 clock 2375 MHz)
15 model 37
16 ncore_per_chip 1
17 ncpu_per_chip 1
18 pg_id -1
19 pkg_core_id 0
20 snaptime 2279.514858392
21 state on-line
22 state_begin 1329488796
23 stepping 5
24 supported_frequencies_Hz 2374891267
25 supported_max_cstates 1
26 vendor_id GenuineIntel
27
0 module: cpu_info instance: 0
1 name: cpu_info0 class: misc
2 brand SPARC64-VII
3 chip_id 1024
4 clock_MHz 2520
5 core_id 0
6 cpu_fru hc:///component=/MBU_A
7 cpu_type sparcv9
8 crtime 92.5418505
9 current_clock_Hz 2520000000
10 device_ID 175931055444225
11 fpu_type sparcv9
12 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
13 pg_id 1
14 snaptime 15277456.9660361
15 state on-line
16 state_begin 1314212380
17 supported_frequencies_Hz 2520000000
18
19 module: cpu_info instance: 1
20 name: cpu_info1 class: misc
21 brand SPARC64-VII
22 chip_id 1024
23 clock_MHz 2520
24 core_id 0
25 cpu_fru hc:///component=/MBU_A
26 cpu_type sparcv9
27 crtime 93.3416172
28 current_clock_Hz 2520000000
29 device_ID 175931055444225
30 fpu_type sparcv9
31 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
32 pg_id 1
33 snaptime 15277456.9667477
34 state on-line
35 state_begin 1314212381
36 supported_frequencies_Hz 2520000000
37
38 module: cpu_info instance: 2
39 name: cpu_info2 class: misc
40 brand SPARC64-VII
41 chip_id 1024
42 clock_MHz 2520
43 core_id 2
44 cpu_fru hc:///component=/MBU_A
45 cpu_type sparcv9
46 crtime 93.3433262
47 current_clock_Hz 2520000000
48 device_ID 175931055444225
49 fpu_type sparcv9
50 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
51 pg_id 4
52 snaptime 15277456.9671387
53 state on-line
54 state_begin 1314212381
55 supported_frequencies_Hz 2520000000
56
57 module: cpu_info instance: 3
58 name: cpu_info3 class: misc
59 brand SPARC64-VII
60 chip_id 1024
61 clock_MHz 2520
62 core_id 2
63 cpu_fru hc:///component=/MBU_A
64 cpu_type sparcv9
65 crtime 93.3449653
66 current_clock_Hz 2520000000
67 device_ID 175931055444225
68 fpu_type sparcv9
69 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
70 pg_id 4
71 snaptime 15277456.9675197
72 state on-line
73 state_begin 1314212381
74 supported_frequencies_Hz 2520000000
75
76 module: cpu_info instance: 4
77 name: cpu_info4 class: misc
78 brand SPARC64-VII
79 chip_id 1024
80 clock_MHz 2520
81 core_id 4
82 cpu_fru hc:///component=/MBU_A
83 cpu_type sparcv9
84 crtime 93.3465648
85 current_clock_Hz 2520000000
86 device_ID 175931055444225
87 fpu_type sparcv9
88 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
89 pg_id 5
90 snaptime 15277456.9678953
91 state on-line
92 state_begin 1314212381
93 supported_frequencies_Hz 2520000000
94
95 module: cpu_info instance: 5
96 name: cpu_info5 class: misc
97 brand SPARC64-VII
98 chip_id 1024
99 clock_MHz 2520
100 core_id 4
101 cpu_fru hc:///component=/MBU_A
102 cpu_type sparcv9
103 crtime 93.3481605
104 current_clock_Hz 2520000000
105 device_ID 175931055444225
106 fpu_type sparcv9
107 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
108 pg_id 5
109 snaptime 15277456.968269
110 state on-line
111 state_begin 1314212381
112 supported_frequencies_Hz 2520000000
113
114 module: cpu_info instance: 6
115 name: cpu_info6 class: misc
116 brand SPARC64-VII
117 chip_id 1024
118 clock_MHz 2520
119 core_id 6
120 cpu_fru hc:///component=/MBU_A
121 cpu_type sparcv9
122 crtime 93.3497654
123 current_clock_Hz 2520000000
124 device_ID 175931055444225
125 fpu_type sparcv9
126 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
127 pg_id 6
128 snaptime 15277456.9686422
129 state on-line
130 state_begin 1314212381
131 supported_frequencies_Hz 2520000000
132
133 module: cpu_info instance: 7
134 name: cpu_info7 class: misc
135 brand SPARC64-VII
136 chip_id 1024
137 clock_MHz 2520
138 core_id 6
139 cpu_fru hc:///component=/MBU_A
140 cpu_type sparcv9
141 crtime 93.3513776
142 current_clock_Hz 2520000000
143 device_ID 175931055444225
144 fpu_type sparcv9
145 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz)
146 pg_id 6
147 snaptime 15277456.9690115
148 state on-line
149 state_begin 1314212381
150 supported_frequencies_Hz 2520000000
4242 Facter.fact(:architecture).stubs(:value).returns("amd64")
4343 File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
4444 File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad"))
45
45
4646 Facter::Util::Processor.enum_cpuinfo[0].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
4747 Facter::Util::Processor.enum_cpuinfo[1].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
4848 Facter::Util::Processor.enum_cpuinfo[2].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE"
5656
5757 Facter::Util::Processor.enum_lsdev[0].should == "PowerPC_POWER3"
5858 end
59
60 it "should get the processor description on Solaris (x86)" do
61 Facter.fact(:kernel).stubs(:value).returns("SunOS")
62 Facter.fact(:architecture).stubs(:value).returns("i86pc")
63 Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-i86pc"))
64
65 Facter::Util::Processor.enum_kstat[0].should == "Intel(r) Core(tm) i5 CPU M 450 @ 2.40GHz"
66 end
67
68 it "should get the processor description on Solaris (SPARC64)" do
69 Facter.fact(:kernel).stubs(:value).returns("SunOS")
70 Facter.fact(:architecture).stubs(:value).returns("sun4u")
71 Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-sun4u"))
72
73 Facter::Util::Processor.enum_kstat[0].should == "SPARC64-VII"
74 Facter::Util::Processor.enum_kstat[1].should == "SPARC64-VII"
75 Facter::Util::Processor.enum_kstat[2].should == "SPARC64-VII"
76 Facter::Util::Processor.enum_kstat[3].should == "SPARC64-VII"
77 Facter::Util::Processor.enum_kstat[4].should == "SPARC64-VII"
78 Facter::Util::Processor.enum_kstat[5].should == "SPARC64-VII"
79 Facter::Util::Processor.enum_kstat[6].should == "SPARC64-VII"
80 Facter::Util::Processor.enum_kstat[7].should == "SPARC64-VII"
81 end
5982 end
8080 Facter.fact(:architecture).stubs(:value).returns(true)
8181 end
8282
83 it "should be parallels with Parallels vendor id from lspci" do
84 Facter.fact(:kernel).stubs(:value).returns("Linux")
85 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005")
86 Facter.fact(:virtual).value.should == "parallels"
87 end
88
89 it "should be parallels with Parallels vendor name from lspci" do
90 Facter.fact(:kernel).stubs(:value).returns("Linux")
91 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Parallels Display Adapter")
92 Facter.fact(:virtual).value.should == "parallels"
93 end
94
95 it "should be vmware with VMware vendor name from lspci" do
96 Facter.fact(:kernel).stubs(:value).returns("Linux")
97 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
98 Facter.fact(:virtual).value.should == "vmware"
99 end
100
101 it "should be virtualbox with VirtualBox vendor name from lspci" do
102 Facter.fact(:kernel).stubs(:value).returns("Linux")
103 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
83 it "should be parallels with Parallels vendor id from lspci 2>/dev/null" do
84 Facter.fact(:kernel).stubs(:value).returns("Linux")
85 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005")
86 Facter.fact(:virtual).value.should == "parallels"
87 end
88
89 it "should be parallels with Parallels vendor name from lspci 2>/dev/null" do
90 Facter.fact(:kernel).stubs(:value).returns("Linux")
91 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("01:00.0 VGA compatible controller: Parallels Display Adapter")
92 Facter.fact(:virtual).value.should == "parallels"
93 end
94
95 it "should be vmware with VMware vendor name from lspci 2>/dev/null" do
96 Facter.fact(:kernel).stubs(:value).returns("Linux")
97 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
98 Facter.fact(:virtual).value.should == "vmware"
99 end
100
101 it "should be virtualbox with VirtualBox vendor name from lspci 2>/dev/null" do
102 Facter.fact(:kernel).stubs(:value).returns("Linux")
103 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
104104 Facter.fact(:virtual).value.should == "virtualbox"
105105 end
106106
107107 it "should be vmware with VMWare vendor name from dmidecode" do
108108 Facter.fact(:kernel).stubs(:value).returns("Linux")
109 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
109 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
110110 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
111111 Facter.fact(:virtual).value.should == "vmware"
112112 end
130130 Facter.fact(:virtual).value.should == "xenu"
131131 end
132132
133 it "should be xenhvm with Xen HVM vendor name from lspci" do
134 Facter.fact(:kernel).stubs(:value).returns("Linux")
135 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
133 it "should be xenhvm with Xen HVM vendor name from lspci 2>/dev/null" do
134 Facter.fact(:kernel).stubs(:value).returns("Linux")
135 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
136136 Facter.fact(:virtual).value.should == "xenhvm"
137137 end
138138
139139 it "should be xenhvm with Xen HVM vendor name from dmidecode" do
140140 Facter.fact(:kernel).stubs(:value).returns("Linux")
141 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
141 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
142142 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
143143 Facter.fact(:virtual).value.should == "xenhvm"
144144 end
145145
146146 it "should be parallels with Parallels vendor name from dmidecode" do
147147 Facter.fact(:kernel).stubs(:value).returns("Linux")
148 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
148 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
149149 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
150150 Facter.fact(:virtual).value.should == "parallels"
151151 end
152152
153153 it "should be virtualbox with VirtualBox vendor name from dmidecode" do
154154 Facter.fact(:kernel).stubs(:value).returns("Linux")
155 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
155 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
156156 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
157157 Facter.fact(:virtual).value.should == "virtualbox"
158158 end
159159
160 it "should be hyperv with Microsoft vendor name from lspci" do
161 Facter.fact(:kernel).stubs(:value).returns("Linux")
162 Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
160 it "should be hyperv with Microsoft vendor name from lspci 2>/dev/null" do
161 Facter.fact(:kernel).stubs(:value).returns("Linux")
162 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
163163 Facter.fact(:virtual).value.should == "hyperv"
164164 end
165165
166166 it "should be hyperv with Microsoft vendor name from dmidecode" do
167167 Facter.fact(:kernel).stubs(:value).returns("Linux")
168 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
168 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
169169 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine")
170170 Facter.fact(:virtual).value.should == "hyperv"
171171 end
179179 it "should be vmware with VMWare vendor name from prtdiag" do
180180 Facter.fact(:kernel).stubs(:value).returns("SunOS")
181181 Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
182 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
182 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
183183 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
184184 Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
185185 Facter.fact(:virtual).value.should == "vmware"
188188 it "should be parallels with Parallels vendor name from prtdiag" do
189189 Facter.fact(:kernel).stubs(:value).returns("SunOS")
190190 Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
191 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
191 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
192192 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
193193 Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
194194 Facter.fact(:virtual).value.should == "parallels"
197197 it "should be virtualbox with VirtualBox vendor name from prtdiag" do
198198 Facter.fact(:kernel).stubs(:value).returns("SunOS")
199199 Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
200 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
200 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
201201 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
202202 Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
203203 Facter.fact(:virtual).value.should == "virtualbox"
209209 Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
210210 Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
211211 Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
212 Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
212 Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
213213 Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
214214 end
215215