class Rubyipmi::Freeipmi::Fru
Constants
- DEFAULT_FRU
Attributes
list[RW]
Public Class Methods
new(opts = ObservableHash.new)
click to toggle source
Calls superclass method
Rubyipmi::BaseCommand::new
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 7 def initialize(opts = ObservableHash.new) super("ipmi-fru", opts) @list = {} end
Public Instance Methods
board_serial()
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 21 def board_serial get_from_list('board_serial_number') end
get_from_list(key)
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 12 def get_from_list(key) return unless list.key?(DEFAULT_FRU) list[DEFAULT_FRU][key] if list[DEFAULT_FRU].key?(key) end
getfrus()
click to toggle source
method to retrieve the raw fru data
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 34 def getfrus command @result end
manufacturer()
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 17 def manufacturer get_from_list('board_manufacturer') end
model()
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 29 def model get_from_list('board_product_name') end
names()
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 39 def names list.keys end
serial()
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 25 def serial get_from_list('board_serial_number') end
Private Instance Methods
command()
click to toggle source
run the command and return result
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 96 def command value = runcmd return @result if value end
method_missing(method, *_args, &_block)
click to toggle source
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 51 def method_missing(method, *_args, &_block) name = method.to_s fru = list.fetch(name, nil) # if the user wanted some data from the default fru, lets show the data for the fru. Otherwise # we return the Fru with the given name if fru.nil? if list[DEFAULT_FRU].keys.include?(name) return list[DEFAULT_FRU][name] else # maybe we should return nil instead? hmm... raise NoMethodError end else return fru end end
parse(data)
click to toggle source
parse the fru information
# File lib/rubyipmi/freeipmi/commands/fru.rb, line 69 def parse(data) if !data.nil? && !data.empty? parsed_data = [] data.lines.each do |line| if line =~ /^FRU.*/ # this is the either the first line of of the fru or another fru if parsed_data.count != 0 # we have reached a new fru device so lets record the previous fru new_fru = FruData.new(parsed_data) parsed_data = [] @list[new_fru[:name]] = new_fru end end parsed_data << line end # process the last fru if parsed_data.count != 0 # we have reached a new fru device so lets record the previous fru new_fru = FruData.new(parsed_data) parsed_data = [] @list[new_fru[:name]] = new_fru end end @list end