Class: Rubyipmi::Freeipmi::BmcInfo

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/freeipmi/commands/bmcinfo.rb

Instance Attribute Summary

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, #validate_status

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) ⇒ BmcInfo

Returns a new instance of BmcInfo.



3
4
5
# File 'lib/rubyipmi/freeipmi/commands/bmcinfo.rb', line 3

def initialize(opts = ObservableHash.new)
  super("bmc-info", opts)
end

Instance Method Details

#guidObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/rubyipmi/freeipmi/commands/bmcinfo.rb', line 7

def guid
  options["get-device-guid"] = false
  status = runcmd
  options.delete_notify("get-device-guid")
  if !status
    raise @result
  else
    @result.chomp.strip
  end
end

#retrieveObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rubyipmi/freeipmi/commands/bmcinfo.rb', line 18

def retrieve
  bmcinfo = {}
  status = runcmd
  subkey = nil
  if !status
    raise @result
  else
    @result.lines.each do |line|
      # clean up the data from spaces
      item = line.split(':')
      key = item.first.strip
      value = item.last.strip
      # if the following condition is met we have subvalues
      if key == value && !subkey
        subkey = key
        bmcinfo[subkey] = []
      elsif key == value && subkey
        # subvalue found
        bmcinfo[subkey] << value.gsub(/\[|\]/, "")
      else
        # Normal key/value pair with no subkeys
        subkey = nil
        bmcinfo[key] = value
      end
    end
    return bmcinfo
  end
end