Class: Rubyipmi::Ipmitool::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyipmi/ipmitool/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, pass, host, opts) ⇒ Connection

Returns a new instance of Connection.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rubyipmi/ipmitool/connection.rb', line 18

def initialize(user, pass, host, opts)
  @debug = opts[:debug]
  @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

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



15
16
17
# File 'lib/rubyipmi/ipmitool/connection.rb', line 15

def debug
  @debug
end

#optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/rubyipmi/ipmitool/connection.rb', line 15

def options
  @options
end

Instance Method Details

#bmcObject



51
52
53
# File 'lib/rubyipmi/ipmitool/connection.rb', line 51

def bmc
  @bmc ||= Rubyipmi::Ipmitool::Bmc.new(@options)
end

#chassisObject



59
60
61
# File 'lib/rubyipmi/ipmitool/connection.rb', line 59

def chassis
  @chassis ||= Rubyipmi::Ipmitool::Chassis.new(@options)
end

#drivers_mapObject



35
36
37
38
39
40
41
# File 'lib/rubyipmi/ipmitool/connection.rb', line 35

def drivers_map
  {
    'lan15' => 'lan',
    'lan20' => 'lanplus',
    'open'  => 'open'
  }
end

#fruObject



43
44
45
# File 'lib/rubyipmi/ipmitool/connection.rb', line 43

def fru
  @fru ||= Rubyipmi::Ipmitool::Fru.new(@options)
end

#get_diagObject



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rubyipmi/ipmitool/connection.rb', line 63

def get_diag
  data = {}
  data['provider'] = provider
  if @fru
    data['frus'] = @fru.getfrus
  end
  if @sensors
    data['sensors'] = @sensors.getsensors
  end
  if @bmc
    data['bmc_info'] = @bmc.info
  end
end

#providerObject



47
48
49
# File 'lib/rubyipmi/ipmitool/connection.rb', line 47

def provider
  'ipmitool'
end

#sensorsObject



55
56
57
# File 'lib/rubyipmi/ipmitool/connection.rb', line 55

def sensors
  @sensors ||= Rubyipmi::Ipmitool::Sensors.new(@options)
end