Sha256: de3551675b34be2627cf24828dbdab583deb593cb499d631bc5222e6ef82e152

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# mamufacturer.rb
# Support methods for manufacturer specific facts

module Facter::Manufacturer
	def self.dmi_find_system_info(name)
		case Facter.value(:kernel)
			when 'Linux'
				return nil unless FileTest.exists?("/usr/sbin/dmidecode")
		
				output=%x{/usr/sbin/dmidecode 2>/dev/null}
			when 'OpenBSD', 'FreeBSD'
				return nil unless FileTest.exists?("/usr/local/sbin/dmidecode")
		
				output=%x{/usr/local/sbin/dmidecode 2>/dev/null}
			when 'NetBSD'
				return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode")

				output=%x{/usr/pkg/sbin/dmidecode 2>/dev/null}
            else
                return
		end
		name.each_pair do |key,v|
			v.each do |value|
				output.split("Handle").each do |line|
				       if line =~ /#{key}/  and line =~ /#{value} ([-\w].*)\n*./
                                                result = $1
						Facter.add(value.chomp(':').gsub(' ','')) do
							confine :kernel => [ :linux, :freebsd, :netbsd, :openbsd ]
							setcode do
							    result
						        end
					        end
				        end
			        end
		        end
	        end
        end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facter-1.5.2 lib/facter/util/manufacturer.rb