Ticket #1182: facter-manufacturer.patch
| File facter-manufacturer.patch, 1.5 kB (added by dhill, 8 months ago) |
|---|
-
manufacturer.rb
old new 2 2 # 3 3 4 4 module Facter::Manufacturer 5 def self.dmi_find_system_info(name )5 def self.dmi_find_system_info(name, area) 6 6 return nil unless FileTest.exists?("/usr/sbin/dmidecode") 7 7 8 8 # Do not run the command more than every five seconds. … … 26 26 end 27 27 end 28 28 29 if data = @data[ "System Information"]29 if data = @data[area] 30 30 data[name] 31 else31 else 32 32 nil 33 33 end 34 34 end 35 35 end 36 36 37 # Add the facts to Facter 37 # Define the sections and keys we want. 38 sections_and_keys = { 39 "System Information" => 40 {:SerialNumber => "Serial Number", :Manufacturer => "Manufacturer", :ProductName=> "Product Name"}, 41 "Chassis Information" => 42 {:ChassisType => "Type"}, 43 } 38 44 39 {:SerialNumber => "Serial Number", 40 :Manufacturer => "Manufacturer", 41 :ProductName=> "Product Name"}.each do |fact, name| 42 Facter.add(fact) do 43 confine :kernel => :linux 44 setcode do 45 Facter::Manufacturer.dmi_find_system_info(name) 46 end 47 end 45 # Add the facts to Facter 46 sections_and_keys.each_pair do |section, dmikeys| 47 dmikeys.each do |fact, name| 48 Facter.add(fact) do 49 confine :kernel => :linux 50 setcode do 51 Facter::Manufacturer.dmi_find_system_info(name, section) 52 end 53 end 54 end 48 55 end