Module Facter::Manufacturer
In: lib/facter/util/manufacturer.rb

mamufacturer.rb Support methods for manufacturer specific facts

Methods

Public Class methods

[Source]

    # File lib/facter/util/manufacturer.rb, line 5
 5:         def self.dmi_find_system_info(name)
 6:                 splitstr="Handle"
 7:                 case Facter.value(:kernel)
 8:                         when 'Linux'
 9:                                 return nil unless FileTest.exists?("/usr/sbin/dmidecode")
10:                 
11:                                 output=%x{/usr/sbin/dmidecode 2>/dev/null}
12:                         when 'OpenBSD', 'FreeBSD'
13:                                 return nil unless FileTest.exists?("/usr/local/sbin/dmidecode")
14:                 
15:                                 output=%x{/usr/local/sbin/dmidecode 2>/dev/null}
16:                         when 'NetBSD'
17:                                 return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode")
18: 
19:                                 output=%x{/usr/pkg/sbin/dmidecode 2>/dev/null}
20:                         when 'SunOS'
21:                                 return nil unless FileTest.exists?("/usr/sbin/smbios")
22:                                 splitstr="ID    SIZE TYPE"
23:                                 output=%x{/usr/sbin/smbios 2>/dev/null}
24: 
25:             else
26:                 return
27:                 end
28:                 name.each_pair do |key,v|
29:                         v.each do |v2|
30:                                 v2.each_pair do |value,facterkey|
31:                                         output.split(splitstr).each do |line|
32:                                                 if line =~ /#{key}/ and ( line =~ /#{value} 0x\d+ \(([-\w].*)\)\n*./ or line =~ /#{value} ([-\w].*)\n*./ )
33:                                                 result = $1
34:                                                         Facter.add(facterkey) do
35:                                                                 confine :kernel => [ :linux, :freebsd, :netbsd, :openbsd, :sunos ]
36:                                                         setcode do
37:                                                             result
38:                                                         end
39:                                                 end
40:                                         end
41:                                 end
42:                         end
43:                 end
44:         end
45:     end

[Validate]