Sha256: 500ee50031526babee8c9db86d64af6b115e7f6b60255385451ba3a9b8587c51

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module Rubyipmi::Ipmitool

  class Fru < Rubyipmi::Ipmitool::BaseCommand

    def initialize(opts = ObservableHash.new)
      super("ipmitool", opts)
    end

    # return the list of fru information in a hash
    def list
      @list ||= parse(command)
    end

    # returns the serial of the board
    def serial
       list["board_serial"]
    end

    # returns the manufacturer of the server
    def manufacturer
       list["product_manufacturer"]
    end

    # returns the product name of the server
    def product
       list["product_name"]
    end

   private

    def method_missing(method, *args, &block)
          if not list.has_key?(method.to_s)
            raise NoMethodError
          else
            list[method.to_s]
          end
     end

    # parse the fru information
    def parse(data)
      datalist = {}
      data.lines.each do |line|
        key, value = line.split(':')
        next if key =~ /\n/
        key = key.strip.gsub(/\ /, '_').downcase
        datalist[key] = value.strip
      end
      return datalist
    end

    # run the command and return result
    def command
       @options["cmdargs"] = "fru"
       value = runcmd
       @options.delete_notify("cmdargs")
       if value
         return @result
       end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubyipmi-0.6.0 lib/rubyipmi/ipmitool/commands/fru.rb
rubyipmi-0.5.1 lib/rubyipmi/ipmitool/commands/fru.rb
rubyipmi-0.5.0 lib/rubyipmi/ipmitool/commands/fru.rb