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.



7
8
9
10
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 7

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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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

Instance Attribute Details

#listObject

return the list of fru information in a hash



29
30
31
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 29

def list
  @list
end

Instance Method Details

#getfrusObject

method to retrieve the raw fru data



35
36
37
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 35

def getfrus
  command
end

#manufacturerObject



16
17
18
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 16

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

#modelObject



24
25
26
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 24

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

#namesObject



12
13
14
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 12

def names
  list.keys
end

#serialObject



20
21
22
# File 'lib/rubyipmi/ipmitool/commands/fru.rb', line 20

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