Package ganeti :: Package server :: Module rapi :: Class RemoteApiHandler
[hide private]
[frames] | no frames]

Class RemoteApiHandler

source code


REST Request Handler Class.

Instance Methods [hide private]
 
__init__(self, user_fn, reqauth, _client_cls=None)
Initializes this class.
source code
 
_GetRequestContext(self, req)
Returns the context for a request.
source code
 
AuthenticationRequired(self, req)
Determine whether authentication is required.
source code
 
Authenticate(self, req, username, password)
Checks whether a user can access a resource.
source code
 
HandleRequest(self, req)
Handles a request.
source code

Inherited from http.auth.HttpServerRequestAuthentication: GetAuthRealm, PreHandleRequest, VerifyBasicAuthPassword

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
tuple; (string, string)
FormatErrorMessage(values)
Formats the body of an error message.
source code
Class Variables [hide private]
  AUTH_REALM = "Ganeti Remote API"
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, user_fn, reqauth, _client_cls=None)
(Constructor)

source code 

Initializes this class.

Parameters:
  • user_fn (callable) - Function receiving username as string and returning http.auth.PasswordFileUser or None if user is not found
  • reqauth (bool) - Whether to require authentication
Overrides: object.__init__

FormatErrorMessage(values)
Static Method

source code 

Formats the body of an error message.

Parameters:
  • values (dict) - dictionary with keys code, message and explain.
Returns: tuple; (string, string)
Content-type and response body
Overrides: http.server.HttpServerHandler.FormatErrorMessage

_GetRequestContext(self, req)

source code 

Returns the context for a request.

The context is cached in the req.private variable.

AuthenticationRequired(self, req)

source code 

Determine whether authentication is required.

Parameters:
  • req - HTTP request context
Overrides: http.auth.HttpServerRequestAuthentication.AuthenticationRequired

Authenticate(self, req, username, password)

source code 

Checks whether a user can access a resource.

Overrides: http.auth.HttpServerRequestAuthentication.Authenticate

HandleRequest(self, req)

source code 

Handles a request.

Overrides: http.server.HttpServerHandler.HandleRequest