Class: Rubyipmi::Freeipmi::BaseCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Rubyipmi::Freeipmi::BaseCommand
- Defined in:
- lib/rubyipmi/freeipmi/commands/basecommand.rb
Direct Known Subclasses
Bmc, BmcConfig, BmcDevice, BmcInfo, Chassis, ChassisConfig, Fru, Power, Sensors
Instance Attribute Summary
Attributes inherited from BaseCommand
#cmd, #lastcall, #options, #passfile, #result
Instance Method Summary collapse
-
#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.
- #makecommand ⇒ Object
- #max_retry_count ⇒ Object
- #setpass ⇒ Object
-
#validate_status(exitstatus) ⇒ Object
This method will check if the results are really valid as the exit code can be misleading and incorrect this is required because freeipmi in older version always returned 0 even if an error occured.
Methods inherited from BaseCommand
#dump_command, #initialize, #locate_command, #logger, #removepass, #run, #runcmd, #update
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
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rubyipmi/freeipmi/commands/basecommand.rb', line 55 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 |
#makecommand ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubyipmi/freeipmi/commands/basecommand.rb', line 17 def makecommand # need to format the options to freeipmi format args = @options.collect do |k, v| # must remove from command line as its handled via conf file next if k == 'password' next if k == 'username' if !v "--#{k}" else "--#{k}=#{v}" end end.join(" ") "#{cmd} #{args.rstrip}" end |
#max_retry_count ⇒ Object
13 14 15 |
# File 'lib/rubyipmi/freeipmi/commands/basecommand.rb', line 13 def max_retry_count @max_retry_count ||= Rubyipmi::Freeipmi::ErrorCodes.length end |
#setpass ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/rubyipmi/freeipmi/commands/basecommand.rb', line 5 def setpass super @options["config-file"] = @passfile.path @passfile.write "username #{@options['username']}\n" @passfile.write "password #{@options['password']}\n" @passfile.close end |
#validate_status(exitstatus) ⇒ Object
This method will check if the results are really valid as the exit code can be misleading and incorrect this is required because freeipmi in older version always returned 0 even if an error occured
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rubyipmi/freeipmi/commands/basecommand.rb', line 35 def validate_status(exitstatus) case @cmdname when "ipmipower" # until ipmipower returns the correct exit status this is a hack # essentially any result greater than 23 characters is an error raise "Error occurred" if @result.length > 23 when "bmc-config" if @result.length > 100 && exitstatus.success? return true else raise "Error occurred" end else super end end |