Sha256: c05744e8786abaa982042b586bea97a1ad875138ac2a21112acc08a3d0690e57
Contents?: true
Size: 1.95 KB
Versions: 3
Compression:
Stored size: 1.95 KB
Contents
module Rubyipmi::Ipmitool class BaseCommand < Rubyipmi::BaseCommand def setpass super @options["f"] = @passfile.path @passfile.puts "#{@options["P"]}" @passfile.close end def makecommand args = "" # need to format the options to ipmitool format @options.each do |k,v| next if k == "cmdargs" args << "-#{k} #{v} " end # must remove from command line as its handled via conf file args.delete("-P") # since ipmitool requires commands to be in specific order args << " " + options["cmdargs"] return "#{cmd} #{args}" end # 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 def findfix(result, args, debug, runmethod) if result # The errorcode code hash contains the fix fix = Rubyipmi::Ipmitool::ErrorCodes.code[result] if not fix raise "#{result}" else @options.merge_notify!(fix) # retry the last called method # its quicker to explicitly call these commands than calling a command block if runmethod == "runcmd" runcmd(debug) else runcmd_without_opts(args, debug) end end end end def throwError # Find out what kind of error is happening, parse results # Check for authentication or connection issue #puts "ipmi call: #{@lastcall}" if @result =~ /timeout|timed\ out/ code = "ipmi call: #{@lastcall} timed out" raise code else # ipmitool spits out many errors so for now we will just take the first error code = @result.split(/\r\n/).first if not @result.empty? end throw :ipmierror, code end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubyipmi-0.6.0 | lib/rubyipmi/ipmitool/commands/basecommand.rb |
rubyipmi-0.5.1 | lib/rubyipmi/ipmitool/commands/basecommand.rb |
rubyipmi-0.5.0 | lib/rubyipmi/ipmitool/commands/basecommand.rb |