class Rubyipmi::Ipmitool::Connection

Attributes

options[RW]

Public Class Methods

new(user, pass, host, opts) click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 18
def initialize(user, pass, host, opts)
  @options = Rubyipmi::ObservableHash.new
  raise("Must provide a host to connect to") unless host
  @options["H"] = host
  # Credentials can also be stored in the freeipmi configuration file
  # So they are not required
  @options["U"] = user if user
  @options["P"] = pass if pass
  if opts.has_key?(:privilege)
    @options["L"] = opts[:privilege]
  end
  # Note: rubyipmi should auto detect which driver to use so its unnecessary to specify the driver unless
  #  the user really wants to.
  @options['I'] = drivers_map[opts[:driver]] unless drivers_map[opts[:driver]].nil?
end

Public Instance Methods

bmc() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 59
def bmc
  @bmc ||= Rubyipmi::Ipmitool::Bmc.new(@options)
end
chassis() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 67
def chassis
  @chassis ||= Rubyipmi::Ipmitool::Chassis.new(@options)
end
connection_works?() click to toggle source

test the connection to ensure we can at least make a single call

# File lib/rubyipmi/ipmitool/connection.rb, line 35
def connection_works?
  begin
    ! (bmc.info.nil? || bmc.info.empty? )
  rescue
    false
  end
end
drivers_map() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 43
def drivers_map
  {
    'lan15' => 'lan',
    'lan20' => 'lanplus',
    'open'  => 'open'
  }
end
fru() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 51
def fru
  @fru ||= Rubyipmi::Ipmitool::Fru.new(@options)
end
get_diag() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 71
def get_diag
  data = {}
  data[:provider] = provider
  data[:frus]     = fru.getfrus
  data[:sensors]  = sensors.getsensors
  data[:bmc_info] = bmc.info
  data[:version]  = bmc.version
  data
end
provider() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 55
def provider
  'ipmitool'
end
sensors() click to toggle source
# File lib/rubyipmi/ipmitool/connection.rb, line 63
def sensors
  @sensors ||= Rubyipmi::Ipmitool::Sensors.new(@options)
end