Class: Rubyipmi::Freeipmi::Connection
- Inherits:
-
Object
- Object
- Rubyipmi::Freeipmi::Connection
- Defined in:
- lib/rubyipmi/freeipmi/connection.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #bmc ⇒ Object
- #chassis ⇒ Object
-
#connection_works? ⇒ Boolean
test the connection to ensure we can at least make a single call.
- #drivers_map ⇒ Object
- #fru ⇒ Object
- #get_diag ⇒ Object
-
#initialize(user, pass, host, opts) ⇒ Connection
constructor
A new instance of Connection.
- #provider ⇒ Object
- #sensors ⇒ Object
Constructor Details
#initialize(user, pass, host, opts) ⇒ Connection
Returns a new instance of Connection.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 14 def initialize(user, pass, host, opts) @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
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 12 def @options end |
Instance Method Details
#bmc ⇒ Object
55 56 57 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 55 def bmc @bmc ||= Rubyipmi::Freeipmi::Bmc.new(@options) end |
#chassis ⇒ Object
59 60 61 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 59 def chassis @chassis ||= Rubyipmi::Freeipmi::Chassis.new(@options) end |
#connection_works? ⇒ Boolean
test the connection to ensure we can at least make a single call
31 32 33 34 35 36 37 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 31 def connection_works? begin ! (bmc.info.nil? || bmc.info.empty? ) rescue false end end |
#drivers_map ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 39 def drivers_map { 'lan15' => 'LAN', 'lan20' => 'LAN_2_0', 'open' => 'OPENIPMI' } end |
#fru ⇒ Object
51 52 53 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 51 def fru @fru ||= Rubyipmi::Freeipmi::Fru.new(@options) end |
#get_diag ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 67 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 ⇒ Object
47 48 49 |
# File 'lib/rubyipmi/freeipmi/connection.rb', line 47 def provider 'freeipmi' end |