Sha256: b8f27ac981036be96c4b7bf30a3ca4387d0e99f2b95e6edf1615a3bab0b586e9

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

module Rubyipmi
  module Ipmitool
    class ErrorCodes

      @@codes = {
          "Authentication type NONE not supported\nAuthentication type NONE not supported\n" +
              "Error: Unable to establish LAN session\nGet Device ID command failed\n" => {"I" => "lanplus"},
         "Authentication type NONE not supported" => {"I" => "lanplus"}


      }
      def self.length
        @@codes.length
      end

      def self.code
        @@codes
      end

      def self.search(code)
        fix = @@codes.fetch(code,nil)
        if fix.nil?
          @@codes.each do | error, result |
            # the error should be a subset of the actual erorr
            if code =~ /.*#{error}.*/i
              return result
            end
          end
        else
          return fix
        end
        raise "No Fix found" if fix.nil?
      end


      def throwError
        # Find out what kind of error is happening, parse results
        # Check for authentication or connection issue

        if @result =~ /timeout|timed\ out/
          code = "ipmi call: #{@lastcall} timed out"
          raise code
        else
          code = @result.split(":").last.chomp.strip if not @result.empty?
        end
        case code
          when "invalid hostname"
            raise code
          when "password invalid"
            raise code
          when "username invalid"
            raise code
          else
            raise :ipmierror, code
        end
      end


    end




  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubyipmi-0.8.1 lib/rubyipmi/ipmitool/errorcodes.rb
rubyipmi-0.7.0 lib/rubyipmi/ipmitool/errorcodes.rb