Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New esx_version fact based on bios informations #20

Merged
merged 2 commits into from
Aug 20, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions lib/facter/esx_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'facter'

# Author: Francois Deppierraz <[email protected]>
# Idea and address/version mapping comes from
# http://virtwo.blogspot.ch/2010/10/which-esx-version-am-i-running-on.html

Facter.add(:esx_version) do
confine :virtual => :vmware
setcode do
if File::executable?("/usr/sbin/dmidecode")
result = Facter::Util::Resolution.exec("/usr/sbin/dmidecode 2>&1")
if result
begin
bios_address = /^BIOS Information$.+?Address: (0x[0-9A-F]{5})$/m.match(result)[1]

case bios_address
when '0xE8480'
'2.5'
when '0xE7C70'
'3.0'
when '0xE7910'
'3.5'
when '0xEA6C0'
'4'
when '0xEA550'
'4 update 1'
when '0xEA2E0'
'4.1'
when '0xE72C0'
'5'
when '0xEA0C0'
'5.1'
else
"unknown, please report #{bios_address}"
end
rescue
'n/a'
end
end
end
end
end