class Rubyipmi::Ipmitool::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/ipmitool/commands/fru.rb, line 7 def initialize(opts = ObservableHash.new) super("ipmitool", opts) @list = {} end
Public Instance Methods
getfrus()
click to toggle source
method to retrieve the raw fru data
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 35 def getfrus command end
manufacturer()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 16 def manufacturer list[DEFAULT_FRU]['product_manufacturer'] end
model()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 24 def model list[DEFAULT_FRU]['product_manufacturer'] end
names()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 12 def names list.keys end
serial()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 20 def serial list[DEFAULT_FRU]['board_serial'] end
Private Instance Methods
command()
click to toggle source
run the command and return result
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 86 def command @options["cmdargs"] = "fru" value = runcmd @options.delete_notify("cmdargs") return @result if value end
method_missing(method, *_args, &_block)
click to toggle source
I use method missing to allow the user to say Fru
.<name> which returns a frudata object unless the user passes a keyname from the default fru device
# File lib/rubyipmi/ipmitool/commands/fru.rb, line 43 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/ipmitool/commands/fru.rb, line 61 def parse(data) return unless data 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 return 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