Module: Facter::Manufacturer

### Home Classes Methods

### In Files

- lib/facter/util/manufacturer.rb

### Methods

- ::dmi_find_system_info
- ::get_dmi_table
- ::prtdiag_sparc_find_system_info
- ::sysctl_find_system_info
- ::win32_find_system_info

### Files

- LICENSE
- Rakefile
- THANKS

### Class/Module Index

Quicksearch

- Facter
- Facter::Application
- Facter::Manufacturer
- Facter::Memory
- Facter::NetMask
- Facter::Util
- Facter::Util::CFPropertyList
- Facter::Util::CFPropertyList::CFArray
- Facter::Util::CFPropertyList::CFBoolean
- Facter::Util::CFPropertyList::CFData
- Facter::Util::CFPropertyList::CFDate
- Facter::Util::CFPropertyList::CFDictionary
- Facter::Util::CFPropertyList::CFInteger
- Facter::Util::CFPropertyList::CFReal
- Facter::Util::CFPropertyList::CFString
- Facter::Util::CFPropertyList::CFType
- Facter::Util::CFPropertyList::XML
- Facter::Util::Collection
- Facter::Util::CompositeLoader
- Facter::Util::Config
- Facter::Util::Confine
- Facter::Util::DirectoryLoader
- Facter::Util::DirectoryLoader::NoSuchDirectoryError
- Facter::Util::EC2
- Facter::Util::Fact
- Facter::Util::FileRead
- Facter::Util::IP
- Facter::Util::IP::Windows
- Facter::Util::IP::Windows::Bindings4
- Facter::Util::IP::Windows::Bindings6
- Facter::Util::Loader
- Facter::Util::Macaddress
- Facter::Util::Macaddress::Darwin
- Facter::Util::Macaddress::Windows
- Facter::Util::Macosx
- Facter::Util::MonkeyPatches
- Facter::Util::MonkeyPatches::Lines
- Facter::Util::NothingLoader
- Facter::Util::Parser
- Facter::Util::Parser::Base
- Facter::Util::Parser::JsonParser
- Facter::Util::Parser::KeyValuePairOutputFormat
- Facter::Util::Parser::NothingParser
- Facter::Util::Parser::PowershellParser
- Facter::Util::Parser::ScriptParser
- Facter::Util::Parser::TextParser
- Facter::Util::Parser::YamlParser
- Facter::Util::Processor
- Facter::Util::Registry
- Facter::Util::Resolution
- Facter::Util::SolarisZones
- Facter::Util::Uptime
- Facter::Util::Values
- Facter::Util::Virtual
- Facter::Util::Vlans
- Facter::Util::WMI
- Facter::Util::Xendomains
- Plist
- Plist::Emit
- Plist::Listener
- Plist::PArray
- Plist::PData
- Plist::PDate
- Plist::PDict
- Plist::PFalse
- Plist::PInteger
- Plist::PKey
- Plist::PList
- Plist::PReal
- Plist::PString
- Plist::PTag
- Plist::PTrue
- Plist::StreamParser
- CFFormatError
- CFPlistError
- CFTypeError
- IO
- Object
- String

No matching classes.

# Facter::Manufacturer

mamufacturer.rb Support methods for manufacturer specific facts

### Public Class Methods

dmi_find_system_info(name) click to toggle source

    # File lib/facter/util/manufacturer.rb, line 30
    def self.dmi_find_system_info(name)
      splitstr=  Facter.value(:kernel) ==  'SunOS' ? "ID  SIZE TYPE" : /^Handle/
      output = self.get_dmi_table()
      return if output.nil?
      name.each_pair do |key,v|
        v.each do |v2|
          v2.each_pair do |value,facterkey|
            output.split(splitstr).each do |line|
              if line =~ /#{key}/ and line =~ /\n\s+#{value} (.+)\n/
                result = $1.strip
                Facter.add(facterkey) do
                  confine :kernel => [ :linux, :freebsd, :netbsd, :sunos, :"gnu/kfreebsd", :dragonfly ]
                  setcode do
                    result
                  end
                end
              end
            end
          end
        end
      end
    end

get_dmi_table() click to toggle source

    # File lib/facter/util/manufacturer.rb, line 6
    def self.get_dmi_table()
      case Facter.value(:kernel)
      when 'Linux', 'GNU/kFreeBSD'
        return nil unless FileTest.exists?("/usr/sbin/dmidecode")

        output=%{/usr/sbin/dmidecode 2>/dev/null}
      when 'FreeBSD'
        return nil unless FileTest.exists?("/usr/local/sbin/dmidecode")

        output=%{/usr/local/sbin/dmidecode 2>/dev/null}
      when 'NetBSD', 'DragonFly'
        return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode")

        output=%{/usr/pkg/sbin/dmidecode 2>/dev/null}
      when 'SunOS'
        return nil unless FileTest.exists?("/usr/sbin/smbios")

        output=%{/usr/sbin/smbios 2>/dev/null}
      else
        output=nil
      end
      return output
    end

prtdiag_sparc_find_system_info() click to toggle source

    # File lib/facter/util/manufacturer.rb, line 64
    def self.prtdiag_sparc_find_system_info()
      # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86
      output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag 2>/dev/null')

      # System Configuration:  Sun Microsystems  sun4u Sun SPARC Enterprise M3000 Server
      if output and output =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/
        Facter.add('manufacturer') do
          setcode do
            $1
          end
        end
        Facter.add('productname') do
          setcode do
            $3
          end
        end
      end

      Facter.add('serialnumber') do
        setcode do
          Facter::Util::Resolution.exec("/usr/sbin/sneep")
        end
      end
    end

sysctl_find_system_info(name) click to toggle source

    # File lib/facter/util/manufacturer.rb, line 53
    def self.sysctl_find_system_info(name)
      name.each do |sysctlkey,facterkey|
        Facter.add(facterkey) do
          confine :kernel => [:openbsd, :darwin]
          setcode do
            Facter::Util::Resolution.exec("sysctl -n #{sysctlkey} 2>/dev/null")
          end
        end
      end
    end

win32_find_system_info(name) click to toggle source

    # File lib/facter/util/manufacturer.rb, line 89
    def self.win32_find_system_info(name)
      require 'facter/util/wmi'
      value = ""
      wmi = Facter::Util::WMI.connect()
      name.each do |facterkey, win32key|
        query = wmi.ExecQuery("select * from Win32_#{win32key.last}")
        Facter.add(facterkey) do
          confine :kernel => :windows
          setcode do
            query.each { |x| value = x.__send__( (win32key.first).to_sym) }
            value
          end
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.