Class: Rubyipmi::Ipmitool::BaseCommand

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/ipmitool/commands/basecommand.rb

Direct Known Subclasses

Bmc, Chassis, ChassisConfig, Fru, Lan, Power, Sensors

Instance Attribute Summary

Attributes inherited from BaseCommand

#cmd, #lastcall, #options, #passfile, #result

Instance Method Summary collapse

Methods inherited from BaseCommand

#dump_command, #initialize, #locate_command, #logger, #removepass, #run, #runcmd, #update, #validate_status

Constructor Details

This class inherits a constructor from Rubyipmi::BaseCommand

Instance Method Details

#find_fix(result) ⇒ Object

The findfix method acts like a recursive method and applies fixes defined in the errorcodes If a fix is found it is applied to the options hash, and then the last run command is retried until all the fixes are exhausted or a error not defined in the errorcodes is found



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rubyipmi/ipmitool/commands/basecommand.rb', line 36

def find_fix(result)
  return unless result
  # The errorcode code hash contains the fix
  begin
    fix = ErrorCodes.search(result)
    @options.merge_notify!(fix)

  rescue
    raise "Could not find fix for error code: \n#{result}"
  end
end

#makecommandObject



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

def makecommand
  args = ''
  # need to format the options to ipmitool format
  @options.each do |k, v|
    # must remove from command line as its handled via conf file
    next if k == "P"
    next if k == "cmdargs"
    args << " -#{k} #{v}"
  end

  # since ipmitool requires commands to be in specific order
  args << ' ' + options.fetch('cmdargs', '')

  "#{cmd} #{args.lstrip}"
end

#max_retry_countObject



13
14
15
# File 'lib/rubyipmi/ipmitool/commands/basecommand.rb', line 13

def max_retry_count
  @max_retry_count ||= Rubyipmi::Ipmitool::ErrorCodes.length
end

#setpassObject



5
6
7
8
9
10
11
# File 'lib/rubyipmi/ipmitool/commands/basecommand.rb', line 5

def setpass
  super
  @options["f"] = @passfile.path
  @passfile.write "#{@options['P']}"
  @passfile.rewind
  @passfile.close
end