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.
Methods inherited from BaseCommand
#find_fix, #makecommand, #max_retry_count, #setpass
Methods inherited from BaseCommand
#dump_command, #find_fix, #locate_command, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Bmc
Returns a new instance of Bmc.
7 8 9 10 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 7 def initialize(opts = ObservableHash.new) super("ipmitool", opts) @bmcinfo = {} end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 5 def config @config end |
Instance Method Details
#guid ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 37 def guid @options["cmdargs"] = "bmc guid" value = runcmd() @options.delete_notify("cmdargs") if value @result.lines.each { | line | line.chomp if line =~ /GUID/ line.split(":").last.strip end } end end |
#info ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 16 def info if @bmcinfo.length > 0 @bmcinfo else retrieve end end |
#lan ⇒ Object
12 13 14 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 12 def lan @lan ||= Rubyipmi::Ipmitool::Lan.new(@options) end |
#reset(type = 'cold') ⇒ Object
reset the bmc device, useful for troubleshooting
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 25 def reset(type='cold') if ['cold', 'warm'].include?(type) @options["cmdargs"] = "bmc reset #{type}" value = runcmd() @options.delete_notify("cmdargs") return value else 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
53 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 |
# File 'lib/rubyipmi/ipmitool/commands/bmc.rb', line 53 def retrieve @options["cmdargs"] = "bmc info" status = runcmd @options.delete_notify("cmdargs") subkey = nil if not 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 and 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 |