Class: Rubyipmi::Ipmitool::Bmc
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Ipmitool::Bmc
- Defined in:
- lib/rubyipmi/ipmitool/commands/bmc.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Attributes inherited from BaseCommand
#cmd, #lastcall, #max_retry_count, #options, #passfile, #result
Instance Method Summary collapse
- #guid ⇒ Object
- #info ⇒ Object
-
#initialize(opts = ObservableHash.new) ⇒ Bmc
constructor
A new instance of Bmc.
- #lan ⇒ Object
-
#reset(type = 'cold') ⇒ Object
reset the bmc device, useful for troubleshooting.
-
#retrieve ⇒ Object
This function will get the bmcinfo and return a hash of each item in the info.
- #version ⇒ Object
Methods inherited from BaseCommand
#find_fix, #makecommand, #max_retry_count, #setpass
Methods inherited from BaseCommand
#dump_command, #find_fix, #locate_command, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Bmc
Returns a new instance of Bmc.
5 6 7 8 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 5 def initialize(opts = ObservableHash.new) super("ipmitool", opts) @bmcinfo = {} end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 3 def config @config end |
Instance Method Details
#guid ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# 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 ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 14 def info if @bmcinfo.length > 0 @bmcinfo else retrieve end end |
#lan ⇒ Object
10 11 12 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 10 def lan @lan ||= Rubyipmi::Ipmitool::Lan.new(@options) end |
#reset(type = 'cold') ⇒ Object
reset the bmc device, useful for troubleshooting
30 31 32 33 34 35 36 37 38 39 40 |
# 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 ⇒ Object
This function will get the bmcinfo and return a hash of each item in the info
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
22 23 24 25 26 27 |
# 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 |