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, #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



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubyipmi/ipmitool/commands/basecommand.rb', line 39

def find_fix(result)
  if 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
end

#makecommandObject



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

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', '')

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

#max_retry_countObject



15
16
17
# File 'lib/rubyipmi/ipmitool/commands/basecommand.rb', line 15

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

#setpassObject



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

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