mamufacturer.rb Support methods for manufacturer specific facts
# File lib/facter/util/manufacturer.rb, line 30 30: def self.dmi_find_system_info(name) 31: splitstr= Facter.value(:kernel) == 'SunOS' ? "ID SIZE TYPE" : /^Handle/ 32: output = self.get_dmi_table() 33: return if output.nil? 34: name.each_pair do |key,v| 35: v.each do |v2| 36: v2.each_pair do |value,facterkey| 37: output.split(splitstr).each do |line| 38: if line =~ /#{key}/ and line =~ /\n\s+#{value} (.+)\n/ 39: result = $1.strip 40: Facter.add(facterkey) do 41: confine :kernel => [ :linux, :freebsd, :netbsd, :sunos, :"gnu/kfreebsd", :dragonfly ] 42: setcode do 43: result 44: end 45: end 46: end 47: end 48: end 49: end 50: end 51: end
# File lib/facter/util/manufacturer.rb, line 6 6: def self.get_dmi_table() 7: case Facter.value(:kernel) 8: when 'Linux', 'GNU/kFreeBSD' 9: return nil unless FileTest.exists?("/usr/sbin/dmidecode") 10: 11: output=%{/usr/sbin/dmidecode 2>/dev/null} 12: when 'FreeBSD' 13: return nil unless FileTest.exists?("/usr/local/sbin/dmidecode") 14: 15: output=%{/usr/local/sbin/dmidecode 2>/dev/null} 16: when 'NetBSD', 'DragonFly' 17: return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode") 18: 19: output=%{/usr/pkg/sbin/dmidecode 2>/dev/null} 20: when 'SunOS' 21: return nil unless FileTest.exists?("/usr/sbin/smbios") 22: 23: output=%{/usr/sbin/smbios 2>/dev/null} 24: else 25: output=nil 26: end 27: return output 28: end
# File lib/facter/util/manufacturer.rb, line 64 64: def self.prtdiag_sparc_find_system_info() 65: # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86 66: output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag 2>/dev/null') 67: 68: # System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server 69: if output and output =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ 70: Facter.add('manufacturer') do 71: setcode do 72: $1 73: end 74: end 75: Facter.add('productname') do 76: setcode do 77: $3 78: end 79: end 80: end 81: 82: Facter.add('serialnumber') do 83: setcode do 84: Facter::Util::Resolution.exec("/usr/sbin/sneep") 85: end 86: end 87: end
# File lib/facter/util/manufacturer.rb, line 53 53: def self.sysctl_find_system_info(name) 54: name.each do |sysctlkey,facterkey| 55: Facter.add(facterkey) do 56: confine :kernel => [:openbsd, :darwin] 57: setcode do 58: Facter::Util::Resolution.exec("sysctl -n #{sysctlkey} 2>/dev/null") 59: end 60: end 61: end 62: end
# File lib/facter/util/manufacturer.rb, line 89 89: def self.win32_find_system_info(name) 90: require 'facter/util/wmi' 91: value = "" 92: wmi = Facter::Util::WMI.connect() 93: name.each do |facterkey, win32key| 94: query = wmi.ExecQuery("select * from Win32_#{win32key.last}") 95: Facter.add(facterkey) do 96: confine :kernel => :windows 97: setcode do 98: query.each { |x| value = x.__send__( (win32key.first).to_sym) } 99: value 100: end 101: end 102: end 103: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.