class Rubyipmi::Ipmitool::Bmc

Attributes

config[RW]

Public Class Methods

new(opts = ObservableHash.new) click to toggle source
Calls superclass method Rubyipmi::BaseCommand::new
# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 5
def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)
  @bmcinfo = {}
end

Public Instance Methods

guid() click to toggle source
# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 42
def guid
  @options["cmdargs"] = "bmc guid"
  value = runcmd
  @options.delete_notify("cmdargs")
  return unless value
  @result.lines.each do |line|
    line.chomp
    line.split(":").last.strip if line =~ /GUID/
  end
end
info() click to toggle source
# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 14
def info
  if @bmcinfo.length > 0
    @bmcinfo
  else
    retrieve
  end
end
lan() click to toggle source
# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 10
def lan
  @lan ||= Rubyipmi::Ipmitool::Lan.new(@options)
end
reset(type = 'cold') click to toggle source

reset the bmc device, useful for troubleshooting

# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 30
def reset(type = 'cold')
  if ['cold', 'warm'].include?(type)
    @options["cmdargs"] = "bmc reset #{type}"
    value = runcmd
    @options.delete_notify("cmdargs")
    return value
  else
    logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
    raise "reset type: #{type} is not a valid choice, use warm or cold"
  end
end
retrieve() click to toggle source

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

# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 54
def retrieve
  @options["cmdargs"] = "bmc info"
  status = runcmd
  @options.delete_notify("cmdargs")
  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 value.empty?
        subkey = key
        @bmcinfo[subkey] = []
      elsif key == value && 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
version() click to toggle source
# File lib/rubyipmi/ipmitool/commands/bmc.rb, line 22
def version
  @options['V'] = nil
  runcmd
  @options.delete_notify('V')
  @result.slice(/\d\.\d.\d/)
end