Revision b61fa2cb

View differences:

src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb
31 31
    #
32 32
    def do_auth(env, params={})
33 33
        auth = Rack::Auth::Basic::Request.new(env)
34

  
35 34
        if auth.provided? && auth.basic?
36 35
            username, password = auth.credentials
37

  
38 36
            authenticated = false
39 37

  
40 38
            invalid_chars =
......
72 70

  
73 71
                rc = user.info
74 72
            end
75

  
76 73
            if OpenNebula.is_error?(rc)
77 74
                if logger
78 75
                    logger.error{ "User #{username} could not be authenticated"}
79 76
                    logger.error { rc.message }
77
                    throw Exception(rc.message) if rc.is_exml_rpc_call?()
80 78
                end
81 79
                return nil
82 80
            end
src/oca/ruby/opennebula/client.rb
201 201
                    response[1] #response[1..-1]
202 202
                end
203 203
            rescue Exception => e
204
                Error.new(e.message)
204
                Error.new(e.message, Error::EXML_RPC_CALL)
205 205
            end
206 206
        end
207 207

  
src/oca/ruby/opennebula/error.rb
28 28
        EACTION         = 0x0800
29 29
        EXML_RPC_API    = 0x1000
30 30
        EINTERNAL       = 0x2000
31
        ENOTDEFINED     = 0x1111
32

  
31
        EALLOCATE       = 0x4000
32
        ENOTDEFINED     = 0xF001
33
        EXML_RPC_CALL   = 0xF002
34
        
33 35
        attr_reader :message, :errno
34 36

  
35 37
        # +message+ Description of the error
......
42 44
        def to_str()
43 45
            @message
44 46
        end
47

  
48
        def is_exml_rpc_call?()
49
            @errno == EXML_RPC_CALL
50
        end
51

  
45 52
    end
46 53

  
47 54
    # Returns true if the object returned by a method of the OpenNebula
......
49 56
    def self.is_error?(value)
50 57
        value.class==OpenNebula::Error
51 58
    end
59

  
52 60
end

Also available in: Unified diff