Imported Upstream version 1.6.7
Stig Sandbeck Mathisen
12 years ago
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 | ||
0 | 7 | 1.6.6 |
1 | 8 | === |
2 | 9 | e046144 Updated CHANGELOG for 1.6.6rc2 |
102 | 102 | op = File.dirname(olf) |
103 | 103 | FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) |
104 | 104 | FileUtils.chmod(0755, op) |
105 | FileUtils.install(lf, olf, {:mode => 0644, :verbose => true}) | |
105 | FileUtils.install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true}) | |
106 | 106 | end |
107 | 107 | end |
108 | 108 | |
113 | 113 | om = File.dirname(omf) |
114 | 114 | FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) |
115 | 115 | FileUtils.chmod(0755, om) |
116 | FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) | |
116 | FileUtils.install(mf, omf, {:mode => 0644, :preserve => true, :verbose => true}) | |
117 | 117 | gzip = %x{which gzip} |
118 | 118 | gzip.chomp! |
119 | 119 | %x{#{gzip} -f #{omf}} |
399 | 399 | installed_wrapper = false |
400 | 400 | |
401 | 401 | 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) | |
403 | 403 | installed_wrapper = true |
404 | 404 | end |
405 | 405 | |
406 | 406 | 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) | |
408 | 408 | installed_wrapper = true |
409 | 409 | end |
410 | 410 | |
418 | 418 | "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %* |
419 | 419 | EOS |
420 | 420 | 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) | |
422 | 422 | |
423 | 423 | tmp_file2.unlink |
424 | 424 | installed_wrapper = true |
425 | 425 | end |
426 | 426 | 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) | |
428 | 428 | tmp_file.unlink |
429 | 429 | end |
430 | 430 |
4 | 4 | # |
5 | 5 | # Resolution: |
6 | 6 | # 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. | |
8 | 9 | # On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU |
9 | 10 | # count. |
10 | 11 | # |
80 | 81 | ## (but we need them inside the Facter.add block above for tests on processorcount to work) |
81 | 82 | processor_list = Facter::Util::Processor.enum_cpuinfo |
82 | 83 | processor_list_aix = Facter::Util::Processor.enum_lsdev |
84 | processor_list_sunos = Facter::Util::Processor.enum_kstat | |
83 | 85 | |
84 | 86 | if processor_list.length != 0 |
85 | 87 | processor_list.each_with_index do |desc, i| |
94 | 96 | processor_list_aix.each_with_index do |desc, i| |
95 | 97 | Facter.add("Processor#{i}") do |
96 | 98 | 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 ] | |
97 | 108 | setcode do |
98 | 109 | desc |
99 | 110 | end |
84 | 84 | end |
85 | 85 | processor_list |
86 | 86 | 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 | |
87 | 106 | end |
88 | 88 | end |
89 | 89 | |
90 | 90 | if result == "physical" |
91 | output = Facter::Util::Resolution.exec('lspci') | |
91 | output = Facter::Util::Resolution.exec('lspci 2>/dev/null') | |
92 | 92 | if not output.nil? |
93 | 93 | output.each_line do |p| |
94 | 94 | # --- look for the vmware video card to determine if it is virtual => vmware. |
24 | 24 | include Comparable |
25 | 25 | include Enumerable |
26 | 26 | |
27 | FACTERVERSION = '1.6.6' | |
27 | FACTERVERSION = '1.6.7' | |
28 | 28 | # = Facter |
29 | 29 | # Functions as a hash of 'facts' you might care about about your |
30 | 30 | # 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 |
42 | 42 | Facter.fact(:architecture).stubs(:value).returns("amd64") |
43 | 43 | File.stubs(:exists?).with("/proc/cpuinfo").returns(true) |
44 | 44 | File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad")) |
45 | ||
45 | ||
46 | 46 | Facter::Util::Processor.enum_cpuinfo[0].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" |
47 | 47 | Facter::Util::Processor.enum_cpuinfo[1].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" |
48 | 48 | Facter::Util::Processor.enum_cpuinfo[2].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" |
56 | 56 | |
57 | 57 | Facter::Util::Processor.enum_lsdev[0].should == "PowerPC_POWER3" |
58 | 58 | 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 | |
59 | 82 | end |
80 | 80 | Facter.fact(:architecture).stubs(:value).returns(true) |
81 | 81 | end |
82 | 82 | |
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") | |
104 | 104 | Facter.fact(:virtual).value.should == "virtualbox" |
105 | 105 | end |
106 | 106 | |
107 | 107 | it "should be vmware with VMWare vendor name from dmidecode" do |
108 | 108 | 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) | |
110 | 110 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II") |
111 | 111 | Facter.fact(:virtual).value.should == "vmware" |
112 | 112 | end |
130 | 130 | Facter.fact(:virtual).value.should == "xenu" |
131 | 131 | end |
132 | 132 | |
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)") | |
136 | 136 | Facter.fact(:virtual).value.should == "xenhvm" |
137 | 137 | end |
138 | 138 | |
139 | 139 | it "should be xenhvm with Xen HVM vendor name from dmidecode" do |
140 | 140 | 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) | |
142 | 142 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU") |
143 | 143 | Facter.fact(:virtual).value.should == "xenhvm" |
144 | 144 | end |
145 | 145 | |
146 | 146 | it "should be parallels with Parallels vendor name from dmidecode" do |
147 | 147 | 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) | |
149 | 149 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter") |
150 | 150 | Facter.fact(:virtual).value.should == "parallels" |
151 | 151 | end |
152 | 152 | |
153 | 153 | it "should be virtualbox with VirtualBox vendor name from dmidecode" do |
154 | 154 | 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) | |
156 | 156 | 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") |
157 | 157 | Facter.fact(:virtual).value.should == "virtualbox" |
158 | 158 | end |
159 | 159 | |
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") | |
163 | 163 | Facter.fact(:virtual).value.should == "hyperv" |
164 | 164 | end |
165 | 165 | |
166 | 166 | it "should be hyperv with Microsoft vendor name from dmidecode" do |
167 | 167 | 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) | |
169 | 169 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine") |
170 | 170 | Facter.fact(:virtual).value.should == "hyperv" |
171 | 171 | end |
179 | 179 | it "should be vmware with VMWare vendor name from prtdiag" do |
180 | 180 | Facter.fact(:kernel).stubs(:value).returns("SunOS") |
181 | 181 | 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) | |
183 | 183 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil) |
184 | 184 | Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform") |
185 | 185 | Facter.fact(:virtual).value.should == "vmware" |
188 | 188 | it "should be parallels with Parallels vendor name from prtdiag" do |
189 | 189 | Facter.fact(:kernel).stubs(:value).returns("SunOS") |
190 | 190 | 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) | |
192 | 192 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil) |
193 | 193 | Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform") |
194 | 194 | Facter.fact(:virtual).value.should == "parallels" |
197 | 197 | it "should be virtualbox with VirtualBox vendor name from prtdiag" do |
198 | 198 | Facter.fact(:kernel).stubs(:value).returns("SunOS") |
199 | 199 | 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) | |
201 | 201 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil) |
202 | 202 | Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox") |
203 | 203 | Facter.fact(:virtual).value.should == "virtualbox" |
209 | 209 | Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false |
210 | 210 | Facter.fact(:kernel).stubs(:value).returns("OpenBSD") |
211 | 211 | 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) | |
213 | 213 | Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil) |
214 | 214 | end |
215 | 215 |