Class: Rubyipmi::Ipmitool::Fru

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/ipmitool/commands/fru.rb

Constant Summary collapse

DEFAULT_FRU =
'builtin_fru_device'

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#cmd, #lastcall, #max_retry_count, #options, #passfile, #result

Instance Method Summary collapse

Methods inherited from BaseCommand

#find_fix, #makecommand, #max_retry_count, #setpass

Methods inherited from BaseCommand

#dump_command, #find_fix, #locate_command, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status

Constructor Details

#initialize(opts = ObservableHash.new) ⇒ Fru

Returns a new instance of Fru.



9
10
11
12
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 9

def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)
  @list = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 47

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

Instance Attribute Details

#listObject

return the list of fru information in a hash



31
32
33
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 31

def list
  @list
end

Instance Method Details

#getfrusObject

method to retrieve the raw fru data



39
40
41
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 39

def getfrus
  command
end

#manufacturerObject



18
19
20
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 18

def manufacturer
  list[DEFAULT_FRU]['product_manufacturer']
end

#modelObject



26
27
28
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 26

def model
  list[DEFAULT_FRU]['product_manufacturer']
end

#namesObject



14
15
16
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 14

def names
  list.keys
end

#serialObject



22
23
24
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 22

def serial
  list[DEFAULT_FRU]['board_serial']
end