Skip to content

Commit 17a3f4f

Browse files
committed
New esx_version fact based on bios informations
1 parent 05f1ae0 commit 17a3f4f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/facter/esx_version.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'facter'
2+
3+
# Author: Francois Deppierraz <francois.deppierraz@nimag.net>
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+
bios_address = /^BIOS Information$.+?Address: (0x[0-9A-F]{5})$/m.match(result)[1]
14+
15+
case bios_address
16+
when '0xE8480'
17+
'2.5'
18+
when '0xE7C70'
19+
'3.0'
20+
when '0xE7910'
21+
'3.5'
22+
when '0xEA6C0'
23+
'4'
24+
when '0xEA550'
25+
'4 update 1'
26+
when '0xEA2E0'
27+
'4.1'
28+
when '0xE72C0'
29+
'5'
30+
when '0xEA0C0'
31+
'5.1'
32+
else
33+
"unknown, please report #{bios_address}"
34+
end
35+
end
36+
end
37+
end
38+
end

0 commit comments

Comments
 (0)