Skip to content

Commit 76dae09

Browse files
committed
Merge pull request #20 from ctrlaltdel/fact-esx-version
New esx_version fact based on bios informations
2 parents 05f1ae0 + 0ad90fe commit 76dae09

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

lib/facter/esx_version.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'facter'
2+
3+
# Author: Francois Deppierraz <[email protected]>
4+
# Idea and address/version mapping comes from
5+
# http://virtwo.blogspot.ch/2010/10/which-esx-version-am-i-running-on.html
6+
7+
Facter.add(:esx_version) do
8+
confine :virtual => :vmware
9+
setcode do
10+
if File::executable?("/usr/sbin/dmidecode")
11+
result = Facter::Util::Resolution.exec("/usr/sbin/dmidecode 2>&1")
12+
if result
13+
begin
14+
bios_address = /^BIOS Information$.+?Address: (0x[0-9A-F]{5})$/m.match(result)[1]
15+
16+
case bios_address
17+
when '0xE8480'
18+
'2.5'
19+
when '0xE7C70'
20+
'3.0'
21+
when '0xE7910'
22+
'3.5'
23+
when '0xEA6C0'
24+
'4'
25+
when '0xEA550'
26+
'4 update 1'
27+
when '0xEA2E0'
28+
'4.1'
29+
when '0xE72C0'
30+
'5'
31+
when '0xEA0C0'
32+
'5.1'
33+
else
34+
"unknown, please report #{bios_address}"
35+
end
36+
rescue
37+
'n/a'
38+
end
39+
end
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)