Class: Rubyipmi::Ipmitool::Bmc

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

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, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status

Constructor Details

#initialize(opts = ObservableHash.new) ⇒ Bmc

Returns a new instance of Bmc.



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

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

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 5

def config
  @config
end

Instance Method Details

#guidObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 37

def guid
  @options["cmdargs"] = "bmc guid"
  value = runcmd()
  @options.delete_notify("cmdargs")
  if value
    @result.lines.each { | line |
      line.chomp
      if line =~ /GUID/
        line.split(":").last.strip
      end
    }
  end

end

#infoObject



16
17
18
19
20
21
22
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 16

def info
  if @bmcinfo.length > 0
    @bmcinfo
  else
    retrieve
  end
end

#lanObject



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

def lan
  @lan ||= Rubyipmi::Ipmitool::Lan.new(@options)
end

#reset(type = 'cold') ⇒ Object

reset the bmc device, useful for troubleshooting



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 25

def reset(type='cold')
  if ['cold', 'warm'].include?(type)
     @options["cmdargs"] = "bmc reset #{type}"
     value = runcmd()
     @options.delete_notify("cmdargs")
     return value
  else
    raise "reset type: #{type} is not a valid choice, use warm or cold"
  end

end

#retrieveObject

This function will get the bmcinfo and return a hash of each item in the info



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 53

def retrieve
  @options["cmdargs"] = "bmc info"
  status = runcmd
  @options.delete_notify("cmdargs")
  subkey = nil
  if not 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 value.empty?
        subkey = key
        @bmcinfo[subkey] = []
      elsif key == value and subkey
        # subvalue found
        @bmcinfo[subkey] << value
      else
        # Normal key/value pair with no subkeys
        subkey = nil
        @bmcinfo[key] = value
      end
    end
    return @bmcinfo
  end
end