Class: Rubyipmi::Freeipmi::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Connection.



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

def initialize(user, pass, host, opts)
  @debug = opts[:debug]
  @options = Rubyipmi::ObservableHash.new
  raise("Must provide a host to connect to") unless host
  @options["hostname"] = host
  # Credentials can also be stored in the freeipmi configuration file
  # So they are not required
  @options["username"] = user if user
  @options["password"] = pass if pass
  if opts.has_key?(:privilege)
    @options["privilege-level"] = opts[:privilege]        # privilege type
  end
  # Note: rubyipmi should auto detect which driver to use so its unnecessary to specify the driver unless
  #       the user really wants to.
  @options['driver-type'] = drivers_map[opts[:driver]] unless drivers_map[opts[:driver]].nil?
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



14
15
16
# File 'lib/rubyipmi/freeipmi/connection.rb', line 14

def debug
  @debug
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/rubyipmi/freeipmi/connection.rb', line 14

def options
  @options
end

Instance Method Details

#bmcObject



50
51
52
# File 'lib/rubyipmi/freeipmi/connection.rb', line 50

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

#chassisObject



54
55
56
# File 'lib/rubyipmi/freeipmi/connection.rb', line 54

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

#drivers_mapObject



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

def drivers_map
  {
    'lan15' => 'LAN',
    'lan20' => 'LAN_2_0',
    'open'  => 'OPENIPMI'
  }
end

#fruObject



46
47
48
# File 'lib/rubyipmi/freeipmi/connection.rb', line 46

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

#get_diagObject



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

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



42
43
44
# File 'lib/rubyipmi/freeipmi/connection.rb', line 42

def provider
  'freeipmi'
end

#sensorsObject



58
59
60
# File 'lib/rubyipmi/freeipmi/connection.rb', line 58

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